my @d1s = sort { $b <=> $a } $d61 ; my @d2s = sort { $b <=> $a } $d62 ; my @d3s = sort { $b <=> $a } $d63 ; my @d4s = sort { $b <=> $a } $d64 ;
What is the point of this? Sorting lone scalars, and putting them in one element arrays? What's the point of chomping $roll? I would write that as:
#!/usr/bin/perl use strict; use warnings; my $tosses = 5; my $dice = 4; foreach (1 .. $tosses) { my @rolls = sort {$b <=> $a} map {2 + int rand 5} 1 .. $dice; pop @rolls; my $sum = 0; $sum += $_ for @rolls; print "\n@rolls: $sum\n\n"; } __END__
And that includes finding the top-3 rolls and summing them.
Abigail
In reply to Re: Remove lowest number
by Abigail-II
in thread Remove lowest number
by ellem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |