You have been given two anagrams as a string, separated by dash. You need to rearrange the letters to turn the first word into the second. The tools you have for this mission are two stacks and a one-letter buffer. The first stack is the beginning of a word; the second stack is where you will put the anagram. The word is placed in the stack, letter by letter. The first letter of the anagram is placed in the bottom stack and the last letter in the middle stack, until it is needed as the end of the anagram. You need to return the shortest sequence of actions to move and turn the word in the first stack into the anagram in the second. The first stack is labeled 1, the second is labeled 2, and the buffer as 0. The action is written as a string of two numbers which signify the original location of the letter and the new location. For example: 12 means that from the first stack, we take the last letter and place it at the end of the second stack. For the result, you need to get a string that lists the steps, separated by commas.
Input: Two words separated by dash as a string.
Output: A sequence of actions as a string.
checkio("rice-cire") == "10,12,12,12,02" checkio("tort-trot") == "12,12,12,12" checkio("hello-holle") == "12,12,12,12,10,21,21,21,21,02,12,12,12,12" checkio("anagram-mragana") == "12,10,12,02,12,12,12,12" checkio("mirror-mirorr") == "12,12,10,12,12,02,10,21,21,21,21,21,02,12,12,12,10,21,21,21,02,12,12,12,12" #It can be solved more the one way.
How it is used: Here you can play with stacks and how they work in games. We see stacks in everyday life, they’re in the books in our library, and the blank sheets of paper in our printer tray.
1 ≤ |word| < 10
Words contains only ASCII letters in lowercase.
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium