Skip to main content
6 of 12
deleted 365 characters in body
PhiNotPi
  • 29.1k
  • 10
  • 85
  • 157

Perl

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

Edit: It has been changed back to the original to improve performance..

$_=<>;
INPUT:{
tr/ /,/;
@in = eval;
@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=5;
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