[Community Puzzle] The Empire Enigma

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Hi all

I think there is an issue on the Empire Enigma puzzle for the test cases 3 and 4 in C++.
If you just print the ints provided as input for those test cases, it seems not to be in line with the description.
I tried to print the length, offset and C values and it gives invalid values (ie length is 1431655646 and shall be a lot less)
The test case 1 and 2 seem to work correctly.

Can anyone confirm this behavior ?

Regards

Ignore this message, the reason was obvious, the input value could be coded on a int64. Just had to change the width of the variable to solve it.

Here is my algorithm :
- XOR the ASCII of ‘@’ with the first number to get R(offset+1)
- Use the formula to get the others R(N) needed
- XOR the R(N) with their corresponding input number to get the final message

It doesn’t seem to work however, since I’m unable to find the right message at the end.

Here is my code (python) :

import sys

offset = int(raw_input())
length = int(raw_input())
c = []
for i in xrange(length):
c.append(int(raw_input()))

b_at = ord(‘@’)
R = []
R.append(b_at ^ c[0])

for k in range(1,length):
nombre = (7562100 * R[-1] + 907598307) % 7140
nombre = nombre & 0b11111111
R.append(nombre)

message = “”

for k in range(1, length):
message += chr(c[k] ^ R[k])

print message

What am I doing wrong please?

The statement says:

Each undiscarded random number from the RNG is then XOR’ed with the ASCII code of each character, truncated to the lowest 8 bits.

Hence “@” XOR the first number is not R(offset+1) but R(offset+1) & 0b11111111.
Moreover (this is related to the same misunderstanding), your nombre = nombre & 0b11111111 completely disturbs the RNG (to compute R(i+1), you are supposed to keep the whole R(i), not only its last 8 bits).

Thank you very much, I didn’t realize I was disturbing the RNG.

However, I’m really lost as to how I could find the whole R(offset+1) from its troncated value… Is my method even viable?

Thanks again

Well, you have to find some way to guess/try. It’s hard to give more hints without spoiling the puzzle.

1 Like

Realize that modulo is a bad formula for the empire.

1 Like