-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
31 lines (26 loc) · 947 Bytes
/
functions.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
# Functions used in main
# Finds the From, To and Total entries based on the string
def get_num(string: str) -> tuple:
if string[:5] == 'Items':
return [int(i) for i in string.split('\n')[-1].split() if i.isnumeric()]
return [1] + ([int(string[:string.find(' ')])] * 2)
# Puts the entries in a table format with each entry as a row
def format_table(string: str) -> list:
op = []
for i, j in enumerate(string.split('\n')):
if not i%4:
op.append([])
op[-1].append(j)
return op
class AC:
def __init__(self, num):
self.num = num
self.state = 0
# 0 for unknown; 1 for passed; 2 for failed
def update(self, n):
if n > self.state:
self.state = n
if n == 1:
print('AC' + str(self.num) + ' passed so far\n')
else:
print('AC' + str(self.num) + ' failed\n')