Anagrams By Stacks Anagrams By Stacks
Challenging
RU English ES

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.

anagrams_by_stacks anagrams_by_stacks

Input: Two words separated by dash as a string.

Output: A sequence of actions as a string.

Example:

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.

Precondition: 1 ≤ |word| < 10
Words contains only ASCII letters in lowercase.

Settings
Code:
CheckiO Extensions

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

checkio sync

(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
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

×
 
 
<< <
> >>
exec

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Share your own solution
Go to the next mission Back to the list of missions Back to the map