Sha256: 08a6bdf3fd3f8689bda91b2d90b4a14c48fb1f49cac62b2de2084f0c96403751
Contents?: true
Size: 495 Bytes
Versions: 1
Compression:
Stored size: 495 Bytes
Contents
module TowersOfHanoi class Move attr_reader :origin, :destination def initialize(origin: nil, destination: nil) @origin = origin @destination = destination end def make(board) if valid?(board) board.tower(destination).add(board.tower(origin).remove) end self end private def valid?(board) (1..3) === origin && (1..3) === destination && board.tower(origin).top < board.tower(destination).top end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
towers_of_hanoi-0.2.0 | lib/towers_of_hanoi/move.rb |