Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Got it!</p> <p>Here is my solution in Python:</p> <pre><code>a = 5402147 b = 54321 n = 10000001 def psi(x): return (a * x + b) % n inverse1000 = 9990001 max_k = (n-1) / 1000 + 1 def first_input(y): global last_input, i, possible_k last_input = y possible_k = [set(range(max_k))] i = 0 def add_input(y): global last_input, i c = inverse1000 * (b + a * last_input - y) % n sk0 = set() sk1 = set() for k0 in possible_k[i]: ak0 = a * k0 % n for k1 in range(max_k): if (k1 - ak0) % n == c: sk0.add(k0) sk1.add(k1) #print "found a solution" last_input = y possible_k[i] = possible_k[i] &amp; sk0 possible_k.append(sk1) i += 1 if len(possible_k[i-1]) == 0 or len(possible_k[i]) == 0: print "Wrong machine" return if len(possible_k[i]) == 1: x = y + 1000 * possible_k[i].copy().pop() for j in range(10): x = psi(x) print x % 1000, print return print "Not enough observations" </code></pre> <p>It could probably be optimized (and cleaned), but since it runs in less than 30sec on my 3 years old laptop I probably won't bother making it faster...</p> <p>The program doesn't accept exactly the same input as requested, here is how to use it:</p> <pre><code>&gt;&gt;&gt; first_input(767) &gt;&gt;&gt; add_input(308) Not enough observations &gt;&gt;&gt; add_input(284) 577 428 402 291 252 544 735 545 771 34 &gt;&gt;&gt; first_input(78) &gt;&gt;&gt; add_input(880) Not enough observations &gt;&gt;&gt; add_input(53) 698 235 762 18 98 703 456 676 621 291 &gt;&gt;&gt; add_input(698) 235 762 18 98 703 456 676 621 291 488 &gt;&gt;&gt; add_input(235) 762 18 98 703 456 676 621 291 488 332 &gt;&gt;&gt; first_input(862) &gt;&gt;&gt; add_input(452) Not enough observations &gt;&gt;&gt; add_input(303) Wrong machine &gt;&gt;&gt; add_input(558) Wrong machine </code></pre> <p>As you can see, usually 3 observations are enough to determine the future outcomes.</p> <p>Since it's a pain to write math stuff in a text editor I took a picture of my <strike>demonstration</strike> explanation:</p> <p><img src="https://i.stack.imgur.com/5vFDJ.jpg" alt="hand written &quot;demonstration&quot;"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload