Part 1
In this puzzle we should implement a scrambled for strings. A series of instructions are given to be followed. Each instruction, such as moving a char, reversing text or rotating text, operates on a string. We should find the resulting string for a given input string.
Since we just have to follow the operations, we iterate over the program. In each line, we use a regex to check for the operation and to parse the operators. For better usability, the operations are done on a list of characters instead of a string. After all operations are done, we output the resulting string.
Part 2
In part 2, we should reverse the process. We are asked to find, which input string produces a given output string.
There might be a simpler version, but we just iterated over all possible input strings (permutations of "abcdefgh"). For each input, we applied the scrambling and checked to resulting output against the target output until we had our solution.
No comments:
Post a Comment