mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Slightly more consise reading logic.
This commit is contained in:
@@ -3,6 +3,7 @@ import fileinput
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
def read_action(it):
|
def read_action(it):
|
||||||
|
next(it)
|
||||||
to_write = 1 if "1" in next(it) else 0
|
to_write = 1 if "1" in next(it) else 0
|
||||||
offset = 1 if "right" in next(it) else -1
|
offset = 1 if "right" in next(it) else -1
|
||||||
goto = next(it).strip()[-2]
|
goto = next(it).strip()[-2]
|
||||||
@@ -23,14 +24,7 @@ def read_input():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
state = line[-2]
|
state = line[-2]
|
||||||
next(in_iter)
|
states[state] = (read_action(in_iter), read_action(in_iter))
|
||||||
|
|
||||||
if_0 = read_action(in_iter)
|
|
||||||
next(in_iter)
|
|
||||||
|
|
||||||
if_1 = read_action(in_iter)
|
|
||||||
|
|
||||||
states[state] = (if_0, if_1)
|
|
||||||
|
|
||||||
return initial, runs, states
|
return initial, runs, states
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user