Advertisement
Loss1k

PHP Code

Jul 5th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2. /**
  3.  * CodinGame planet is being attacked by slimy insectoid aliens.
  4.  * <---
  5.  * Hint:To protect the planet, you can implement the pseudo-code provided in the statement, below the player.
  6.  **/
  7.  
  8.  
  9. // game loop
  10. while (TRUE)
  11. {
  12.     fscanf(STDIN, "%s",
  13.         $enemy1;
  14.     );
  15.     fscanf(STDIN, "%d",
  16.         $dist1;
  17.     );
  18.     fscanf(STDIN, "%s",
  19.         $enemy2;
  20.     );
  21.     fscanf(STDIN, "%d",
  22.         $dist2;
  23.     );
  24.    
  25. if ($dist1 < $dist2) {
  26.     print $enemy1;
  27. } else {
  28.     print $enemy2;
  29. }
  30.  
  31.     // Write an action using echo(). DON'T FORGET THE TRAILING \n
  32.     // To debug (equivalent to var_dump): error_log(var_export($var, true));
  33.  
  34.     echo("enemy\n"); // replace "enemy" with a correct ship name to shoot
  35. }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement