;/5 3$"1(' ',.s){~"1#:3 u:(ucp'翇篭篯礧歮禧禤祯寭璗牯宭䤧彭忭筯篤筿殭秏璒孯孪寿咕寏犧'){~0>.64-~a.i.s=:
Usage:
;/5 3$"1(' ',.s){~"1#:3 u:(ucp'翇篭篯礧歮禧禤祯寭璗牯宭䤧彭忭筯篤筿殭秏璒孯孪寿咕寏犧'){~0>.64-~a.i.s=:'ABCDEFGHIJKLMNOPQRSTUVWXYZ !'
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│AAA│BBB│CCC│DD │EEE│FFF│GGG│H H│III│JJJ│K K│L │M M│N N│OOO│PPP│QQQ│RR │SSS│TTT│U U│V V│W W│X X│Y Y│ZZZ│ │!!!│
│A A│B B│C │D D│E │F │G │H H│ I │ J│K K│L │MMM│NNN│O O│P P│Q Q│R R│S │ T │U U│V V│W W│ X │Y Y│ Z│ │!!!│
│AAA│BBB│C │D D│EE │FF │G G│HHH│ I │ J│KK │L │M M│NNN│O O│PPP│Q Q│RR │SSS│ T │U U│V V│WWW│ X │YYY│ Z │ │!!!│
│A A│B B│C │D D│E │F │G G│H H│ I │J J│K K│L │M M│N N│O O│P │QQQ│R R│ S│ T │U U│V V│WWW│ X │ Y│Z │ │ │
│A A│BBB│CCC│DD │EEE│F │GGG│H H│III│JJJ│K K│LLL│M M│N N│OOO│P │QQQ│R R│SSS│ T │UUU│ V │WWW│X X│YYY│ZZZ│ │!!!│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
;/5 3$"1(' ',.s){~"1#:3 u:(ucp'翇篭篯礧歮禧禤祯寭璗牯宭䤧彭忭筯篤筿殭秏璒孯孪寿咕寏犧'){~0>.64-~a.i.s=:'this is incorrect input.'
|index error
Explanation (NB.
is comment in J):
;/ NB. String together along the third dimension...
5 3$"1 NB. ... reshape each line to 5x3...
(' ',.s) NB. ... a space before each letter of the input string...
{~"1 NB. ... indexed using...
#: NB. ... the (15 bit) binary representation of ...
3 u: NB. ... the integer representation of...
(ucp'翇篭篯礧歮禧禤祯寭璗牯宭䤧彭忭筯篤筿殭秏璒孯孪寿咕寏犧') ... the unicode versions of these code points...
{~ NB. ...indexed using...
0>. NB. ...the max of 0 and...
64-~ NB. ...64 less than...
a.i. NB. the ascii indexes of s
s=: NB. Assign the input string to the variable s.
s=raw_input()
for i in range(5):
for c in s:
print''.join((' ',c)[int('2zj93fqzj6hsh2bc8i2b1ycncj5yc2v9i0m16dz91gcizj18blbw6wt0p3qqh8svchwc5onna2808of',36)>>((ord(c)-65 if c>'@'else 26)*15+i*3+j)&1]for j in[0,1,2]),
print
Notes:
Running (I changed appearance of a few letters, for aestetic reasons only ;):
$ echo ABCDEFGHIJKL | python code-golf.py
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 EEE FFF 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
$ echo MNOPQRSTUVWX | python code-golf.py
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 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 X
M M N N OOO P QQQ R R SSS T UUU V W W X X
$ echo YZ\! | python code-golf.py
Y Y ZZZ !!!
Y Y Z !!!
YYY Z !!!
Y Z
YYY ZZZ !!!
There are trailing spaces.
wget -q 3.ly/gzkv;figlet -f b
Sample output:
% wget -q 3.ly/gzkv;figlet -f b ABCDEFGHIJKLMNOPQRS
A BB CC DD EEE FFF GG H H III JJ K K L M M NNN O PP Q RR SS
A A B B C D D E F G H H I J K K L MMM N N O O P P Q Q R R S
AAA BB C D D EE FF G G HHH I J KK L MMM N N O O PP Q Q RR S
A A B B C D D E F G G H H I J J K K L M M N N O O P QQ R R S
A A BB CC DD EEE F GG H H III J K K LLL M M N N O P Q R R SS
% wget -q 3.ly/gzkv;figlet -f b TUVWXYZ \!
TTT U U V V W W X X Y Y ZZZ !!!
T U U V V W W X X Y Y Z !!!
T U U V V WWW X Y Z !!!
T U U V V WWW X X Y Z
T UUU V W W X X Y ZZZ !!!
Candidate for the shortest python solution here :-)
It is a two-liner - last line was broken in 3 for urrrr readability
s=raw_input()
for i in range(5):print' '.join(''.join((' ',c)[ord(
'W_E__U__QQ_QN_UQ_EA_Q]_D_Q_QYQ__D[_PP_B__F__Q__EG_Y__EZWU]A_A_P_OPO_\\_QNQWT_YUS'
[max(0,3*ord(c)-192-k)])>>i&1]for k in(2,1,0))for c in s)
ps. Thanks for comments, corrected issues and now using 7-bit ASCII only!
Test banner:
TTT H H EEE QQQ U U III CCC K K BBB RR OOO W W N N FFF OOO X X JJJ U U M M PPP SSS OOO V V EEE RR TTT H H EEE L AAA ZZZ Y Y DD OOO GGG !!!
T H H E Q Q U U I C K K B B R R O O W W NNN F O O X J U U MMM P P S O O V V E R R T H H E L A A Z Y Y D D O O G !!!
T HHH EE Q Q U U I C KK BBB RR O O WWW NNN FF O O X J U U M M PPP SSS O O V V EE RR T HHH EE L AAA Z YYY D D O O G G !!!
T H H E QQQ U U I C K K B B R R O O WWW N N F O O X J J U U M M P S O O V V E R R T H H E L A A Z Y D D O O G G
T H H EEE QQQ UUU III CCC K K BBB R R OOO WWW N N F OOO X X JJJ UUU M M P SSS OOO V EEE R R T H H EEE LLL A A ZZZ YYY DD OOO GGG !!!
import Data.Bits
import Data.Char
c&True=c
c&_=' '
a ' '='@'
a '!'='['
a c=c
q s=unlines[s>>= \c->take 3(drop(84*n+3*(ord(a c)-64))$map((c&).testBit(0xffdebaf79f6fbfde7bfe8062f6a979b69b55a4d368ebaf6aeefbe9717add3f8f2ab6a36dbf9b1524d368fedb6fefff69bfdffbff8::Integer))[0..])++" "|n<-[0..4]]
main=getLine>>=putStr.q
For 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.
formats :: [String] -- order: [ A-Z!] <- that's a space in front of A
formats = [
" AAABBBCCCDD EEEFFFGGGH HIIIJJJK KL M MN NOOOPPPQQQRR SSSTTTU UV VW WX XY YZZZ!!!"
, " A AB BC D DE F G H H I JK KL MMMNNNO OP PQ QR RS T U UV VW W X Y Y Z!!!"
, " AAABBBC D DEE FF G GHHH I JKK L M MNNNO OPPPQ QRR SSS T U UV VWWW X YYY Z !!!"
, " A AB BC D DE F G GH H I J JK KL M MN NO OP QQQR R S T U UV VWWW X YZ "
, " A ABBBCCCDD EEEF GGGH HIIIJJJK KLLLM MN NOOOP QQQR RSSS T UUU V WWWX XYYYZZZ!!!"
]
charToBool :: Char -> Bool
charToBool ' ' = False
charToBool _ = True
boolToInteger :: Bool -> Integer
boolToInteger True = 1
boolToInteger _ = 0
encoding :: Integer
encoding = foldr f 0 $ zip [0..] $ map charToBool $ concat formats
where
f (pow, bool) z = z + ((2^pow) * boolToInteger bool)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With