public
Description:
Homepage: http://tempe.st
Clone URL: git://github.com/intinig/setsolver.git
Giovanni Intini (author)
Tue Nov 04 16:17:58 -0800 2008
commit  e972e21f1eaf1776fbbb350e7b292f393f86bb56
tree    e5fa90856c9e76e09382bf25c0d358e347e74e3a
parent  1f180127803ccd1f4f6c9008979178d265bb8448
setsolver / solver.rb
100755 23 lines (16 sloc) 0.451 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env ruby
 
require File.join(File.dirname(__FILE__), 'lib/board')
 
cards = []
ARGV.each do |arg|
  cards << Card.parse(arg)
end
 
raise "Incorrect number of cards you gave #{cards.size}, you need 12" unless cards.flatten.size % 3 == 0
 
board = Board.new(cards)
 
puts "=== BOARD ==="
board.cards.each do |card|
  puts card.describe
end
 
puts "\n=== SOLUTION ==="
board.solve.each do |c|
  puts c.collect {|card| card.describe}.join(" | ")
end