Code a simple REST web service to start playing Reversi. It should accept a 64-character string representing the current 8×8 “game board” with dot (empty space), X (black), or O (white) in each position (starting from the top left, going left-to-right and down). It should return a 64-character string with your next move added. Don’t worry about turning pieces yet, just find the next best move.

Here’s a simple solution in PHP, with room for improvement. To start playing, pass it ?board=………………………OX……XO………………………&piece=X.

Of course, there are much smarter ways to code Reversi, such as applying common strategies and running look-ahead scenarios, but that’d be more than a fragment. Years ago, a coworker wrote one for VisualWorks (still in the Cincom Public Repository), and there’s a well-documented implementation at lurgee.net. If you’re up for coding a smarter version behind the service interface, give it a shot.