Adding fingers P55691


Statement
 

pdf   zip

thehtml

Consider a game for two players playing alternatively. Both players show a certain number of fingers in each hand. Let X be the player that moves next, and let Y be the other player. Let a and b be the number of fingers shown by X, and let c and d be the number of fingers shown by Y. In each turn, these are the allowed moves:

  1. Add mod 5 as many fingers as X has in a non-empty hand (a hand showing at least one finger) to one of Y’s non-empty hands. That is:
            



            (a,b)(c,d) → (a,b)(c+a,d)if  a,c ≠ 0 
            (a,b)(c,d) → (a,b)(c,d+a)if  a,d ≠ 0 
            (a,b)(c,d) → (a,b)(c+b,d)if  b,c ≠ 0 
            (a,b)(c,d) → (a,b)(c,d+b)if  b,d ≠ 0
  2. “Move” the fingers in one of X’s hands to the other hand, provided that none of them are empty. Again, the operations are made mod 5:
        

        (a,b)(c,d) → (a+b,0)(c,d)if  a,b ≠ 0 
        (a,b)(c,d) → (0,a+b)(c,d)if  a,b ≠ 0
  3. “Redistribute” the fingers in X’s hands, if one of them is empty:
            

            (a,0)(c,d) → (x,y)(c,d)if  x+y=a  and  0 < x,y < a
            (0,b)(c,d) → (x,y)(c,d)if  x+y=b  and  0 < x,y < b

Both players play perfectly. The first player to get to (0, 0) loses the game. A game that never ends is considered to be a draw.

Input

Input consists of several cases, each one with a, b, c and d, all between 0 and 4. Assume a + b > 0 and c + d > 0.

Output

For every case, tell if X will win, if X will lose, or if the game is a draw.

Public test cases
  • Input

    2 4 0 3
    1 0 4 0
    0 1 0 1
    3 0 2 3
    3 3 0 4
    1 1 1 1
    

    Output

    WIN
    WIN
    LOSE
    LOSE
    DRAW
    DRAW
    
  • Information
    Author
    Marc Felipe
    Language
    English
    Official solutions
    C++
    User solutions
    C++