Skip to content

Instantly share code, notes, and snippets.

@ashpool
ashpool / knight.rb
Created February 12, 2012 17:14
The knight's tour is a mathematical problem involving a knight on a chessboard. The knight is placed on the empty board and, moving according to the rules of chess, must visit each square exactly once.
class Game
attr_accessor :board
def initialize(size)
@size = size
@board = Array.new(size)
end
def start(start_row, start_column)
first_move = Move.new(start_row, start_column, 0, @board)
@ashpool
ashpool / stripper.rb
Created February 12, 2012 16:51
Citerus challenge
class Stripper
def initialize(acronyms)
@stripCache = {}
@acronyms = acronyms
end
def strip(source)
return @stripCache[source] if @stripCache.has_key?(source)
result = source
@acronyms.each do |acronym|