20
1
figlet is utility that converts plain text to an ascii-art representation for use in banners and the like. For example:
$ figlet "CODE GOLF"
____ ___ ____ _____ ____ ___ _ _____
/ ___/ _ \| _ \| ____| / ___|/ _ \| | | ___|
| | | | | | | | | _| | | _| | | | | | |_
| |__| |_| | |_| | |___ | |_| | |_| | |___| _|
\____\___/|____/|_____| \____|\___/|_____|_|
$
Write a program or function that takes the ascii-art output from figlet and returns it to its original plain text.
It may be helpful to you to install figlet. I have version 2.2.5 which is what you get if you sudo apt-get install figlet on Ubuntu 14.04. This figlet actually has several "fonts". For the purposes of this context, we will just be dealing with the default standard font.
Input text will be no more that 80 characters wide, and will have been generated from plain text containing only the uppercase characters and space.
Your program may not call figlet or its source code in any way.
Example
Input:
_ ____ ____ ____ _____ _____ ____ _ _ ___
/ \ | __ ) / ___| _ \| ____| ___/ ___| | | |_ _|
/ _ \ | _ \| | | | | | _| | |_ | | _| |_| || |
/ ___ \| |_) | |___| |_| | |___| _|| |_| | _ || |
/_/ \_\____/ \____|____/|_____|_| \____|_| |_|___|
_ _ ___ __ __ _ _ ___ ____ ___ ____
| | |/ / | | \/ | \ | |/ _ \| _ \ / _ \| _ \
_ | | ' /| | | |\/| | \| | | | | |_) | | | | |_) |
| |_| | . \| |___| | | | |\ | |_| | __/| |_| | _ <
\___/|_|\_\_____|_| |_|_| \_|\___/|_| \__\_\_| \_\
____ _____ _ ___ ____ ____ ____ _______
/ ___|_ _| | | \ \ / /\ \ / /\ \/ /\ \ / /__ /
\___ \ | | | | | |\ \ / / \ \ /\ / / \ / \ V / / /
___) || | | |_| | \ V / \ V V / / \ | | / /_
|____/ |_| \___/ \_/ \_/\_/ /_/\_\ |_| /____|
Output:
ABCDEFGHI
JKLMNOPQR
STUVWXYZ
Input:
____ _____ _ ____ __ ___ ____ ____
/ ___|_ _|/ \ | _ \ \ \ / / \ | _ \/ ___|
\___ \ | | / _ \ | |_) | \ \ /\ / / _ \ | |_) \___ \
___) || |/ ___ \| _ < \ V V / ___ \| _ < ___) |
|____/ |_/_/ \_\_| \_\ \_/\_/_/ \_\_| \_\____/
Output:
STAR WARS
Note a previous edit of this question allowed inputs containing upper and lower case letters plus numerals. It was pointed out that this caused several points of ambiguity with certain adjacent character combinations. It became obvious that I needed to rigorously find a set of characters with no such collisions so that the contest is actually doable. At first I tried all lowercase letters plus numerals with this shell one-liner:
for t in {0..9}{a..z} {a..z}{a..z} {a..z}{0..9} {0..9}{0..9} ; do figlet $t | tr '\n' ':'; echo ; done | sort | uniq -d | tr ':' '\n'
This yielded {j1, jl} and {i1, il} as ambiguous pairs. So instead with all uppercase letters (as suggested by @AlexA.), there are no ambiguous pairs:
for t in {A-Z} ; do figlet $t | tr '\n' ':'; echo ; done | sort | uniq -d | tr ':' '\n'
5I'd suggest a 'you may not call figlet' clause, because otherwise surely the shortest program will iterate over all possible strings, calling figlet on them, and then comparing for equality. – orlp – 2015-07-30T00:24:47.680
1The source code of figlet can be found in the following git repo:
git://git.debian.org/git/collab-maint/figlet.git(download withgit clone). – Doorknob – 2015-07-30T03:14:40.1504Note: this challenge is very difficult to code, let alone code golf. – Lynn – 2015-07-30T09:27:44.747
4
1andlare not identical, butV1andVlare. – Lynn – 2015-07-30T09:39:57.1531Much more feasible! – Not that Charles – 2015-07-30T18:16:54.703
@AlexA. - done :) I think its cleaner now - deleting obsolete comments... – Digital Trauma – 2015-07-30T18:17:26.133
XOXandXDXare still really hard to discern... maybe that's a good kind of challenge, though? – Lynn – 2015-07-30T19:38:48.970@Mauris hard, but not impossible :) – Digital Trauma – 2015-07-30T19:41:21.223
2
For people who do not have a system that can run figlet, there are various online versions. Search for "figlet online". For example, this one looks fairly straightforward and ad free: http://www.network-science.de/ascii/. Make sure that you choose the "standard" font.
– Reto Koradi – 2015-07-30T20:07:59.960@RetoKoradi Thanks! I checked the output and with the standard font, it does seem to match. – Digital Trauma – 2015-07-30T20:15:36.317