Skip to content

Instantly share code, notes, and snippets.

@lancew
Last active October 12, 2019 17:03
Show Gist options
  • Save lancew/1b750e81b83963977858ea15dc54b765 to your computer and use it in GitHub Desktop.
Save lancew/1b750e81b83963977858ea15dc54b765 to your computer and use it in GitHub Desktop.
Per5->Perl6... next step Raku
sub MAIN($n=100) {
my $percentleft = 100;
my $biggestpercent = 0;
my $guestwithbiggestpercent = 0;
for (1..$n) -> $i
{
my $pi = $i * $percentleft / 100; # amount for guest i
print "guest $i has $pi percent of the pie\n";
if ( $pi > $biggestpercent )
{
$biggestpercent = $pi;
$guestwithbiggestpercent = $i;
}
$percentleft -= $pi; # percentage left over
}
print "\nguest $guestwithbiggestpercent has biggest percentage of pie: " ~
"$biggestpercent\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment