Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Two Piles, Diagonal Moves > Editorial

Two Piles, Diagonal Moves — Solution & Editorial

Back to the Problem

Wythoff's game: the losing (P) positions are (⌊kφ⌋, ⌊kφ²⌋) for k ≥ 0, where φ is the golden ratio. With a = min, b = max and k = b−a, the position loses iff a = ⌊kφ⌋.

Complexity: O(1)

Watch out: Floating φ near 109 can be off by one — the intended solution rounds carefully (integer Beatty-sequence test).