Submit | All submissions | Best solutions | Back to list |
FMORSE1 - Fractionated morse cipher |
Fractionated morse is a classic cipher:
The plaintext letters are in [A-Z] only with no punctuation.
Each letter of the plaintext is first enciphered using Morse code with "|" after every letter.
If the length of the resulting string is not multiple of three, you have to truncate the remaining symbols.
Standard morse table:
A=.- B=-... C=-.-. D=-.. E=. F=..-. G=--. H=.... I=.. J=.--- K=-.- L=.-.. M=--
N=-. O=--- P=.--. Q=--.- R=.-. S=... T=- U=..- V=...- W=.-- X=-..- Y=-.-- Z=--..
This series of [A-Z] and | letters is taken off in units of three, each trigraph set and
cipher letters assigned to each group using a keyword alphabet to obtain the ciphertext.
Fractionated morse table with keyword alphabet (key=ROUNDTABLE):
R=... O=..- U=..| N=.-. D=.-- T=.-| A=.|. B=.|- L=.|| E=-.. C=-.- F=-.| G=--.
H=--- I=--| J=-|. K=-|- M=-|| P=|.. Q=|.- S=|.| V=|-. W=|-- X=|-| Y=||. Z=||-
Your task is simple. You only will have to code the input message using the keyword.
You have to reduce the keyword by the alphabet:
(JIMMORRISON => JIMORSN reduced key)
Score is the source length.
Input
N testcases (no more than 100)
Each line of the input contains the keyword and a plaintext.
The keylength max is 100 and the length of the plaintext is limited to 200.
The last testcase ends with EOF.
Output
Output consist of exactly N lines of cyphertexts with letters in [A-Z] with no spaces.
Example
Input:
JIMMORRISON RIDERSONTHESTORMINTOTHISHOUSEWEAREBORN Output: OQVNTNMGVXJNQAWKEHMELHKJQQNJWKSJURUSOUCAHOV
Added by: | legrand |
Date: | 2013-02-27 |
Time limit: | 1s-5s |
Source limit: | 2000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP C99 OCAML PYTHON PYTHON3 PY_NBC |
Resource: | own |
hide comments
2013-09-24 13:23:16 Aditya Pande
How do u get the Fractionated morse table for a particular key? =>there is a logic, it's part of the problem. Read the problem and the table carefully. Last edit: 2013-09-24 15:01:18 |
|
2013-06-11 20:33:09 Mostafa 36a2
Thanks For The Problem Enjoy It :) |
|
2013-02-27 18:29:52 Mitch Schwartz
Thanks for the reply. I figured it out: Original problem statement said '|' appears between letters, but now it says '|' appears after every letter, and the trailing '\n' was causing me to add an extra '|' without realising (which just happened to give the right answer with the modified statement). |
|
2013-02-27 18:29:52 legrand
@mitch: no. I have verified it at the moment and I don't see where it comes as the file format is a unix ASCII text file. perhaps it comes from the '\n' at the end of every line of the file. Last edit: 2013-02-27 16:58:35 |
|
2013-02-27 18:29:52 Mitch Schwartz
When I replace split(' ') with split() it goes from AC to WA. I think that means there is something wrong with the input, maybe some keyword contains a tab character or something? |
|
2013-02-27 18:29:52 legrand
The restriction on language is I want C/C++ or python shorten only, except Caml. but I think it can't be as short as C or python. |
|
2013-02-27 18:29:52 Mitch Schwartz
If the length of transformed text is not divisible by 3, do we right-pad it with some character, or truncate it? Edit: Oh, you already changed the problem statement to include this information. :) Any reason for the restricted language list? I happened to write it in Python anyway without noticing the restriction. Last edit: 2013-02-27 16:00:36 |