Intersecting number wheels: Difference between revisions
m
→Python: Functional composition
Line 754:
def clockWorkTick(wheelMap):
'''The new state of the wheels, tupled with the
digit found
def click(wheels, name):
wheel = wheels.get(name, ['?'])
v = wheel[0]
return (Tuple if isDigit(v) or '?' == v else curry(click))(
insertDict(name)(
leftRotate(wheel)
)(wheels)
)(v)
return click(wheelMap, 'A')
Line 779 ⟶ 780:
'''First twenty values from each set of test wheels.'''
print('New state of wheel sets, after 20 clicks of each:\n')▼
wheelMaps = [dict(kvs) for kvs in [
[('A', "123")],
Line 786:
[('A', "1BC"), ('B', "34"), ('C', "5B")]
]]
▲ print('New state of wheel sets, after 20 clicks of each:\n')
for wheels, series in [
mapAccumL(compose(const)(clockWorkTick))(
|