def test_do_all(): operations = [ 'swap position 4 with position 0', 'swap letter d with letter b', 'reverse positions 0 through 4', 'rotate left 1 step', 'move position 1 to position 4', 'move position 3 to position 0', 'rotate based on pposition of letter b', 'rotate based on position of letter d' ] assert Scrambler.do_all(operations, 'abcde') == 'decab' assert Scrambler.do_all(operations, 'decab', reverse=True) == 'abcde'
from day21.scrambler import Scrambler with open('input.txt') as f: operations = [line[:-1] for line in f.readlines() if len(line) > 0] print(Scrambler.do_all(operations, 'abcdefgh')) print(Scrambler.do_all(operations, 'fbgdceah', reverse=True))