Created
February 16, 2015 23:38
-
-
Save thoroc/eec5be3e96d0b40bb254 to your computer and use it in GitHub Desktop.
codingame - the Descent
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
package main | |
import "fmt" | |
import "os" | |
func main() { | |
for { | |
var SX, SY int | |
fmt.Scan(&SX, &SY) | |
var MAX int | |
var pos int | |
for i := 0; i < 8; i++ { | |
// MH: represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right. | |
var MH int | |
fmt.Scan(&MH) | |
if MAX < MH { | |
MAX = MH | |
pos = i | |
} | |
} | |
fmt.Fprintln(os.Stderr, MAX) | |
if pos == SX { | |
fmt.Println("FIRE") // either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing). | |
} else { | |
fmt.Println("HOLD") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment