Jump to content

Ramsey's theorem: Difference between revisions

→‎{{header|Perl 6}}: follow new task description
(→‎{{header|REXX}}: verified Ramsey's condition, removed STYLE from the PRE html tag, added verification, added comments, changed indentations.)
(→‎{{header|Perl 6}}: follow new task description)
Line 464:
 
=={{header|Perl 6}}==
<lang Perl 6perl6>my @a = [ 0 xx 17 ] xx 17;
{{incorrect|Perl 6|The task has been changed to also require demonstrating that the graph is a solution.}}
@a[$_][;$_] = 2'-' for ^17;
{{trans|C}}
<lang Perl 6>my @a = [ 0 xx 17 ] xx 17;
@a[$_][$_] = 2 for ^17;
 
loopfor (my^17 $k =X 1;,2,4,8 -> $k <= 8;i, $k +<= 1) {
formy ^17$j ->= ($i {+ $k) % 17;
my @a[$i;$j] = (@a[$j;$i] + $k) %= 171;
@a[$i][$j] = @a[$j][$i] = 1;
}
}
.say for @a;
 
for combinations(17,4) -> $quartet {
say <0 1 ->[@a[$_][]] for ^17;</lang>
my $links = [+] $quartet.combinations(2).map: -> [$i;$j] { @a[$i;$j] }
die "Bogus!" unless 0 < $links < 6;
}
say "OK";</lang>
{{out}}
<pre>- 1 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 1 - 1 1 0 1 0 0 0 1 1 0 0 0 1 0
0 1 1 - 1 1 0 1 0 0 0 1 1 0 0 0 1
1 0 1 1 - 1 1 0 1 0 0 0 1 1 0 0 0
0 1 0 1 1 - 1 1 0 1 0 0 0 1 1 0 0
0 0 1 0 1 1 - 1 1 0 1 0 0 0 1 1 0
0 0 0 1 0 1 1 - 1 1 0 1 0 0 0 1 1
1 0 0 0 1 0 1 1 - 1 1 0 1 0 0 0 1
1 1 0 0 0 1 0 1 1 - 1 1 0 1 0 0 0
0 1 1 0 0 0 1 0 1 1 - 1 1 0 1 0 0
0 0 1 1 0 0 0 1 0 1 1 - 1 1 0 1 0
0 0 0 1 1 0 0 0 1 0 1 1 - 1 1 0 1
1 0 0 0 1 1 0 0 0 1 0 1 1 - 1 1 0
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 - 1
1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 -
OK</pre>
 
=={{header|Python}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.