note
Ven'Tatsu
Your solution is calling <code>max(@xs)</code> twice each step. This leads to O(2^n) growth for what should be an O(n) problem. Modifying it slightly to call max once and save the value in a temp variable should save considerable time on long lists.
<code>
sub max {
my ($x, @xs) = @_;
@xs ? do { my $m = maxdo(@xs); ($x, $m)[$x < $m] } : $x;
}
</code>
406883
407163