Skip to content

Instantly share code, notes, and snippets.

@vampy
Created March 14, 2016 11:27
Show Gist options
  • Save vampy/ab033db1237064f42025 to your computer and use it in GitHub Desktop.
Save vampy/ab033db1237064f42025 to your computer and use it in GitHub Desktop.
(* 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