-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathts.ts
36 lines (28 loc) · 960 Bytes
/
ts.ts
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
import readlineSync from 'readline-sync'
const readline = () => readlineSync.prompt({ encoding: 'utf-8', prompt: '' })
// ------ Everything above this line will get cut when running copy script
let inputs: string[] = readline().split(' ')
const lightX: number = parseInt(inputs[0]) // the X position of the light of power
const lightY: number = parseInt(inputs[1]) // the Y position of the light of power
let tx: number = parseInt(inputs[2]) // Thor's starting X position
let ty: number = parseInt(inputs[3]) // Thor's starting Y position
// game loop
while (true) {
const remainingTurns: number = parseInt(readline()) // The remaining amount of turns Thor can move. Do not remove this line.
let move = ''
if (ty > lightY) {
move += 'N'
ty += -1
} else if (ty < lightY) {
move += 'S'
ty += 1
}
if (tx > lightX) {
move += 'W'
tx += -1
} else if (tx < lightX) {
move += 'E'
tx += 1
}
console.log(move)
}