Adding fingers P55691


Statement
 

pdf   zip

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 aa and bb be the number of fingers shown by X, and let cc and dd be the number of fingers shown by Y. In each turn, these are the allowed moves:

  1. Add $\bmod$ 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,c0(a,b)(c,d)(a,b)(c,d+a)if a,d0(a,b)(c,d)(a,b)(c+b,d)if b,c0(a,b)(c,d)(a,b)(c,d+b)if b,d0\left\{\begin{array}{cc} (a,b)(c,d) \to (a,b)(c+a,d) & \text{if } a,c \neq 0 \\ (a,b)(c,d) \to (a,b)(c,d+a) & \text{if } a,d \neq 0 \\ (a,b)(c,d) \to (a,b)(c+b,d) & \text{if } b,c \neq 0 \\ (a,b)(c,d) \to (a,b)(c,d+b) & \text{if } b,d \neq 0 \end{array}\right.

  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 $\bmod$ 5: {(a,b)(c,d)(a+b,0)(c,d)if a,b0(a,b)(c,d)(0,a+b)(c,d)if a,b0\left\{\begin{array}{lr} (a,b)(c,d) \to (a+b,0)(c,d) & \text{if } a,b \neq 0 \\ (a,b)(c,d) \to (0,a+b)(c,d) & \text{if } a,b \neq 0 \end{array}\right.

  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\left\{\begin{array}{lr} (a,0)(c,d) \to (x,y)(c,d) & \text{if } x+y=a \text{ and } 0 < x,y < a \\ (0,b)(c,d) \to (x,y)(c,d) & \text{if } x+y=b \text{ and } 0 < x,y < b \end{array}\right.

Both players play perfectly. The first player to get to (0,0)(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 aa, bb, cc and dd, all between 0 and 4. Assume a+b>0a + b > 0 and c+d>0c + 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++