Ramsey's theorem: Difference between revisions

completed ruby version
(→‎{{header|Perl 6}}: follow new task description)
(completed ruby version)
Line 637:
 
=={{header|Ruby}}==
{{incorrect|Ruby|The task has been changed to also require demonstrating that the graph is a solution.}}
<lang ruby>a = Array.new(17){['0'] * 17}
17.times{|i| a[i][i] = '-'}
Line 646 ⟶ 645:
end
end
a.each {|row| puts row.join(' ')}</lang>
# check taken from Perl6 version
(0...17).to_a.combination(4) do |quartet|
links = quartet.combination(2).map{|i,j| a[i][j].to_i}.reduce(:+)
abort "Bogus" unless 0 < links && links < 6
end
puts "Ok"
</lang>
{{out}}
<pre>
Line 666 ⟶ 672:
1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 - 1
1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 -
Ok
</pre>
 
10

edits