Advertisement
MonsterScripter

CodinGame_2023_08_27__15_41_05__mountains.fs

Aug 27th, 2023
2,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.87 KB | None | 0 0
  1. (* The while loop represents the game. *)
  2. (* Each iteration represents a turn of the game *)
  3. (* where you are given inputs (the heights of the mountains) *)
  4. (* and where you have to print an output (the index of the mountain to fire on) *)
  5. (* The inputs you are given are automatically updated according to your last actions. *)
  6. open System
  7.  
  8. let maxM = 8
  9. let mutable index_highest_mountain = 0
  10. let mutable max_highest_mounter = 0
  11.  
  12. (* game loop *)
  13. while true do
  14.     for i in 0 .. maxM - 1 do
  15.         let mountainH = int(Console.In.ReadLine()) (* represents the height of one mountain. *)
  16.         if max_highest_mounter < mountainH then
  17.             max_highest_mounter <- mountainH
  18.             index_highest_mountain <- i
  19.     printfn "%d" index_highest_mountain // L'indice de la montagne à viser.
  20.     max_highest_mounter <- 0
  21.     index_highest_mountain <- 0
  22.     ()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement