AMSCO Cipher
Let's look at the AMSCO cipher. This is a positional cipher with exchanges. You can easily encode or decode a message with a pen and paper, that is of course, if you know the key.
The key is represented as a number that consist of unique digits from 1 to N. N is a length of the key. To encode message we should write a message in a matrix with N columns. The matrix is written row by row. In this process, one or two characters are alternately recorded in a field. One or two characters alternate in rows and in columns too (like a chessboard). The first element is single letter field (this is the arrangement for this mission). The last field can have single characters if there are not enough. Columns are then numbered with digits from the key in order. For example: using the key 312, the first column will be 3, the second is 1 and the third is 2. Lastly, you will write all characters in the columns as they were numbered in the most recent step. All white spaces and punctuation symbols are excluded while letters are in lowercase.
Let's look at this with an example. The message "Lorem ipsum dolor sit amet". And the key is 4123. The cut message is "loremipsumdolorsitamet". In matrix form it will be:
4 1 2 3 l or e mi ps u md o l or s it am e t
Now write the columns as they are numbered in the ascending order - "oruore", "emdst", "mioit", "lpslam". The encoded message is "oruoreemdstmioitlpslam".
You are given an encoded message and the key. Your mission is to decode the message. Of course in the cut version.
Input: Two arguments. A message as a string (unicode) and a key as an integer.
Output: The decoded message as a string.
Example:
decode_amsco("oruoreemdstmioitlpslam", 4123) == "loremipsumdolorsitamet"
How it is used: For any cipher, it is important to realize both parts - encoding and decoding. This way, even if you know only one part of the cipher, you can finalize an implementation.
Precondition:
4 ≤ len(str(key))
int(len(str(key)) * 1.5) ≤ len(message)
re.match("\w+$", message)
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.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.