-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpowerOfThor.go
47 lines (39 loc) · 1.12 KB
/
powerOfThor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import "fmt"
//import "os"
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
func main() {
// LX: the X position of the light of power
// LY: the Y position of the light of power
// TX: Thor's starting X position
// TY: Thor's starting Y position
var LX, LY, TX, TY int
fmt.Scan(&LX, &LY, &TX, &TY)
destY := LY - TY
destX := LX - TX
for {
// E: The level of Thor's remaining energy, representing the number of moves he can still make.
var E int
fmt.Scan(&E)
moveStr := ""
// fmt.Fprintln(os.Stderr, "Debug messages...")
if destY > 0 {
moveStr += "S"
destY--
} else if destY < 0 {
moveStr += "N"
destY++
}
if destX > 0 {
moveStr += "E"
destX--
} else if destX < 0 {
moveStr += "W"
destX++
}
fmt.Println(moveStr) // A single line providing the move to be made: N NE E SE S SW W or NW
}
}