■
プログラミングの勉強を本気でWebゲーム化した「CodinGame」が時間泥棒確定! | APPGIGA!!(アプギガ)
http://plus.appgiga.jp/masatolan/2014/10/03/53923/
# game loop while (1) { my ($enemy_tmp, $dist_tmp) = ("HotDroid",100); chomp($count = <STDIN>); # The number of current enemy ships within range for(my $i=0; $i<$count; $i++) { # enemy: The name of this enemy # dist: The distance to your cannon of this enemy chomp($tokens=<STDIN>); ($enemy, $dist) = split(/ /,$tokens); if ($dist < $dist_tmp) { $enemy_tmp = $enemy; $dist_tmp = $dist; } } # Write an action using print # To debug: print STDERR "Debug messages...\n"; print "$enemy_tmp\n"; #print "HotDroid\n" # The name of the most threatening enemy (HotDroid is just one example) }