angelg's blog

By angelg, history, 9 years ago, In English

Let's suppose you have an array A of numbers (0-255). Then, you pick a single variable K (0-255), and you create another array B. Where Bi = Ai ^ K. Is there a way to restore the original array A? If you are not giving A or K.

  • Vote: I like it
  • -4
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Anyone cares to share the solution if it's so obvious that I'm getting downvotes?

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

255255 has 614 digits.

Are you sure about constraints or is there any modulo involved ?

  • »
    »
    9 years ago, # ^ |
      Vote: I like it +11 Vote: I do not like it

    It is not a POWER it is XOR

    • »
      »
      »
      9 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks for pointing that out. It can confuse some people.

»
9 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

if (Ai^K = Bi) then

Ai^K^K = Bi^K, so Ai = Bi^K(because K^K = 0)

Ai^K^Ai = Bi^Ai, so K = Bi^Ai(because Ai^Ai = 0)

That's how we can find Ai, when we have Bi and K or we can find K, when we have Ai and Bi.