Discuss Scratch

TheHockeyist
Scratcher
1000+ posts

Converting one number to another.

I don't mean like “multiply by 2, divide by x” sort of stuff. I'm coding in a project that randomly generates two 6 digit numbers using 7's and 8's (the project's equivalent of 0's and 1's). The first result is “old” and the second is “new”. And each of the 64 possible combinations needs to be translated into a number from 1-64. How do I do that?

I could do
defineconvertresultifresult=777777thensetresultto1ifresult=888888thensetresultto2. . .ifresult=878787thensetresultto64

But I cannot do that for some reason. Can anyone help me to convert one number to another? I need to do this for both of my “old” and “new” variables which are set up in 6-digit format.
drmcw
Scratcher
1000+ posts

Converting one number to another.

Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
TheHockeyist
Scratcher
1000+ posts

Converting one number to another.

drmcw wrote:

Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
It has to be.
drmcw
Scratcher
1000+ posts

Converting one number to another.

TheHockeyist wrote:

drmcw wrote:

Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
It has to be.
Unless you can come up with a mathematical function that relates the two number systems then a huge if then else switch statement is one way to go the other would be to fill a list with the numbers then find the number in the list and it's index is the converted number.
TheHockeyist
Scratcher
1000+ posts

Converting one number to another.

drmcw wrote:

TheHockeyist wrote:

drmcw wrote:

Does it have to be 777777 = 1 and 888888=2? It would be much easier if you could treat it like binary so 7 = 0 and 8 =1 then 777777=0 and 888888 = 63
It has to be.
Unless you can come up with a mathematical function that relates the two number systems then a huge if then else switch statement is one way to go the other would be to fill a list with the numbers then find the number in the list and it's index is the converted number.
Thanks.
TheHockeyist
Scratcher
1000+ posts

Converting one number to another.

I've inserted the list now,

item 1 = 777777
item 2 = 888888

item 64 = 878787

But how do you check the location of something in the list?
TheHockeyist
Scratcher
1000+ posts

Converting one number to another.

Nevermind, the code is working now. I'm going to report this to be closed.

Powered by DjangoBB