Skip to content

Commit

Permalink
refactor-day-05 resolves #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasile-Hij committed May 26, 2023
1 parent f46e85e commit 8029e50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def helper_base(source: str, year: str, functions: callable = str, display: int

display_items('Raw input', day_text.splitlines(), display)
data = make_tuple(parser_function, segmentation)
if parser_function != str or parser_function != lines:
display_items('Parsed file', data, display)
#if parser_function != str or parser_function != lines:
display_items('Parsed file', data, display)

return data

Expand Down Expand Up @@ -125,3 +125,8 @@ def each_first_item(data: str):
def each_item(data: str):
return [item for item in data]


def strings_per_line(data):
_data = paragraph(data)
return [[item for item in line.split('\n') if item] for line in _data if line][0]

2 changes: 1 addition & 1 deletion py/22/day05.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def start_day():
name = '--- Day 5: Supply Stacks ---'
parser_function = 'each_item'
parser_function = 'strings_per_line'
display_lines_or_paragraph = 'paragraph'
return name, parser_function, display_lines_or_paragraph

Expand Down

0 comments on commit 8029e50

Please sign in to comment.