When thanking someone, you don't want to just send them an e-mail saying "Thanks!", you want to have something FLASHY:
Input: THANKS!!
Output:
TTT H H AAA N N K K SSS !!! !!!
T H H A A NNN K K S !!! !!!
T HHH AAA NNN KK SSS !!! !!!
T H H A A N N K K S
T H H A A N N K K SSS !!! !!!
Write a program to generate a banner. You only have to generate upper-case A-Z along with spaces and exclamation points (what is a banner without an exclamation point?). All characters are made up of a 3x5 grid of the same character (so the S is a 3x5 grid made of S). All output should be on one row (so no newlines). Here are all the letters you need:
Input: ABCDEFGHIJKL
Output:
AAA BBB CCC DD EEE FFF GGG H H III JJJ K K L
A A B B C D D E F G H H I J K K L
AAA BBB C D D EE FF G G HHH I J KK L
A A B B C D D E F G G H H I J J K K L
A A BBB CCC DD EEE F GGG H H III JJJ K K LLL
Input: MNOPQRSTUVWX
Output:
M M N N OOO PPP QQQ RR SSS TTT U U V V W W X X
MMM NNN O O P P Q Q R R S T U U V V W W X
M M NNN O O PPP Q Q RR SSS T U U V V WWW X
M M N N O O P QQQ R R S T U U V V WWW X
M M N N OOO P QQQ R R SSS T UUU V WWW X X
Input: YZ!
Output:
Y Y ZZZ !!!
Y Y Z !!!
YYY Z !!!
Y Z
YYY ZZZ !!!
The winner is the shortest source code, as counted by the number of bytes it takes to store the file in utf-8 encoding. Source code should read input from stdin, output to stdout. You can assume input will only contain [A-Z! ]
. If you insult the user on incorrect input, you get a 10 character discount =P.
I was going to require these exact 28 characters, but to make it more interesting, you can choose how you want them to look - whatever makes your code shorter! To prove that your letters do look like normal letters, show the output of the last three runs.
Shortest codes so far, in characters (utf8 encoding if non-ASCII present):
C#,
239 231229 chars (292 bytes)I'm a bit late but this just looked like fun.
Python 2.6,
251-243- 227 charactersI tried a slightly different approach (bitpacking the parts the letters are made of) ...
As always, all comments and suggestions welcome! Contender for shortest Python solution (again a few characters behind at the moment)...
C89, 345 characters
Newlines added for your sanity (they are not included in the character count and can/should be deleted):
F#, 382 chars
I compressed two letters from each row into an ascii-printable byte, and handled space and exclamation point specially.
Sample I/O below:
Haskell, 313
316320For the curious, the large number is the hex version of
encoding
in the following code. The number is simply used as a bitmap. I've had no success with further shortening the code by encoding the number to other bases even with non-standard character representations.Python,
233231225224205 charsCandidate for the shortest python solution here :-)
It is a two-liner - last line was broken in 3 for urrrr readability
ps. Thanks for comments, corrected issues and now using 7-bit ASCII only!
Test banner: