( 1 0 , 4 ) → ( 2 0 , 5 ) → ( 2 1 , 1 0 ) → ( 4 2 , 1 1 ) → ( 4 3 , 2 2 ) → ( 4 4 , 4 4 )
I have two integers A and B . Each turn, I must double one number and add 1 to the other. I repeat this process, with the goal of making the integers equal to each other. The above is an example of how we can start from ( 1 0 , 4 ) and get to two equal integers.
Given that I have the initial pairs of integers A = 3 0 0 , B = 3 0 1 and that after M steps I have the pairs ( N , N ) for some integer N . What is the value of N such that M is minimized?
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.
Oh wow, I didn't noticed you have posted a solution. My bad. For a non-CS solution, see the report made by Garrett in the report section.
Represent the possible turns using binary digits: 0 : ( a , b ) ↦ ( 2 a , b + 1 ) , 1 : ( a , b ) ↦ ( a + 1 , 2 b ) . In this notation, binary strings represent compositions. For instance, 0 1 denotes the composition given by 0 1 ( a , b ) = 0 ( 1 ( a , b ) ) = ( 2 a + 2 , 2 b + 1 ) . The script below generates all binary strings with 10 or fewer characters, applies the corresponding sequences of turns to 300 and 301, and prints those strings that produce a pair of matching numbers. The only sequence that produces a pair of matching numbers is 1 1 0 0 0 0 1 0 1 1 , which has length 10. Therefore, the smallest value of M is 10. The pair produced by 1 1 0 0 0 0 1 0 1 1 is ( 9 6 6 8 , 9 6 6 8 ) , so N = 9 6 6 8 .
Here is one more interesting observation. For all x , 1 1 0 0 0 0 1 0 1 1 ( x , x + 1 ) = ( 3 2 x + 6 8 , 3 2 x + 6 8 ) . This means that for any pair of starting values x and x + 1 , the minimum number of turns to get matching numbers is at most 10. There are some pairs for which a smaller number of turns is possible. For example, the starting numbers 4 and 5 both become 68 after applying the seven-turn sequence corresponding to 1 1 0 1 0 0 0 .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Even though this solution is longer than the other solution, this is certainly easier to digest. Yup, binary numbers is the idea here! +1
Problem Loading...
Note Loading...
Set Loading...
Because this has been posted under logic, I tend to believe that Goh has some way to solve it by hand which bizzares me.
I solve it through breadth first search.