You are viewing a single comment's thread. Return to all comments →
Perl:
sub pickingNumbers { my $aa = shift; my $max = 0; my @a = sort {$a <=> $b} @$aa; for (my $i = 0; $i < scalar(@a); $i++) { my $cnt = 0; for (my $j = $i+1; $j < scalar(@a); $j++) { if (abs($a[$i] - $a[$j]) <= 1) { $cnt++; } } $max = $cnt if ($cnt > $max); } return ++$max; }
Seems like cookies are disabled on this browser, please enable them to open this website
Picking Numbers
You are viewing a single comment's thread. Return to all comments →
Perl: