2008-03-24

Ruby Quiz---Solving Tactics

关键字: ruby quiz
There is a pencil and paper game, Tactics, played on a 4×4 grid. The
play starts with an empty grid. On each turn, a player can fill in
from one to four adjacent squares, either horizontally or vertically. The
player who fills in the last square loses.
Your task is to write a Ruby program that, given only these rules, determines
whether the first or second player is bound to be the winner,
assuming perfect play. It should do this in a “reasonable” amount of
time and memory—it should definitely take less than a minute on any
processor less than five years old. You get bonus points if you can make
the case that your program actually gets the right answer for the right
reason!
  • 8893eae5-6aba-3bc9-b85f-316129906c40-thumb
  • 描述: initializing and recursive playing
  • 大小: 61.5 KB
  • C5d4a94e-42d8-3629-8c9f-f51c2c7d02b8-thumb
  • 描述: generating all possible moves
  • 大小: 76.6 KB
评论
发表评论

您还没有登录,请登录后发表评论