Skip to content

Instantly share code, notes, and snippets.

@hughsimpson
hughsimpson / troll.p6
Created December 24, 2015 01:16
countdown numbers game (needs an input csv of the form `a,b,c,d` for the generating numbers
sub getPartial(Str $a, Rat $x, Rat $y) {
my @comps = $x + $y, $x *$y, $x - $y, $x ** $y, $x / $y;
my @agg = "($a " «~« <+ * - ** /> »~» " $y)";
return @comps Z=> @agg
}
sub comp(@ps, %a) {
if @ps.elems == 0 {return %a}
my ($h, @t) = @ps;
if %a.elems == 0 {return comp(@t, $h => $h.Str)}