Skip to main content
1 of 12
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157

Perl

I tried a little harder this time. It's a really simple strategy, but I've set up the framework for expansion.

$_=<>;
INPUT:{

tr/ /,/;
@in = eval;
$"="\n";
@rbids = "";
for(1..$#in){
 $rbids[$in[$_]]++
}

LOWBID: for($pnt=1;$pnt<$#in+1;$pnt++){
 if($rbids[$pnt]==0){$lows[$pnt]++;last LOWBID}
}

$_=<>;
if($_ ne"\n"){redo INPUT}
}

$max=0;
$maxloc=3;
for(1..100){
 if($lows[$_]>$max){$maxloc=$_;$max=$lows[$_]}
}
print$maxloc

This program takes input one line at a time, followed by two newlines:

perl PhiNotPi2.plx
1 2 3 3 2
2 1 3 1 3
2 1 1 1 3
[empty line]
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157