Advertisement
MonsterScripter

CodinGame_2023_08_27__15_31_39__mountains.sh

Aug 27th, 2023
1,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 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.  
  7. index_highest_mountain="0"
  8. max_highest_mounter="0"
  9. # game loop
  10. while true; do
  11.     for ((i=0; i<8; i++)); do
  12.         # mountainH: représente la hauteur d'une montagne.
  13.         read -r mountainH
  14.         if [[ "$max_highest_mounter" -lt "$mountainH" ]]; then
  15.             max_highest_mounter="$mountainH"
  16.             index_highest_mountain="$i"
  17.         fi
  18.     done
  19.     printf "%s\n" "$index_highest_mountain"
  20.     max_highest_mounter="0"
  21.     index_highest_mountain="0"
  22. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement