Created
March 14, 2016 11:27
-
-
Save vampy/ab033db1237064f42025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Auto-generated code below aims at helping you parse *) | |
(* the standard input according to the problem statement. *) | |
(* --- *) | |
(* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders. *) | |
(* lightx: the X position of the light of power *) | |
(* lighty: the Y position of the light of power *) | |
(* initialtx: Thor's starting X position *) | |
(* initialty: Thor's starting Y position *) | |
let line = input_line stdin in | |
let rec solve lightX lightY thorX thorY = | |
begin | |
prerr_endline (string_of_int thorX); prerr_endline (string_of_int thorY); | |
print_endline ((if thorY > lightY then "N" else if thorY < lightY then "S" else "") ^ (if thorX > lightX then "W" else if thorX < lightX then "E" else "")); | |
let remainingturns = int_of_string (input_line stdin) in | |
solve lightX lightY | |
(if thorX > lightX then thorX - 1 else if thorX < lightX then thorX + 1 else thorX) | |
(if thorY > lightY then thorY - 1 else if thorY < lightY then thorY + 1 else thorY) | |
end in | |
(* game loop *) | |
Scanf.sscanf line "%d %d %d %d" solve;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment