It’s Friday, and time again for the Friday Fragment: our weekly programming-related puzzle.
This Week’s Fragment
Having finished a series of game bots, we’ll have a Thanksgiving change of pace and do another cryptogram. Crack the following cipher:
OBKR
UOXOGHULBSOLIFBBWFLRVQQPRNGKSSO
TWTQSJQSSEKZZWATJKLUDIAWINFBNYP
VTTMZFPKWGDKZXTJCDIGKUHUAUEKCAR
You can provide the solution or just offer suggestions on how to go about solving it. For example, I can’t solve it, but based on its background (try some googling), I have ideas about how it might be solved. To “play along,” post your response as a comment or send it via email.
Last Week’s Fragment – Solution
Last week’s puzzle was to code a simple Reversi competition:
Write code to call competing Reversi bots, flip pieces, and score the results.
Here’s a solution in PHP.
<?php require('reversimove.php); $urls[0] = 'http://derekwilliams.us/bots/reversi'; $urls[1] = $urls[0]; // Your bot here $pieces = array('X', 'O'); $board = str_repeat('.',64); $board[27]='O'; $board[28]='X'; $board[35]='X'; $board[36]='O'; $player = 0; for ($i=0; $i<64; $i++) {; $play = file_get_contents($urls[$player].'?board='.$board.'&piece='.$pieces[$player]); $board = update_board($board, $play); show_board($board); $player = $player == 0 ? 1 : 0; } function show_board($board) { $scores = array('.' => 0, 'X' => 0, 'O' => 0); echo '<table border="1">'; for ($i=0; $i<8; $i++) { echo '<tr border="1">'; for ($j=0; $j<8; $j++) { $piece = $board[($i*8)+$j]; $scores[$piece]++; echo '<td border="1">'.$piece.' </td>'; } echo '</tr>'; } echo '</table><p> </p>'; printf("<p>X: %d, O: %d</p>", $scores['X'], $scores['O']); if ($scores['.'] == 0) exit(printf("<p>%s wins!</p>", $scores['X'] > $scores['O'] ? 'X' : 0)); } ?>
You can run this solution and other bots from the links at http://derekwilliams.us/bots. This page also includes full source code, including helper functions.