← Questions

XOR random number generator to encrypt and decrypt a tree

0
BasetenCodingLast asked Aug 2026
  1. Implement a pseudo-random number generator whose state update uses bitwise XOR (shifts and XORs on an integer state), seeded so the same seed always gives the same sequence.
  2. Use it to encrypt a tree-structured document, walking the tree in a fixed order and mixing each value with the next generated number, and write the decryption that turns the result back into the original document. Explain why the same seed and the same traversal order make decryption work.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding