Anonymous user
Free polyominoes enumeration: Difference between revisions
→{{header|Ruby}}: reduction of the unnecessary argument
(Added Ruby) |
(→{{header|Ruby}}: reduction of the unnecessary argument) |
||
Line 671:
end
def canonical(poly
end
Line 685 ⟶ 683:
def new_points(poly)
points = []
poly.each{|x,y| contiguous(x,y).each{|
(points - poly).uniq
end
def new_polys(polys)
pattern = Set.new
polys.
new_points(poly).each do |point|
next if pattern.include?(pl = translate2origin(poly + [point]))
polyomino << canonical(pl
end
end
end
Line 722 ⟶ 718:
n = ARGV[0] ? ARGV[0].to_i : 5
puts "\nAll free polyominoes of rank %d:" % n
rank(n).sort.each{|poly| puts text_representation(poly),""}</lang>
{{out}}
|