# [Community Puzzle] deus Hex machina

Coding Games and Programming Challenges to Code Better

Created by @_yel_p,validated by @JDOnline,@UncleV and @667ekipafond.
If you have any issues, feel free to ping them.

Hi,

Maybe there’s some math trick that helps you solve this directly but isn’t this only easy once you have the binary representation of the hexadecimal?
This might be super easy in Python3 but some languages don’t handle anything > 2^63 natively.

Hex to binary is easy to do one character at a time, you don’t need to convert the whole number at once.

Probably shouldn’t be in the easy section though, theres some knowledge needed and a few different steps.

2 Likes

I did it in C++ and I didn’t need any big number. As RoboStac said, you can obtain binary representation one character at a time, since the input is hexadecimal.

1 Like

For information to anyone still searching, it is not needed to solve this problem to track the flips of the digits more precisely than with the use of ‘#’ (I did track each change individually and it’s of no use).

+RoboStac probably shouldn’t be in the easy section, there is a clear gap between it and euclid’s algorithm

Hey, still searching. In python. Not that easy for me.
i made a dictionnary and loop throught bit for flip seq and loop for each digit of number but pass test 1,2 and 4 only. Can figure out the issue

Still searching too. Could someone explain the first flips for test 6 : as I understand it, “555689abde1222” becomes “222e8a9##61555” after first flip ( necessarily “1” so vertical flip) and I stop here because there are two “#”. Where do I miss something ?
Thx

2 Likes

“555689abde1222” becomes “222e8a9##61555” after first flip

The statement said, “The # symbol means arbitrary shapes that don’t look like a valid hex digit.” It means it is still a “shape” and is allowed to happen as long as it does not happen at the very end.

“bd” flips to become shapes “##”. Flip again it returns to “bd”.

4 Likes

Well that changes everything… I now have a working code for this, but any test after 10 needs some serious optimisation to run and I’m not there yet. I’m wondering as well if this should be in easy or not?

Even in Python, converting to binary is much more expensive than processing character by character.

However, one needs to handle leading (binary) zeroes, which don’t count as flips. This seems doubtful to me, especially when there is a test case that starts with an hexa zero, hinting that leading zeroes are meaningful in hexa, but not in binary !

Hi,
In the 6th test, I don’t understand why 555689abde1222 can become 55519bd6e8a222, as I can’t see any way for a 6 to be a 1.
I handled #, as for instance b becomes # when vertically flipped, I must convert it back to a b when flipped again.
If someone can help me, I’d be very grateful.

Look at your hands, they are also flipped physically.

I just realized that I forgot to reverse the order while flipping horizontally, my bad.