forked from RiviereGregory/CodinGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ragnarök - Le pouvoir de Thor.txt
70 lines (59 loc) · 1.76 KB
/
Ragnarök - Le pouvoir de Thor.txt
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.*;
import java.io.*;
import java.math.*;
class Player {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int eclairX = in.nextInt();
int eclairY = in.nextInt();
int thorX = in.nextInt();
int thorY = in.nextInt();
//System.out.println("E ("+eclairX+","+eclairY+")" +" T ("+thorX+","+thorY+")");
while (true) {
int n = in.nextInt();
String choix = direction(eclairX, eclairY, thorX, thorY);
switch(choix){
case "N": thorY -= 1;
break;
case "S": thorY += 1;
break;
case "NE": thorY -= 1;
thorX +=1 ;
break;
case "SE": thorY += 1;
thorX +=1 ;
break;
case "NW": thorY -= 1;
thorX -=1 ;
break;
case "SW": thorY += 1;
thorX -=1 ;
break;
case "E": thorX +=1 ;
break;
case "W": thorX -=1 ;
break;
}
// Write action to standard output
System.out.println(choix );
}
}
public static String direction(int eclairX, int eclairY,int thorX,int thorY){
String dir = "";
int X;
int Y;
X = eclairX - thorX;
Y = eclairY - thorY;
if(Y>0){
dir +="S";
}else if(Y<0){
dir +="N";
}
if(X>0){
dir +="E";
}else if(X<0){
dir +="W";
}
return dir;
}
}