You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
556 B
Python
22 lines
556 B
Python
from typing import List, Tuple
|
|
|
|
|
|
class RucksackLoader:
|
|
|
|
def __init__(self, path: str):
|
|
self.path = path
|
|
|
|
def parse_file(self) -> List[Tuple[List[str], List[str]]]:
|
|
rucksacks = []
|
|
with open(self.path, "r") as file:
|
|
for line in file:
|
|
line = line.strip()
|
|
if len(line) == 0:
|
|
continue
|
|
comp_1 = list(line[:len(line)//2])
|
|
comp_2 = list(line[len(line)//2:])
|
|
rucksacks.append((comp_1, comp_2))
|
|
|
|
return rucksacks
|
|
|