RosettaCodeData/Task/Topswops/Ruby/topswops-1.rb

17 lines
220 B
Ruby
Raw Permalink Normal View History

2013-10-27 22:24:23 +00:00
def f1(a)
i = 0
2015-02-20 00:35:01 -05:00
while (a0 = a[0]) > 1
2013-10-27 22:24:23 +00:00
a[0...a0] = a[0...a0].reverse
i += 1
end
i
end
def fannkuch(n)
[*1..n].permutation.map{|a| f1(a)}.max
end
for n in 1..10
puts "%2d : %d" % [n, fannkuch(n)]
end