>>13217981okay.
So i have this assignment where i have to code a game called "Nim" where two players take turns removing objects from distinct heaps or piles, and the player that gets to remove the last object wins.
I've already coded a function for doing a specific move, i.e :
play [1,2,3,4] (3,2) = [1,2,1,4].
[1,2,3,4] would be the number of objects on each tile, and (3,2) would be removing 2 objects from the third tile.
I also coded a function that gives a list of all the posible plays on a specific board position, i.e:
possiblePlays [1,2,3] = [(1,1), (2,2),(2,1),(3,3), (3,2), (3,1)]
The problem i'm having is that now i have to code a function that tells me if a board position (like [1,2,3,4]) is "winnable": a board position is winnable if a play exists that can lead to the other player getting a not winnable board position. i.e:
isItWinnable [] = False (because you can't make another move, so you lose)
isItWinnable [1] = True (because you get to remove the last object).
I think these could be the base cases, but i'm having a lot of trouble thinking the recursion.