# Our Setup
Alice and Bob work in an office. When the workload is light and the boss isn't looking, they often play simple word games for fun. This is one of those days!
# This Game
Today Alice and Bob are playing what they like to call _Mutations_, where they take turns trying to "think up" a new four-letter word identical to the prior word except for one letter. They just keep on going until their memories fail out.
# Their Words
Alice and Bob have memories of the same size, each able to recall `10` to `2000` different four-letter words. Memory words and initial game word are randomly taken from a list of `4000` (unique, four-letter, lowercased) words, any of which may appear in both memories.
The expression to "think up" a new word means that for their turn, the player must submit as their response word the first valid, unused word that appears in their memory (by lowest array index), as their memories are ordered from the most "memorable" words to the least.
# The Rules
* a valid response word must contain four different letters
* `1` letter is replaced while the other `3` stay in position
* it must be the lowest indexed valid word in their memory
* this word cannot have already been used during the game
* the final player to provide a valid word will win the game
* if 1st player fails 1st turn, 2nd can win with a valid word
* when both players fail the initial word, there is no winner
# Your Task
To determine the winner!
# Some Examples
`alice = plat,rend,bear,soar,mare,pare,flap,neat,clan,pore`
`bob   = boar,clap,farm,lend,near,peat,pure,more,plan,soap`
1) In the case of `word = "send"` and `first = 0`:
* Alice responds to `send` with `rend`
* Bob   responds to `rend` with `lend`
* Alice has no valid response to `lend`
* Bob   wins the game.
2) In the case of `word = "flip"` and `first = 1`:
* Bob   has no valid response to `flip`
* Alice responds to `flip` with `flap`
* Alice wins the game.
3) In the case of `word = "maze"` and `first = 0`:
* Alice responds to `maze` with `mare`
* Bob   responds to `mare` with `more`
* Alice responds to `more` with `pore`
* Bob   responds to `pore` with `pure`
* Alice responds to `pure` with `pare`
* Bob   has no valid response to `pare`
* Alice wins the game.
4) In the case of `word = "calm"` and `first = 1`:
* Bob   has no valid response to `calm`
* Alice has no valid response to `calm`
* Neither wins the game.
# Input
``` c
size_t n                    // number of words (10 <= n <= 2000)
const char *const alice[n]; // Alice's memory of four-letter words
const char *const bob[n];   // Bob's memory of four-letter words
const char* word;           // initial challenge word of the game
int first;                  // whom begins: 0 for Alice, 1 for Bob
```
``` python
alice  #  list of words in Alice's memory (10 <= n <= 2000)
bob    #  list of words in Bob's memory (10 <= n <= 2000)
word   #  string of the initial challenge word
first  #  integer of whom begins: 0 for Alice, 1 for Bob
```
``` javascript
let alice;  //  array of words in Alice's memory (10 <= n <= 2000)
let bob;    //  array of words in Bob's memory (10 <= n <= 2000)
let word;   //  string of the initial challenge word
let first;  //  integer of whom begins: 0 for Alice, 1 for Bob
```
# Output
``` c
return  0  //  if Alice wins
return  1  //  if Bob wins
return -1  //  if both fail
```
``` python
return  0  #  if Alice wins
return  1  #  if Bob wins
return -1  #  if both fail
```
``` javascript
return  0  //  if Alice wins
return  1  //  if Bob wins
return -1  //  if both fail
```
# Enjoy!
If interested, I also have [this kata](https://www.codewars.com/kata/5cb7baa989b1c50014a53333) as well as [this other kata](https://www.codewars.com/kata/5cab471da732b30018968071) to consider solving.
cmp=lambda a,b,f:(a,b)==(0,0) and -1 or a>b and 0 or a<b and 1 or a==b and not f and 1 or 0
def mutations(alice, bob, word, first):
    score = {0:0, 1:0}
    seen = {word}
    mapping = {0:alice, 1:bob}

    def foo(alice,bob,word,first):
        foo.counter += 1

        if foo.counter > 2 and not score[0] and not score[1]:
            return
        
        for a_word in mapping[first]:
            counter = 0
            for i,x in enumerate(a_word):
                if a_word[i] == word[i]:
                    counter += 1

            if counter == 3 and len(set(a_word))==4 and a_word not in seen:
                seen.add(a_word)
                word = a_word
                score[first] += 1
                break

        if counter==3 or not score[first]:
            return foo(alice,bob,word,first^1)

    foo.counter = 0
    foo(alice,bob,word,first)
    return cmp(score[0],score[1],first)
cmp=lambda a,b,f:(a,b)==(0,0) and -1 or a>b and 0 or a<b and 1 or a==b and not f and 1 or 0
def mutations(alice, bob, word, first):
    score = {0:0, 1:0}
    seen = {word}
    mapping = {0:alice, 1:bob}

    def foo(alice,bob,word,first):
        foo.counter += 1

        if foo.counter > 2 and not score[0] and not score[1]:
            return
        
        for a_word in mapping[first]:
            counter = 0
            for i,x in enumerate(a_word):
                if a_word[i] == word[i]:
                    counter += 1

            if counter == 3 and len(set(a_word))==4 and a_word not in seen:
                seen.add(a_word)
                word = a_word
                score[first] += 1
                break

        if counter==3 or not score[first]:
            return foo(alice,bob,word,first^1)

    foo.counter = 0
    foo(alice,bob,word,first)
    return cmp(score[0],score[1],first)