make AOCDay.getInput() return type casted input
This commit is contained in:
parent
a2aa81388c
commit
353ff51411
18
tools/aoc.py
18
tools/aoc.py
@ -168,17 +168,17 @@ class AOCDay:
|
||||
|
||||
answer_cache.save()
|
||||
|
||||
def getInput(self) -> Union[str, List]:
|
||||
def getInput(self, return_type: Type = None) -> Any:
|
||||
if len(self.input) == 1:
|
||||
return self.input[0]
|
||||
if return_type:
|
||||
return return_type(self.input[0])
|
||||
else:
|
||||
return self.input[0]
|
||||
else:
|
||||
return self.input.copy()
|
||||
|
||||
def getInputListAsType(self, return_type: Type) -> List:
|
||||
"""
|
||||
get input as list casted to return_type, each line representing one list entry
|
||||
"""
|
||||
return [return_type(i) for i in self.input]
|
||||
if return_type:
|
||||
return [return_type(i) for i in self.input]
|
||||
else:
|
||||
return self.input.copy()
|
||||
|
||||
def getMultiLineInputAsArray(self, return_type: Type = None, join_char: str = None) -> List:
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user