Starting from the number 1, your goal is to get to the number 17 using only these actions:
What is the minimum number of actions it takes to get to 17?
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.
Very interesting! I never would've thought about this in terms of bases. I feel like this is a really good way to introduce different number bases.
Log in to reply
Thanks... Yeah, it seems to give some motivation as to why we might want to consider other bases besides 10, 2 and 8, and 16.
I agree! I stumbled upon the 6 step solution, but the base 3 argument makes it really clear why it's optimal.
I used *.if you know your times table you should get this one easy:)
Due to my carelessness, I mistakenly thought it’s “add 3” instead of multiplying and still got 6 turns... Quite coincidence
Log in to reply
I dont know what the hex I did because I that was exactly how I did it but some how counted 8 moves in my head...Thats what I get for not writing it out....ooops
You can do it "reverse", if it is a multiple of 3, then divide by 3.
1 7 − 1 − 1 = 1 5 , 1 5 / 3 = 5 , 5 − 1 − 1 = 3 , 3 / 3 = 1
Really similar with the base 3 method.
Log in to reply
Yes, it is the same method that I used
wow it's so simplistic amazing
I did the same
how is 122 in base 3 suggesting the solution? you mean only considering units place and the hundreth place, what about 2*3^1 in tens place ( Terms in decimal system)
Log in to reply
It’s perhaps not immediately obvious but I think it’s an ingenious approach... the target is 122 in base 3, so the steps would be:
1 ... we have the first digit of the target, so the next step should be to multiply by 3
1 * 3 = 10
10 + 1 = 11
11 + 1 = 12 ... this gives the first two digits of the target, so multiply by 3 again
12 * 3 = 120
120 + 1 = 121
121 + 1 = 122
Rather than just using trial and error we can see when to multiply and when to add.
Log in to reply
quite interesting.
Log in to reply
@Sunil Nandella – thank you is this representation leading to some other subject. It cant be just this vague problem.
This is beautiful, mind blown 🤯
I had the exact thing, except I didn't realize I started with one.
*3 +1 +1 +1 *3 +1
i got the answer but i counted the step wrongπ_π
I really thought it was 7, but thank you for showing me the right way, I really appreciate it.
.×3=3+1=4×(3+1)=16+1=17=5 steps
Log in to reply
I guess that your way isn't well at all beacuse you're multiplying 4 4 (4 (3+1)) and that's not a valid way...
ahh, I just didn't think to try adding another one in the beginning, so I got 7
umm... I didn't get the base 3 thing ..
Log in to reply
"multiplying by 3 is the same as adding a 0 to the end" So...you start with 1, and know your goal ist 122. So first you add a 0 to the end, to get 10 (i.e. multiply by the base, which is 3). You add 1 to get 11, another 1 for 12, multiply again for 120, and add two 1 again. This way u don't have to consider "first add? Two multiply in a row?", the structure of the goal 122 makes it easier to think.
5 steps: 1+3=4 4+1=5 5*3=15 15+1=16 16+1=17
Log in to reply
U can only add by 1 or multiply by 3
You added 3 the first time instead of multiplying by 3 so the steps would be: 1 3=3 3+1=4 4+1=5 5 3=15 15+1=16 16+1=17
Going base 3 is suitable for any number, not just 17.
Having a look at the base3 number: - Number of multiplications = digit count - 1 - Number of additions = sum of digits.
In this task, the initial number is 1 (instead of "normal" 0), so take an addition to get the correct result.
So base 3 form of 17 is 122, like mentioned by Geoff. So number of multiplications=2 Number of additions=5 (but this time, just 4 because of the starting number)
I thought it was 7 but I forgot we were starting at 1, not 0
Got 7, then decide the world will always do 1 better, so guessed 6.
I also thought seven because I skimmed the part of starting at 0. ;-;
Same As I did
the updated version of brilliant.org is so boring
Log in to reply
In what way?
Log in to reply
where is the follower option????
u can't search for anyone or any members.
i mean the interaction has become very backdated
[it is just my opinion]
What's this base thing? I understood that 6 steps it was quite easy
The fastest solution is to get to 5 and then multiply by 3.This solution use 3 steps to get to 5.If you add 1 four times,you have to use four steps to get to 5.
Nolp . I do not understand ...
The biggest constraint is that we should include 5 × 3 since that is the biggest step. The fastest way to get to 5 is 1 × 3 + 1 + 1 = 5 . After 5 × 3 = 1 5 , the only way to 1 7 from here is 1 + 1 , giving a total of 6 turns
1+3*5=16....3 steps 16+1 = 17....That is one extra step steps. Total: is 4 Operations in the Equation.
The information provided states ONLY: " start with 1" The only actions permitted are:
" add 1" or "multiply by 3".
Other than that there are no restrictions as to HOW one gets to 17 There is no restriction on the "multiply by 3" . . .it means 3 x. . . .It does NOT mean x 3 Using x=5 gives the minimum number of steps to get to 17 with 4 steps. There is no restriction on setting x=5.
Other than the above, If "starting with 1" is counted as an " operational step then the minimum number of operations = 5.
This explanation was useful and helpful!🤩
Apply reverse thinking in finding the answer.
It is equivalent to find how to get to 1 from 17, using -1 and ÷3.
The advantage is that you can easily determine if ÷3 can be used, by checking the divisibility of 3.
Hence,
17-1=16
16-1=15, which is divisible by 3.
15÷3=5
5-1=4
4-1=3, which is divisible by 3.
3÷3=1
Therefore, 6 steps are required at least.
I like this backtracking approach. It is clear why it results in the lowest number of steps. Namely, if you don't use the divide by 3 function when you can, it definitely takes more steps.
To me, the top answer does not really provide this proof, although given this answer, it is clear why the base-3 approach should work. In other words, this answer provided the proof I was missing for the top answer.
Brilliant!
That is actually my favorite method for this question
General solution
Write the final number in ternary (base 3) notation. Let N be the number of ternary digits and S the sum of the digits. Then the minimum number of steps is X = S + N − 2 . In this case, 1 7 1 0 = 1 2 2 3 , so that N = 3 , S = 1 + 2 + 2 = 5 and X = 3 + 5 − 2 = 6 .
Reasoning
In ternary notation, the two operations we are allowed are:
adding one to the final digit
shifting all digits left (i.e. add a zero to the end)
We build the number digit by digit. The number of additions we must perform is one less than the digit sum, A = S − 1 . (One less, because we are given 1 at the beginning.)
The number of multiplications is one less than the number of digits, M = N − 1 . (One less, because we start with one digit.)
Adding gives A + M = S + N − 2 .
The only thing missing in this approach is the proof that this is indeed the minimum. The basic idea of this proof is that any sequence of three or more additions can be replaced by something more efficient. Thus, M A A A ↦ A M .
Fantastic explanation, thx!
Let's reason backwards and consider every possible case:
Let A n be the set of numbers from which you can reach 1 7 in n moves:
A 0 = { 1 7 } (duh!)
A 1 = { 1 6 } (17 is reachable only from 16)
A 2 = { 1 5 } (16 is reachable only from 15)
A 3 = { 5 , 1 4 } (15 is reachable from either 5 or 14, because it's a multiple of 3)
A 4 = { 4 , 1 3 } (5 is reachable from 4; 14 from 13)
A 5 = { 3 , 1 2 } (4 is reachable from 3; 13 from 12)
A 6 = { 1 , 2 , 4 , 1 1 } (3 is reachable from either 1 (yay!) or 2; 12 from either 4 or 11)
So the minimum number of moves is 6 .
Translating my intuitive solution into solving a graph theory problem. Nice!
We let A ( n ) to be the minimum number of actions needed. If we think intuitively, the recursive form of A ( n ) is A ( n ) = ⎩ ⎪ ⎨ ⎪ ⎧ A ( n − 1 ) + 1 min ( A ( n / 3 ) + 1 , A ( n − 1 ) + 1 ) 0 if n > 1 and is indivisible by 3 if n > 1 and is divisible by 3 if n = 1 Of course, A ( n / 3 ) might be a greater choice for the value to be minimum than A ( n − 1 ) , but you also want to know why it's true. An important observation here is that, for any three consecutive integers there must exists a number among them which is divisible by 3 . That can be proven by induction.
Then, if n / 3 (assuming n is divisible by 3 ) is an another integer indivisible by three then either n / 3 − 1 or n / 3 − 2 must be divisible by three, in this case it seems like this is a great case for minimizing the number of actions by doing either A ( ( n / 3 − 1 ) / 3 ) or A ( ( n / 3 − 2 ) / 3 ) . If n / 3 is also divisible by three (which is another luck), we can just do A ( ( n / 3 ) / 3 ) . (In fact, this is more likely a "greedy approach".)
From this observation, we transform A ( n ) to be A ( n ) = ⎩ ⎪ ⎨ ⎪ ⎧ A ( n − 1 ) + 1 A ( n / 3 ) + 1 0 if n > 1 and is indivisible by 3 if n > 1 and is divisible by 3 if n = 1
and the result is A ( 1 7 ) = A ( 1 6 ) + 1 = A ( 1 5 ) + 2 = A ( 5 ) + 3 = A ( 4 ) + 4 = A ( 3 ) + 5 = A ( 1 ) + 6 = 6 . Backtracking always helps.
I started from 17 and turned it into 1. The rules would be "subtract 1" and "divide by 3". Since division is more 'stricter' than multiply, I would be forced to reach a multiple of 3 by subtracting first.
The best way I could see approaching this problem is by thinking of it as a graph problem. The root node is 1 and every child child is reached by either multiplying by 3 or adding 1 to the previous node. So that the v i + 1 -th node is either 3 v i or v i + 1 . The easiest way to traverse the tree and determine bad paths is by either reaching a node which could have otherwise been traversed faster, or by taking the biggest step possible at each iteration.
We can formulate a similar problem by thinking of 3 n + 1 = 1 7 which yields 5R1. This gives us an idea of how close we can get by multiplication alone. The idea then is to get to 5 in the least amount of moves as possible, then to 15, then to 17.
3+1=4 4+1=5 5*3=15 15+1=16 16+1=17 It is only 5 steps I don't understand how I am the only one who realised it
((1×3)+1+1)×3+1+1=17. So the total is 6 turns.
why just not thinking that a number obtained on multiplying by 3 must be a multiple of 3! So all you need to do is generate multiples of 3 by reducing 17 by one which would yield 15! now divide by 3 to get 5 subtract 1 two times n divide by 3
the problem appears easy here but I think the smart mathematicians must try for 6565 this might outsmart you;)
The closer number to 17 which you can multiply by 3 is 15.
I thought the same as you.
Equivalent problem: starting at 1 7 , make way to 1 using one of two operations: n → n − 1 or n → n / 3 . In this case, division can only be used at multiples of 3 , so the first two steps have to be subtraction. Next, observe that a greedy strategy is optimal, since it's faster to divide by 3 and subtract 1 (two steps) than subtract 3 and then divide by 3 (four steps).
Thus the optimal path is 1 7 → 1 6 → 1 5 → 5 → 4 → 3 → 1
I found it helpful to work backwards from 17. Since 17 and 16 are not divisible by 3, you will not reach those values directly by multiplying by 3. This means that that the last two steps are going to be adding 1 to some number. When we get to 15, that is thankfully divisible by 3, so we can get to the number 5 by dividing 15 by 3. Following the same logic, we subtract one to get to 4, then 3. Dividing 3 by 3, we get back to 1 which was the starting point. Counting the steps here, it is six steps.
I tried to come up with another solution that would give a smaller amount but nothing worked lol.
You can do this, it is very simple if you think about it. Starting with 1: - 1 x 3 = 3 (Step 1) - 3 + 1 = 4 (Step 2) - 4 + 1 = 5 (Step 3) - 5 x 3 = 15 (Step 4) - 15 + 1 = 16 (Step 5) - 16 + 1 = 17 (Step 6) 6 Steps in total! don't make it too confusing but don't make it too easy for yourself.
This is really easy to figure out if you solve the problem backward. Start at 17 and try to reach 1 with the actions reversed (subtract 1, or divide by 3). Since the goal now is to reach 1 in the fewest # of actions, you should simply divide by 3 whenever you can, which is when your current number is divisible by 3, and subtract by 1 when it is not:
Start at 17 (not divisible by 3)
So the minimum # of actions is 6!
Think about the biggest number you can multiply by 3 and get under 17. Then figure out the fastest way to get to that number. 5X3=15 but 6X3=18 so you choose 5 and figure out that you can get to 3 in one step by 1X3 then add 2, multiply by 3, and add 2!
Bad path. Since 6*3 = 18, if you go up to 6 you can never multiply by 3 again. So you would have to add 1 eleven more times.
We can work backwards, reducing the total either by subtracting one (which we can always do) or by dividing by three (which we can do only if our current total is a multiple of three).
We must start off
1 7 → 1 6 → 1 5
now we have a choice. *.The obvious thing to do is to divide by three, and continue
1 7 → 1 6 → 1 5 → 5 → 4 → 3 → 1
Running this backwards exhibits a solution in 6 steps . (Obviously we reject the continuation 3 → 2 → 1 as inferior to 3 → 1 )
To complete our solution we must show that this is the best possible chain of operations. It is just possible that if we had taken the other choice at * it would have switched us onto a better track. Let's check it out and see
1 7 → 1 6 → 1 5 → 1 4 → 1 3 → 1 2 → 1 1 or 4
At this point we already have six steps, but we have not reached 1 yet, so we cannot find a better solution by this route.
I easily completed it by doing it in reverse order counting the steps:
Total steps: 6.
1 X 3 3+1 4+1 5 X 3 15 +1 16 + 1 = 17 Six steps
Problem Loading...
Note Loading...
Set Loading...
Starting with 1:
6 steps!
This is more intuitive if you think in base 3, where multiplying by 3 is the same as adding a 0 to the end.
1 7 1 0 = 1 2 2 3