33 lines
951 B
Python
33 lines
951 B
Python
|
#!/usr/bin/env python3
|
||
|
import re
|
||
|
|
||
|
INPUT_FILE = 'input'
|
||
|
pattern = '^move (\d+) from (\d+) to (\d+)$'
|
||
|
|
||
|
stacks = [
|
||
|
['G','T','R','W'],
|
||
|
['G', 'C', 'H', 'P', 'M', 'S', 'V', 'W'],
|
||
|
['C', 'L', 'T', 'S', 'G', 'M'],
|
||
|
['J', 'H', 'D', 'M', 'W', 'R', 'F'],
|
||
|
['P', 'Q', 'L','H','S','W','F','J'],
|
||
|
['P', 'J', 'D','N','F','M','S'],
|
||
|
['Z', 'B', 'D','F','G','C','S','J'],
|
||
|
['R', 'T', 'B'],
|
||
|
['H', 'N', 'W', 'L', 'C'],
|
||
|
]
|
||
|
|
||
|
def main():
|
||
|
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
|
||
|
for line in content:
|
||
|
print(stacks)
|
||
|
amount, move_from, move_to = re.match(pattern, line).groups()
|
||
|
amount, move_from, move_to = int(amount), int(move_from)-1, int(move_to)-1
|
||
|
print('{}: {} -> {}'.format(amount, move_from, move_to))
|
||
|
for _ in range(amount):
|
||
|
stacks[move_to].append(stacks[move_from].pop())
|
||
|
for s in stacks:
|
||
|
print(s.pop())
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|