Fun Number Theory Game

Sally likes to play a math game with herself. She starts with a number, x. She then will repeatedly do a move to x. A move consists of either multiplying the number by 3 or subtracting 1. For example, if x=2, she could multiply by 3 to get 6, subtract 1 to get 5, and multiply by 3 again to get 15, for a total of 3 moves to get from 2 to 15. What is the minimum number of moves she could use to get from 1 to 100?


The answer is 12.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Richard Desper
Dec 22, 2020

It is easier to reverse the rules and look for a path from 100 100 to 1 1 . When going backward a simple heuristic suffices:

Our two possible moves are n n / 3 n \rightarrow n/3 and n n + 1 n \rightarrow n+1

From the number n n

a) if 3 n 3 | n , move to n / 3 n/3

b) if 3 n 3 \nmid n , move to n + 1 n+ 1 .

Clearly if 3 n 3 \nmid n we cannot move to n / 3 n/3 as every number in the forward path is an integer.. So to show the soundness of this approach, it suffices to show that, when possible, it's preferable to divide by 3 3 than to add 1 1 .
This is fairly obvious: the path of

n n / 3 n / 3 + 1 n \rightarrow n/3 \rightarrow n/3 +1

gets us to the same place as

n n + 1 n + 2 n + 3 n / 3 + 1 n \rightarrow n+1 \rightarrow n+2 \rightarrow n+3 \rightarrow n/3+1 ,

and it takes 2 fewer steps.

So, our backwards path goes 100 101 102 34 35 36 12 4 5 6 2 3 1 100 \rightarrow 101 \rightarrow 102 \rightarrow 34 \rightarrow 35 \rightarrow 36 \rightarrow 12 \rightarrow 4 \rightarrow 5 \rightarrow 6 \rightarrow 2 \rightarrow 3 \rightarrow 1

Our optimal path has 12 steps.

Hongqi Wang
Dec 22, 2020

we can do the reversed moving from 100 to 1:

( ( ( ( 100 + 1 + 1 ) ÷ 3 + 1 + 1 ) ÷ 3 ÷ 3 + 1 + 1 ) ÷ 3 + 1 ) ÷ 3 = 1 ((((100 + 1 + 1) \div 3 + 1 + 1) \div 3 \div 3 + 1 + 1) \div 3 + 1) \div 3 = 1

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...