Skip to content

Instantly share code, notes, and snippets.

@thoroc
Created February 16, 2015 23:38
Show Gist options
  • Save thoroc/eec5be3e96d0b40bb254 to your computer and use it in GitHub Desktop.
Save thoroc/eec5be3e96d0b40bb254 to your computer and use it in GitHub Desktop.
codingame - the Descent
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