Skip to content

Instantly share code, notes, and snippets.

View ranraj's full-sized avatar
🏠
Working from home

Ranjithrajd ranraj

🏠
Working from home
View GitHub Profile
[{
"id": 1,
"name": "W180"
},
{
"id": 2,
"name": "W210"
},
{
"id": 3,

The goal is to write an API for the tic-tac-toe game. An API user, should be able to play a game of tic-tac-toe using this API, but importantly, it should be impossible for the API user to break the rules of the game. Specifically, if an attempt is made to break a rule, the API should reject the program. This is often done by way of a compile-time type error.

The following API functions should exist:

  • move: takes a tic-tac-toe board and position and moves to that position (if not occupied) returning a new board. This function can only be called on a board that is empty or in-play. Calling move on a game board that is finished is a compile-time type error.

  • whoWon: takes a tic-tac-toe board and returns the player that won the game (or none if neither has won). This function can only be called on a board that is finished. Calling whoWon on a game board that is empty or in-play is a compile-time type error.

  • playerAt: takes a tic-tac-toe board and position and returns the (possible) player at a given posi

@ranraj
ranraj / zsh.md
Last active January 20, 2017 19:07 — forked from tsabat/zsh.md