-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprobe.py
More file actions
46 lines (37 loc) · 1.44 KB
/
probe.py
File metadata and controls
46 lines (37 loc) · 1.44 KB
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
file = open("probein.txt", "r")
write_file = open("probeout.txt", "w")
row, column, water_row, water_column, lava_row, lava_column = file.readline().split()
blockade = False
if int(lava_row) + int(lava_column) == int(water_row) + int(water_column):
blockade_sum = int(lava_row) + int(lava_column)
blockade = True
if lava_row < water_row:
below = 'water'
else:
below = 'lava'
questions = int(file.readline())
for i in range(0, questions):
question_row, question_column = file.readline().split()
lava_value = abs(int(question_row)-int(lava_row)) + abs(int(question_column)-int(lava_column))
water_value = abs(int(question_row)-int(water_row)) + abs(int(question_column)-int(water_column))
if lava_value < water_value:
write_file.write("LAVA\n")
elif lava_value > water_value:
write_file.write("WATER\n")
else:
if blockade:
question_sum = int(question_row)+int(question_column)
if below == 'water':
if question_sum > blockade_sum:
write_file.write("WATER\n")
else:
write_file.write("LAVA\n")
else:
if question_sum > blockade_sum:
write_file.write("LAVA\n")
else:
write_file.write("WATER\n")
else:
write_file.write("MOUNTAINS\n")
file.close()
write_file.close()