-
Notifications
You must be signed in to change notification settings - Fork 0
/
3.py
32 lines (27 loc) · 1.06 KB
/
3.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
import csv
with open('scientist_sorted.txt', 'r', encoding="utf8") as csvfile:
reader = csv.DictReader(csvfile, delimiter='#')
reader = [row for row in reader]
command = input()
while command != 'эксперимент':
command = command.split('.')
command.reverse()
command = '-'.join(command)
print(command)
left = 0
right = len(reader) - 1
mid = left + (right - left) // 2
while left <= right:
print(left, right, reader[mid])
if reader[mid]['date'] == command:
print(f'Ученый {reader[mid]["ScientistName"]} создал препарат: {reader[mid]["preparation"]} - {reader[mid]["date"]}')
break
elif reader[mid]['date'] < command:
left = mid + 1
mid = left + (right - left) // 2
else:
right = mid - 1
mid = left + (right - left) // 2
else:
print('В этот день ученые отдыхали')
command = input()