Nintendo Challenge

I’ve been avoiding this problem because C++ is really not my thing, but a few days ago I decided to give it a shot. I have some familiarity with the implementation of the Rijndael/AES algorithm, and this problem seems inspired by it. Cases 1 and 2 were good hints of what was going on, so I wrote some Python+Sympy code to confirm my suspicions and, surprisingly, it solved all cases. After some digging through Sympy sources I wrote a standalone Python solution that I can port to C++. It takes 10s for the 256 bits case, but it’s correct, so now it’s more of a C++ and optimization challenge for me. Today I ported it to C++ and it runs but returns wrong results and at this point it’s beyond my C++ debugging skills. I might give it another shot later.

Maybe I shouldn’t say this, but if you’re better to optimize python than c++, you can write

#include <iostream>
int main()
{
    system("python3 -c 'insert your code python here'");
}

Yes, maybe you shouldn’t… :grimacing:

FWIW, the Python solution worked for all but the 256 bits validator. Locally I got it down to 4.7s, but it’s still timing out on CG.

After a day-long debugging and refactoring session, I finally finished it. I added identical debug statements to the Python and C++ versions, compared the outputs for all testcases with diff, and kept fixing stuff until everything matched. I’m sure the code is terrible, but it’s solving the 256 case in 600ms, enough to pass the validators. I might come back to this in the future as I try to improve my C++ skills, but for now I’m happy that I was able to finish it.

1 Like

Just to be told … My own invention was wrong, but I found a solution after half a year learning a new kind of mathematics.

It was “hard fun” to solve it :smiley:

i have and im 15 years old its very hard

well actually i got 69%