Last active
August 29, 2015 14:10
-
-
Save veiset/3fb27fc3c1b65e6869a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BLACK, WHITE, SIZE, MOVES = True, False, 10, [[-2,-1],[-2,1],[-1,-2],[-1,2],[1,-2],[1,2],[2,-1],[2,1]] | |
pos, board = [0, 0], [[WHITE for _ in range(SIZE)] for _ in range(SIZE)] | |
for _ in range(200): | |
x, y = pos | |
moves = map(lambda move: [x+move[0], y+move[1]], MOVES) | |
validMoves = filter(lambda pos: SIZE > pos[0] >= 0 and SIZE > pos[1] >= 0, moves) | |
sameColorMoves = filter(lambda move: board[x][y] == board[move[0]][move[1]], validMoves) | |
pos = sameColorMoves[0] if sameColorMoves else validMoves[-1] | |
board[x][y] = not board[x][y] | |
print sum(map(sum, board)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment