Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse.


Task:

Take a string of ASCII-art text and output the content of the text as regular ASCII text.


Input:

String of ASCII-art text.

Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing newline is optional). All lines have the same length. (That is, the last ASCII-art letter is padded with trailing spaces.) You can use some other printable ASCII character instead of # in the input if you wish.

The input will contain ASCII-art letters A-Z and ASCII-art spaces (a 5x5 block of whitespace). No punctuation. There is only one line of ASCII-art text (5 actual lines). There will be no trailing or leading ASCII-art spaces, nor will there be adjacent ASCII-art spaces.

Letter size is 5x5 characters. There is a 1x5 space between each letter. Space between words is a 5x5 block of whitespace (+ 1x5 space on each side, because it is just another letter). There will be no 1x5 space at the end or at the beginning, only between ASCII-art letters.


Output:

String containing the text as ASCII characters A-Z + spaces. The output can be in lowercase also, if that is somehow easier for your solution. Mixed case is also allowed.


The ASCII-art letters:

 ###  ####   ###  ####  ##### #####  ###  #   # ##### ##### #   # #     #   #
#   # #   # #   # #   # #     #     #     #   #   #     #   #  #  #     ## ##
##### ####  #     #   # ####  ####  #  ## #####   #     #   ###   #     # # #
#   # #   # #   # #   # #     #     #   # #   #   #   # #   #  #  #     #   #
#   # ####   ###  ####  ##### #      ###  #   # ##### ###   #   # ##### #   #

#   #  ###  ####   ###  ####   ###  ##### #   # #   # #   # #   # #   # #####
##  # #   # #   # #   # #   # #       #   #   # #   # #   #  # #   # #     # 
# # # #   # ####  #   # ####   ###    #   #   #  # #  # # #   #     #     #  
#  ## #   # #     #  #  #   #     #   #   #   #  # #  ## ##  # #    #    #   
#   #  ###  #      ## # #   #  ###    #    ###    #   #   # #   #   #   #####

The space:

     |
     | A 5x5 square of spaces.
     | (Padded with |s to make it appear in this post.)
     |
     |

Examples:

Input:

#   # ##### #     #      ###        #   #  ###  ####  #     #### 
#   # #     #     #     #   #       #   # #   # #   # #     #   #
##### ####  #     #     #   #       # # # #   # ####  #     #   #
#   # #     #     #     #   #       ## ## #   # #   # #     #   #
#   # ##### ##### #####  ###        #   #  ###  #   # ##### #### 

Output: HELLO WORLD

Input:

 ###   ###   ###  ##### #####
#   # #     #   #   #     #  
#####  ###  #       #     #  
#   #     # #   #   #     #  
#   #  ###   ###  ##### #####

Output: ASCII

Input:

####  ####   ###   ### 
#   # #   # #   # #    
####  ####  #     #  ##
#     #     #   # #   #
#     #      ###   ### 

Output: PPCG


This is , so the shortest answer in bytes wins.

share|improve this question
4  
I'm thinking the solution to this might involve some sort of hash function... – Neil 11 hours ago
3  
I really like this genre of challenge (effectively, reverse kolmogorov-complexity), and it could probably do with a tag of its own. (Searching for "hash is:answer" tends to be a good way to find them, although only once they actually have answers.) – ais523 11 hours ago
4  
Bounty from me if you do this by converting the input to an image and solves this using image processing! (The solution must be golfed too of course) – Stewie Griffin 11 hours ago
1  
If it's of help to anyone: either the second row, the fourth row, or the middle column of the letters can be dropped without losing relevant information. – Martin Ender 11 hours ago
1  
@JungHwanMin Hmm. I think not, because that would not be very human-readable ASCII-art text. – Steadybox 7 hours ago

Python 2, 405 335 234 212 bytes

lambda s,j=''.join:j('  UV  RG  F M E  SI TADJH    BP  LQW       O     N  Z  C     YXK'[sum((y>" ")<<i for i,y in enumerate(j(s.split('\n')[x][i:i+5]for x in range(5))))%137%93%72%64]for i in range(0,len(s)/5,6))

Try it online!

share|improve this answer
    
Clever use of the modulus, but I can't help thinking there must be a way to do: [0,2,3,7,...] and ' UBGOTA... split it, and use some sort of mapping. 0:' ',2:'U',3:'V'... looks so long,,, there are so many :'',. (I know you had something similar in the original post, but with very long numbers. – Stewie Griffin 10 hours ago
    
@StewieGriffin it is better now – ovs 10 hours ago

JavaScript (ES6), 204 186 184 bytes

Saved 18 bytes thanks to Neil
Saved 2 bytes thanks to ETHproductions

Breakdown:

  • 42-byte lookup table
  • 162 144 142 bytes of code
s=>(a=s.split`
`)[0].replace(/.{6}/g,(_,n)=>' H_JM__WDCSORLU___QKG_P_AFT_N_EI_XBV____YZ'[[0,1,2,4].reduce((p,r,i)=>p+='0b'+a[r].substr(n,5).replace(/./g,c=>0|c>' ')<<i*6,0)%178%69%43])

Demo

let f =

s=>(a=s.split`
`)[0].replace(/.{6}/g,(_,n)=>' H_JM__WDCSORLU___QKG_P_AFT_N_EI_XBV____YZ'[[0,1,2,4].reduce((p,r,i)=>p+='0b'+a[r].substr(n,5).replace(/./g,c=>0|c>' ')<<i*6,0)%178%69%43])

console.log(f(
  ' ###   ###   ###  ##### ##### \n'+
  '#   # #     #   #   #     #   \n'+
  '#####  ###  #       #     #   \n'+
  '#   #     # #   #   #     #   \n'+
  '#   #  ###   ###  ##### ##### \n'
));

share|improve this answer
1  
You can save a whole bunch of bytes using (a=s.split`\n`)[0].replace(/......?/g, with substr(n,5) and without the join of course. – Neil 5 hours ago
    
I think you can save a byte with c=>0|c>' ', and another with p+='0b'+... – ETHproductions 5 hours ago

Jelly, 50 45 bytes

ỴZFs30UOḂḅ7%81‘ị“wḌ81X/⁸N©ẎRyGṬ%Ṇ1mÆėƙñøƭẇỌỊ»

Try it online! (note the argument does not require the leading newline, but since leading and trailing newlines have no effect I included one to make the multiline string more human-readable)

Results are mixed case (as allowed by the OP in a comment).

How?

Splits on new lines, transposes, flattens and splits into chunks of (up to) 30 to get the character representations and reverses each (equating the later base conversion for the final character of length 25). Then maps '#' and ' ' to one and zero respectively using the fact that '#' has an odd ordinal while ' ' has an even one. Reads each as if it were a base seven number. Takes modulo 81 of each (to yield 27 unique values for the 27 possible cases), and finally indexes into a "magic string" with the correct chars at the correct indexes.

Here is the "magic string" I created along with a (case-insensitive) regex pattern it needed to match:

 ' affectedly Azerbaijan rewaxed naganas jiujitsudankly pase UVB freqHaarlemcoact'
'^ ..f...e.....z......a..r.w.x...n.g......iuj....d..kly.p.s...vb....qh.....m.o.ct.*'

As such it may be compressed, looking up eleven sub-slices as words in Jelly's dictionary (most of which use the leading space default):

' affectedly Azerbaijan rewaxed naganas jiujitsudankly pase UVB freqHaarlemcoact'
 ^          ^          ^       ^       ^        ^     ^    ^   ^    ^      ^

which results in the Jelly compressed string, “wḌ81X/⁸N©ẎRyGṬ%Ṇ1mÆėƙñøƭẇỌỊ»

The rest of the code works as follows:

ỴZFs30UOḂḅ7%81‘ị“...» - Main link: multi-line string, s
Ỵ                     - split on new lines
 Z                    - transpose
  F                   - flatten
   s30                - split into chunks of length 30
      U               - upend (reverse each)
       O              - cast to ordinals ('#' -> 35, ' '-> 32)
        Ḃ             - modulo 2 ('#' -> 1, ' ' -> 0)
         ḅ7           - convert from base 7 (vectorises)
           %81        - modulo 81 (vectorises)
              ‘       - increment
               ị      - index into
                “...» -     the "magic string" described above
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.