# Need some more help plz

I'm making a program that conducts a game in which the player can move around a bin of apples with a random binary number on it. Then three apples drop from a tree and the player then must catch the apple with the correct decimal conversion on it. I am having a lot of trouble. I do not know how to make it so that the apple bin , the sprite, knows if it is touching the correct answer. Basically, I need to figure out a way to create a block that will be able to set each binary number to a correct answer. Any help is appreciated, thank you!

So, you're saying you need to convert a text string of zeros and ones into a number? Here's how I think about it: Divide the string into the last character (one bit) and the rest of the string. Then:

1. Convert the rest of the string to a number. Go ahead, pick an example and do this in your head. How does the result compare to the value that those bits contribute to the entire number? For example, say the string is "111". So the all-but-last string is "11". That represents the value 3. But in the original string, those bits represent the value 6.

2. Now, what about the last bit? Well, it just represents the number that Snap! thinks it represents, 1.

3. Now add the 6 from step one with the 1 from step two.

Get it? Write the code.

Alternative algorithm:

1. Take the leftmost bit. It's your starting value. Continue with that value and the rest of the string. So you have 1 and "11" respectively.

2. As long as the string is nonempty, multiply your number by 2 and add the new first digit, in this case 2+1=3, new string is "1". Then again, new value is 3*2+1, new string is "" (empty).

The value you have now is the solution.

Try writing it this way, too.