Beta

The Broken Typewriter

Description:

You are a downtown hipster who bought an ancient typewriter at the flea-market. After proudly taking it home and showing it to your partner you realized it has exactly 1 functioning key. Nothing else works on it. No new line, no carriage return, no space, no tab, nothing, but that bloody 'P' key.

Your partner starts arguing with you about the 'great' purchase, but you insist keeping it, so you immediately jump on the problem just to prove her/him wrong.

So here is the problem: you have to find a way to encode a message using only one kind of character in the encoded message. That means you can not use any kind of separator or other character, but 'P'. No spaces, no tabs, no new line characters, but the P key.

Let's say you want to send the message 'I told you so!'. After encoding it will look something like "PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP". Length may vary depending on your implementation. However, since the message can only contain one kind of character it's enough to return the length of the encoded message.

For practical reasons the input messages used to test your encoder will be limited to 100 characters in length and the alphabet used in the test messages will consist of the following 67 characters:

.-, !abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789

This alphabet is available via the constant Alphabet.ALLOWED_CHARACTERS.

Note: there can be multiple good solutions with different encoding algorithms. The system will perform different tests to ensure you did not try to trick it. (The encode() and decode() methods should not share any state.)

Now go and prove your damn point!

Puzzles

Similar Kata:

Stats:

CreatedAug 27, 2016
PublishedAug 27, 2016
Warriors Trained101
Total Skips40
Total Code Submissions85
Total Times Completed17
Java Completions17
Total Stars4
% of votes with a positive feedback rating86% of 11
Total "Very Satisfied" Votes9
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • user3914838 Avatar
Ad