AceInfinity
Emeritus, Contributor
There is a challenge on a coding website sponsored by Nintendo. The idea is to reverse the encoding process specified by the below code:
There is also some pseudo code for this encoding process on the website, but it's very difficult. For those of you brave enough to give it a shot: https://www.codingame.com
(In the "Games" section down near the bottom the Nintendo challenge description can be found)
Good luck! :thumbsup2:
Code:
[NO-PARSE]
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int size;
cin >> size;
unsigned int *a = new unsigned int[size / 16]; // <- input tab to encrypt
unsigned int *b = new unsigned int[size / 16]; // <- output tab
for (int i = 0; i < size / 16; i++) // Read size / 16 integers to a
{
cin >> hex >> a[i];
}
for (int i = 0; i < size / 16; i++) // Write size / 16 zeros to b
{
b[i] = 0;
}
for (int i = 0; i < size; i++)
for (int j = 0; j < size; j++)
{
b[(i + j) / 32] ^= ((a[i / 32] >> (i % 32)) &
(a[j / 32 + size / 32] >> (j % 32)) & 1) << ((i + j) % 32); // Magic centaurian operation
}
for (int i = 0; i < size / 16; i++)
{
if (i > 0)
{
cout << ' ';
}
cout << setfill('0') << setw(8) << hex << b[i]; // print result
}
cout << endl;
delete [] a;
delete [] b;
/*
Good luck humans
*/
return 0;
}[/NO-PARSE]
There is also some pseudo code for this encoding process on the website, but it's very difficult. For those of you brave enough to give it a shot: https://www.codingame.com
(In the "Games" section down near the bottom the Nintendo challenge description can be found)
Good luck! :thumbsup2: