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
Arrayop
PRAC 2 #5
Attractive Numbers
Hashes
each_hash_function
Challenge 41 Task 1
test hello world perl compiler n tex
Array_with_push_function
Hash
Cloeren 4 Coding