plus a couple of one-liners

dpuu on 2008-12-24T18:38:35

event 6 asks us to generate the prime numbers from 1 to 200:

% ./perl6 -e 'my @primes; for 2 .. 200 -> $n { @primes.push($n) unless $n % any(@primes)==0 }; .say for @primes'

and event 7 asks for a random scheduling of a round-robin tournament with 6 teams:

% ./perl6 -e 'my @teams = "A" .. "F"; my @games = (@teams X~X @teams).grep: { [le] $_.split("") } ; .say for @games.pick( @games.elems )'

This latter would be even easier if we had a "combinations" operator