Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std;
- /**
- * The while loop represents the game.
- * Each iteration represents a turn of the game
- * where you are given inputs (the heights of the mountains)
- * and where you have to print an output (the index of the mountain to fire on)
- * The inputs you are given are automatically updated according to your last actions.
- **/
- void main()
- {
- const int maxM = 8;
- int index_highest_mountain = 0;
- int max_highest_mounter = 0;
- // game loop
- while (1) {
- for (int i = 0; i < maxM; i++) {
- int mountainH = readln.chomp.to!int; // represents the height of one mountain.
- if (max_highest_mounter < mountainH) {
- max_highest_mounter = mountainH;
- index_highest_mountain = i;
- }
- }
- writeln(index_highest_mountain); // The index of the mountain to fire on.
- max_highest_mounter = 0;
- index_highest_mountain = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement