-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy paththe-fall1.js
41 lines (40 loc) · 856 Bytes
/
the-fall1.js
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
function printNextRoom(roomType, x, y, entrance) {
switch (roomType) {
case 2:
case 6:
entrance === "LEFT" ? x++ : x--;
break;
case 4:
entrance === "TOP" ? x-- : y++;
break;
case 5:
entrance === "TOP" ? x++ : y++;
break;
case 10:
x--;
break;
case 11:
x++;
break;
default:
y++;
}
console.log(`${x} ${y}`);
}
let rooms = [];
let inputs = readline().split(' ');
const nbColumns = Number(inputs[0]);
const nbRows = Number(inputs[1]);
for (let i = 0; i < nbRows; i++) {
let line = readline().split(' ').map(Number);
rooms.push(line);
}
readline();
// game loop
while (true) {
const inputs = readline().split(' ');
const x = Number(inputs[0]);
const y = Number(inputs[1]);
const entrance = inputs[2];
printNextRoom(rooms[y][x], x, y, entrance);
}