Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
taller in front
#perl 5.22.1 @H = (2, 6, 4, 5, 1, 3); # Heights @T = (1, 0, 2, 0, 1, 2); # Number of taller people in front my %hash=(); foreach my $person (0..$#H){ $hash{$person}={height=>$H[$person], tallerInFront=>$T[$person], peopleTaller =>[ map{$H[$_]>$H[$person]?$_:()}(0..$#H)], } } my @currentOrder=keys %hash; print score(@currentOrder); sub score{ my $score=0; foreach $person(1..$#currentOrder){ $score++ if $hash{$person}{tallerInFront} == scalar map{$hash{$_}{height}>$hash{$person}{height}?$_:()}(0..$person-1) } return $score }
run
|
edit
|
history
|
help
0
Array_with_shift_function
Quotes
Quote code
Hash-Nevil
Array_with_shift_function
Supriya
testing anonymous routine dereference with alternate syntax
Perl
Anchal 101712
array_value