ZIO problems

Hey, @jinishatejura nice to meet you. Sudheerays and I just help each other out in difficulties, we don’t have any group but we just chat on WhatsApp.

Thank You!

2 Likes

ZIO2008 P.1
Transform a number to gray code:
Example 78:
At first I calculate the next bigger power of 2 --> 128
Then I check if the number is part of the first (0-63) part or the second (64-127) part.
It is the second part --> by rule we have a leading 1
If we are in the second part we need to know that the order is reversed so we calculate the unreversed index of the remaining part:
formula is: end of first part (63) minus (original value (78) minus first index of second part (64))
63-(78-64) = 49

So we need to continue with 49:
Check if first (0-31) or second (32-63) part:
Second -> we add a 1 to our number (11) and apply formula again
31-(49-32) = 14

So we need to continue with 14:
Check if first (0-15) or second (16-31) part:
First -> we add a 0 to our number (110) do nothing to our number but we decrease our ranges!

So we need to continue with 14:
Check if first (0-7) or second (8-15) part:
Second -> we add a 1 to our number (1101) and apply formula again
7-(14-8) = 1

So we need to continue with 1:
Check if first (0-3) or second (4-7) part:
First -> we add a 0 to our number (11010) do nothing to our number but we decrease our ranges!

So we need to continue with 1:
Check if first (0-1) or second (2-3) part:
First -> we add a 0 to our number (110100) do nothing to our number but we decrease our ranges!

So we need to continue with 1:
Check if first (0) or second (1) part:
Second -> we add a 1 to our number (1101001) and apply formula
0-(1-1)=0 --> we are done our result is 1101001 (take care that they asked for 7 digits and we got 7 digits from our algorithm, if they would have asked for 8 or more digits we would have needed to add leading zeros!)

Apply some logic to second example.

2 Likes

ZIO 2008 P.1
Transform a number from gray code to decimal:
Do the steps from right to left and you will get same intermediate results.
I did 1101001 back to 78 as an exercise and once you have the idea its easy to apply to any number.
I leave it as exercise to you.

My excel output for the reconstruction of the 2 examples

2 Likes