aoc2020/aoclib/inputs.py
Stefan Harmuth 10a569faed day1
2020-12-01 08:19:38 +01:00

19 lines
537 B
Python

import os
BASE_PATH = os.path.dirname(os.path.dirname(__file__))
INPUTS_PATH = os.path.join(BASE_PATH, 'inputs')
def getInputLineAsArray(day, return_type=None):
"""
get input for day x as array, each line representing one array entry
when type is given, each entry will be converted to the specified type
"""
with open(os.path.join(INPUTS_PATH, str(day)), "r") as f:
input_array = f.readlines()
if return_type:
return [return_type(i) for i in input_array]
else:
return input_array