-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetro.py
33 lines (27 loc) · 787 Bytes
/
metro.py
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
from re import S
with open('metro.txt') as file:
lines = file.readlines()
lines = [line.rstrip() for line in lines]
station = [i.split(' ') for i in lines]
n = int(input())
l = []
o = []
for i in range(n):
mabda , maghsad = input().split(' ')
o.append((mabda, maghsad))
for j in o:
(mabda, maghsad) = j
for i in range(7):
if mabda in station[i]:
index_mabda = i
if maghsad in station[i]:
index_maghsad = i
if index_mabda == index_maghsad:
t = station[index_mabda].index(maghsad)
t2 = station[index_mabda].index(mabda)
fasele = abs(t-t2)
l.append(29 + fasele*2)
else:
avaz = set(station[index_mabda]).intersection(set(station[index_maghsad]))
for i in l:
print(i)