arrow_forward همه ارسال‌ها

جزئیات ارسال کد#571

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Milad Nasiri (۲ سال پیش)
descriptionsolution.py ۲۶ خط • ۵۴۴ بایت
1def new_position(n, p, x, y, direction):
2 directions = {
3 'N': (-p, 0),
4 'S': (p, 0),
5 'W': (0, -p),
6 'E': (0, p),
7 'NE': (-p, p),
8 'NW': (-p, -p),
9 'SE': (p, p),
10 'SW': (p, -p)
11 }
12
13 dx, dy = directions[direction]
14
15 new_x = (x + dx) % n
16 new_y = (y + dy) % n
17
18 return new_x, new_y
19
20n, p = map(int, input().split())
21x, y = map(int, input().split())
22direction = input().strip()
23
24final_x, final_y = new_position(n, p, x, y, direction)
25
26print(final_x, final_y)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8