Jump to content

Ramsey's theorem: Difference between revisions

m
→‎{{header|Perl 6}}: .Array work-around now obsolete, factored out array-size constant
(Added Perl example)
m (→‎{{header|Perl 6}}: .Array work-around now obsolete, factored out array-size constant)
Line 946:
 
=={{header|Perl 6}}==
{{Works with|rakudo|20172018.0108}}
<lang perl6>my @a$n = [ 0 xx 17 ] xx 17;
my @a[$_;$_] = '-'[ for0 ^17xx $n ] xx $n;
@a[$_;$_] = '-' for ^$n;
 
for flat ^17$n X 1,2,4,8 -> $i, $k {
my $j = ($i + $k) % 17$n;
@a[$i;$j] = @a[$j;$i] = 1;
}
.say for @a;
 
for combinations(17$n,4).Array -> $quartet {
my $links = [+] $quartet.combinations(2).map: -> $i,$j { @a[$i;$j] }
die "Bogus!" unless 0 < $links < 6;
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.