19
\$\begingroup\$

This is a bit similar to this dust covered entry but I'm hoping my spin on it makes it unique enough. Not been able to find anything dissuading me from posting this but there is quite the sea out there.

Anyway! The challenge:

Your code receives a string of characters; It converts this into an ASCII-art style version of the same string, but with a catch.

Input transformation

  • The only characters to be supported are A-Z and 0-9
  • Lower case letters are transformed into uppercase
  • Anything else is silently removed

Character drawing

  • Each "pixel" of the enlarged font is drawn from the input string
  • The n'th pixel is equal to the n'th character in the input string. If n is greater than the length of the input string, wrap around back to the beginning
  • Individual letters are drawn left-to-right, top-to-bottom
  • Subsequent letters pick up their "pixel character" index from where the last letter left off (e.g. with an input length of 10, if the first letter had 9 pixels, the second letter's first pixel will be drawn with the 10th input character, the second pixel will be drawn with the 1st input character)
  • Each letter is drawn in a 5x5 grid, fully padded with spaces. You can find the font you are to use pre-rendered for you in this pastebin or a bit further down in this post
  • Every letter is drawn on the same line, so the total number of line breaks in your output will be 4
  • Every letter is seperated by 2 columns of spaces

The font

 000 
0  00
0 0 0
00  0
 000 

111  
  1  
  1  
  1  
11111

2222 
    2
 222 
2    
22222

3333 
    3
  333
    3
3333 

  44 
 4 4 
44444
   4 
   4 

55555
5    
5555 
    5
5555 

 6666
6    
6666 
6   6
 666 

77777
    7
   7 
  7  
 7   

 888 
8   8
 888 
8   8
 888 

 999 
9   9
 9999
    9
9999 

 AAA 
A   A
AAAAA
A   A
A   A

BBBB 
B   B
BBBB 
B   B
BBBB 

 CCCC
C    
C    
C    
 CCCC

DDDD 
D   D
D   D
D   D
DDDD 

EEEEE
E    
EEE  
E    
EEEEE

FFFFF
F    
FFF  
F    
F    

 GGGG
G    
G  GG
G   G
 GGGG

H   H
H   H
HHHHH
H   H
H   H

IIIII
  I  
  I  
  I  
IIIII

JJJJJ
  J  
  J  
  J  
JJ   

K   K
K  K 
KKK  
K  K 
K   K

L    
L    
L    
L    
LLLLL

M   M
MM MM
M M M
M   M
M   M

N   N
NN  N
N N N
N  NN
N   N

 OOO 
O   O
O   O
O   O
 OOO 

PPPP 
P   P
PPPP 
P    
P    

 QQ  
Q  Q 
Q QQ 
Q  Q 
 QQ Q

RRRR 
R   R
RRRR 
R  R 
R   R

 SSSS
S    
 SSS 
    S
SSSS 

TTTTT
  T  
  T  
  T  
  T  

U   U
U   U
U   U
U   U
 UUU 

V   V
V   V
 V V 
 V V 
  V  

W   W
W   W
W W W
WW WW
W   W

X   X
 X X 
  X  
 X X 
X   X

Y   Y
 Y Y 
  Y  
  Y  
  Y  

ZZZZZ
   Z 
  Z  
 Z   
ZZZZZ

Yes I know the 4 and Q are ugly

An example

Input

0123456789

Output

 012   567    6789   0123     34   45678   9012  34567   234    567 
3  45    8        0      4   5 6   9      3          8  5   6  8   9
6 7 8    9     123     567  78901  0123   4567      9    789    0123
90  1    0    4          8     2       4  8   9    0    0   1      4
 234   12345  56789  9012      3   5678    012    1      234   5678 

Another example

Input

a3 B'2

Output

 A3B   B2A3   2A3B   2A3B 
2   A      B  2   A      2
3B2A3    2A3  3B2A    A3B 
B   2      B  3   B  2    
A   3  2A3B   2A3B   A3B2A

Standard loopholes are forbidden. Code golf so no green tick will be given.

\$\endgroup\$
19
  • 19
    \$\begingroup\$ I'd suggest guaranteeing that the input will only contain [A-Z\d] - I don't think filtering invalid characters adds anything to the challenge. \$\endgroup\$
    – Shaggy
    Commented Jun 14, 2018 at 10:36
  • 3
    \$\begingroup\$ @Shaggy Perhaps. But by the same token I don't think it removes anything from the challenge \$\endgroup\$
    – Scoots
    Commented Jun 14, 2018 at 10:40
  • 1
    \$\begingroup\$ related \$\endgroup\$
    – Laikoni
    Commented Jun 14, 2018 at 11:21
  • 1
    \$\begingroup\$ Related. \$\endgroup\$ Commented Jun 14, 2018 at 12:19
  • 2
    \$\begingroup\$ What about THREE leading spaces? Surely you'll not allow that! \$\endgroup\$ Commented Jun 15, 2018 at 10:14

12 Answers 12

16
\$\begingroup\$

Python 2, 413 411 373 364 352 345 bytes

-1 byte thanks to Kevin Cruijssen.
-9 bytes thanks to Jo King.
-1 byte thanks to Lynn.

Data string contains unprintables, escaped version below.

k=list(filter(str.isalnum,input()))
q=range(5);o=['']*5;r=k*25;d=0
for c in'uM<LxSe#ye>El4NpD@$	gh>I,m]aB>e,]?kFLyglxV!%w832wGj%uT{Hr*K,*[P\n6.&ED#T}^DLI&p7f\d`*lG!FacG\rz?!A':d*=126;d+=ord(c)-1
for c in k:
 for i in q:
	for y in q+[999]*2:o[i]+=d>>int(c,36)*25+i*5+y&1and r.pop(0)or' '
print'\n'.join(o).upper()

Try it online!

As each character has 25 pixels it can be easily encoded in 25 bits. The base 126 number 'uM\x04<L\x10x\x14Se#ye\x0f>El4NpD@$\tgh>\x1d\x10\x15I,\x0em]a\x0e\x03B>e\x15,\x0c]\x03?kFL\x01\x0byglxV!\x18\x16\x0c\x0b\x10\x0b%w832wGj%uT{Hr*K,*[P\n6.&ED#T\x0c}^\x1c\x0fD\x17LI&p7\x17f\\d`*\x01l\x1bG\x12!Fac\x05\x08\x0eG\rz?!\x1aA' encodes all chars, the 0 is encoded by the least significant 25 bits, the 1 by the next 25 bits and the Z is encoded by the 25 most significant bits. A single character is encoded in the following order:

00 01 02 03 04
05 06 07 08 09
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24

(00 is the least significant bit, 25 the most significant one)

Spaces are encoded by a zero, non-spaces by a one. Example:

77777      11111
    7      00001
   7   =>  00010  => (0001000100010001000011111)
  7        00100
 7         01000

Ungolfed

k = list(filter(str.isalnum,input()))  # keep only alphanumeric characters of the input
o = ['']*5   # this list contains the output, initially 5 empty lines
r = k * 25   # make a copy of the input 25-times the length, these chars will be used for the pixels
data = 0
#  data encoded in base 126
b92d = 'uM<LxSe#ye>El4NpD@$	gh>I,m]aB>e,]?kFLyglxV!%w832wGj%uT{Hr*K,*[P\n6.&ED#T}^DLI&p7f\d`*lG!FacG\rz?!A'
for c in b92d:          # convert base 92 to base 10
  d*=126;d+=ord(c)-1

for c in k:             # iterate over the filtered input
  a_index = int(c, 36)  # the index of the current char in '0..9A..Z' / '0..9a..z'
  for i in range(5):    # for each row of the output
    for y in range(5)+[999]*2:  # for each pixel in the row, th two 999's are used for spaces
      is_set = data >> (a_index*25 + i*5 + y) & 1  # We shift the to the right to have ...
                                                   # the current pixels value at the LSB:
                                                   # 25 bits for each char that came before
                                                   # 5 bits for each previous row and 1 bit
                                                   # for every pixel in the same row
      o[i] += is_set and r.pop(0) or ' '           # If the current pixel is set, append ...
                                                   # ... a character from the input to the current row
print '\n'.join(o).upper()  # print the output

Try it online!

\$\endgroup\$
7
  • \$\begingroup\$ Letters should be separated by two spaces, so the +' ' should be +' '. Nice answer regardless, so +1 from me. \$\endgroup\$ Commented Jun 14, 2018 at 13:52
  • \$\begingroup\$ you do need the .upper() somewhere though, otherwise the inner letters end up lowercase \$\endgroup\$
    – Jo King
    Commented Jun 15, 2018 at 1:11
  • \$\begingroup\$ @JoKing You're right, fixed it. \$\endgroup\$
    – ovs
    Commented Jun 15, 2018 at 6:31
  • \$\begingroup\$ Love this encoding trick. Did you choose base 92 because that's the largest standard encoding consisting of printable ascii? could you have gone higher? also i googled but wasn't able to fine info on base 92 - do you have a link? \$\endgroup\$
    – Jonah
    Commented Jun 16, 2018 at 14:00
  • \$\begingroup\$ @Jonah There is no such standard as base 92-encoding, thats why I implemented my own decoding logic. As long as you have enough distinct digits, you can use any base >1. \$\endgroup\$
    – ovs
    Commented Jun 16, 2018 at 14:10
10
\$\begingroup\$

APL (Dyalog Unicode), 228 225 224 214 bytes

Full program. Prompts stdin for string. Prints to stdout. About half of the code is just decoding the encoded alphabet.

⍉↓(⍴t)⍴r\i⍴⍨+/r←,t←(⊂a⍳i←(1(819⌶)⍞)∩a←⎕D,⎕A)⌷0(220⌶)¯1(219⌶)¯125+⎕AV⍳_________________________________________________________________________________________________________________________________________________

__ represents the following 143-byte LZ4-encoded string in quotes: "⊥\u0004pæ€}€\\⊃⌿Æ€â<Å€∧€ÀÆ€Ð┬:Ëcü\u0000≥ðè⊤õ⍨¢∧·èý\u0005þÐÕ\u001EÐ :\u001Eè⌊×ßi[B⊂ɫoãà oéìÐ⍙⊃Ý∣à)≥èB⊃\u001B\u001F⊥ä{⌿⍨ G⍺\u001B⌿Æ\u001F∇x└îR`:└è→⊂\u0000ê∧⍒\u0003ɫqè$$ÛD⊥â∊\u001B\u001Eéu|\u001B@4A|⍪┌nàkááЀ€€€€€€"

Try it online!

__ 143-byte LZ4-encoded string in quotes

⎕AV⍳ɩndices of that in the Atomic Vector (the character set)

¯125+ add -125 to that (to get signed 8-bit integers)

¯1(219⌶) LZ4 decompress

0(220⌶) deserialise to a 36 layer, 5 row, 5 column Boolean array

()⌷ index into that using the following indices:

⎕A uppercase Alphabet

⎕D, prepend the Digits

a← store in a (for alphabet)

()∩ intersection of the following and that (removes invalid input):

 prompt for text input from stdin (console)

  1(819⌶) fold to uppercase (819 looks like Big, 1 is for yes big as opposed to small)

i← store in i (for input)

a⍳ɩndices of that in a

 enclose (to index with each one representing the leading coordinate)

t← store in t (for text)

, ravel (flatten)

r← store in r (for ravelled)

+/ sum that (i.e. number of characters needed to paint the artwork)

i⍴⍨ cyclically reshape the input to that length

r\ expand that; insert a spaces at 0s, consume letters at 1s

(…)⍴` reshape to the following shape:

⍴t the shape of the text

 split the N-by-5-by5 array into an N-by-5 matrix of art lines

transpose into a 5-by-N matrix of art lines (this aligns corresponding lines of the characters)

By default, APL separates simple elements of a nested array with 2 spaces.

\$\endgroup\$
3
  • \$\begingroup\$ Not quite! There needs to be 2 spaces between each letter \$\endgroup\$
    – Scoots
    Commented Jun 14, 2018 at 12:54
  • 1
    \$\begingroup\$ @Scoots OK, fixed. \$\endgroup\$
    – Adám
    Commented Jun 14, 2018 at 12:57
  • \$\begingroup\$ @Adám something's wrong with C and D \$\endgroup\$
    – ngn
    Commented Jun 16, 2018 at 4:19
9
\$\begingroup\$

Python 2, 428 bytes

s=filter(str.isalnum,input().upper());x=s
R=['']*5
for c in s:
 i=0;exec"n=int('RAAAOQQ2RBAQBQRRBDRRDCDDAQ8QBRDDDDDRXDDF0XX6CCDDCDCCCD00ECNLDDEDC0DDD66YYABH0A3RQQRQCDOOFR00OCHHDQIQA0D6H0000DXL0CXYXDDDCDCCDD00ECDFDCEEX0D6N6044AQARRQYQADQBQRCBDRKDRDDAC9DQ0A0DD0R'[i*36+ord(c)%55%45],36);R[i]+=bin(n+36*(n<30)<<2)[3:].replace(*'0 ').replace(*'1.');i+=1;"*5
 while'.'in`R`:R=eval(`R`.replace('.',x[0],1));x=x[1:]+s
print'\n'.join(R)

Try it online!


The letters are encoded as follows:

Each unique part (there are 23) is converted to binary, and a 1 is added in front. Then it is converted to base 36.

  part      bin      1+bin     int     base36
'  ...' -> 00111 -> 100111 ->   39  ->   13

The resulting base-36 numbers are:

[10,12,13,14,16,18,19,1A,1B,1C,1D,1E,1F,1H,1I,1K,1L,1N,1O,1Q,1R,X,Y]

The initial 1 is removed, so we have a single character:

[0,2,3,4,6,8,9,A,B,C,D,E,F,H,I,K,L,N,O,Q,R,X,Y]

Each letter (A-Z0-9) is then encoded to five of these new chars.

0 = ' ... ','.  ..','. . .','..  .',' ... ' -> A,F,H,L,A
1 = '...  ','  .  ','  .  ','  .  ','.....' -> O,0,0,0,R
etc.

Into five lists:

'AOQQ2RBRAAAQBQRRBDRRDCDDAQ8QBRDDDDDR'
'F0XX6CCXDDDDCDCCCD00ECNLDDEDC0DDD66Y'
'H0A3RQQYABRQCDOOFR00OCHHDQIQA0D6H000'
'L0CXYXD0DXDDCDCCDD00ECDFDCEEX0D6N604'
'ARRQYQA4AQDQBQRCBDRKDRDDAC9DQ0A0DD0R'

To map the input to an index in these lists, the ordinal is modded:

'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ord(c) = [48-57, 65-90]
ord(c)%55%45 = [3-9, 0-2, 10-35]

Because the ordinals are not 0-35, but slightly mixed, the 5 lists are rearranged, and concatenated:

'RAAAOQQ2RBAQBQRRBDRRDCDDAQ8QBRDDDDDR'
'XDDF0XX6CCDDCDCCCD00ECNLDDEDC0DDD66Y'
'YABH0A3RQQRQCDOOFR00OCHHDQIQA0D6H000'
'0DXL0CXYXDDDCDCCDD00ECDFDCEEX0D6N604'
'4AQARRQYQADQBQRCBDRKDRDDAC9DQ0A0DD0R'
->
'RAAAOQQ2RBAQBQRRBDRRDCDDAQ8QBRDDDDDRXDDF0XX6CCDDCDCCCD00ECNLDDEDC0DDD66YYABH0A3RQQRQCDOOFR00OCHHDQIQA0D6H0000DXL0CXYXDDDCDCCDD00ECDFDCEEX0D6N6044AQARRQYQADQBQRCBDRKDRDDAC9DQ0A0DD0R'

For each char in the input, it's 5 letters are found, and converted to a ints(base36):

n=int('RAAA...D0R'[i*36+ord(c)%55%45],36)
                   i*36                    #get row i
                        ord(c)%55%45       #n -> 0..35
  int(                               ,36)  #convert to int

If the number is below 30, 36is added (the missing 1we removed earlier)

n+36*(n<30)

Then the number is converted back to binary, and 0s and 1s are converted to and .. Two spaces are added at the end during the conversion.

bin(n+36*(n<30)<<2)[3:].replace(*'0 ').replace(*'1.')

    n+36*(n<30)                                       #add leading base36 '1'
               <<2                                    #add 2 0's to end
bin(              )                                   #convert to binary string
                   [3:]                               #remove '0b1' from front
                       .replace(*'0 ').replace(*'1.') #replace 0 and 1

Eg.

C    base36    int     <<2       bin-str        str
3 ->   13   ->  39  ->  156 -> 0b10011100 -> '  ...  '

For each . in the result, it is replaced by the next character from the input (iterated by x)

while'.'in`R`:R=eval(`R`.replace('.',x[0],1));x=x[1:]+s
\$\endgroup\$
4
  • \$\begingroup\$ Nice! Could I trouble you for an explanation of how this works? At the moment this is wizardry to my eyes. \$\endgroup\$
    – Scoots
    Commented Jun 14, 2018 at 12:33
  • \$\begingroup\$ @Scoots On it! :) \$\endgroup\$
    – TFeld
    Commented Jun 14, 2018 at 12:48
  • 3
    \$\begingroup\$ Thanks for adding that :) The cleverness I see in the answers on this site never fails to impress me \$\endgroup\$
    – Scoots
    Commented Jun 14, 2018 at 13:12
  • \$\begingroup\$ Since the parts are 5 bits, why not use base 32 instead? \$\endgroup\$
    – Neil
    Commented Jun 14, 2018 at 16:52
6
\$\begingroup\$

Java 8, 917 907 bytes

int i,l;String[]S;s->{String q=" ",t="",r[]={t,t,t,t,t};S=s.toUpperCase().replaceAll("[^A-Z0-9]",t).split(t);i=-1;l=S.length;for(String c:S){r[0]+=s("12357BDEFHIJKLMNPRTUVWXYZ",c)+s("012356789ABCDEFGIJOPQRSTZ",c)+s("0123456789ABCDEFGIJOPQRSTZ",c)+s("023456789ABCDEFGIJOPRSTZ",c)+s("567CEFGHIJKMNSTUVWXYZ",c)+q;r[1]+=s("05689ABCDEFGHKLMNOPQRSUVW",c)+s("4MNXY",c)+s("1IJT",c)+s("04KMQXYZ",c)+s("023789ABDHMNOPRUVW",c)+q;r[2]+=s("0456ABCDEFGHKLMNOPQRUW",c)+s("245689ABEFHKPRSV",c)+s("012345689ABEFHIJKMNPQRSTWXYZ",c)+s("23456789ABGHPQRSV",c)+s("0349ADGHMNOUW",c)+q;r[3]+=s("0268ABCDEFGHKLMNOPQRUW",c)+s("0VWXZ",c)+s("17IJTY",c)+s("4KNQRVWX",c)+s("035689ABDGHMNOSUW",c)+q;r[4]+=s("12359ABDEFHIJKLMNPRSWXZ",c)+s("012356789BCDEGIJLOQSUZ",c)+s("01235689BCDEGILOQSTUVYZ",c)+s("012345689BCDEGILOSUZ",c)+s("12ACEGHIKLMNQRWXZ",c)+q;}return"".join("\n",r);}String s(String...s){return s[0].contains(s[1])?S[++i%l]:" ";}

Will golf it down from here to at least halve the current byte-count hopefully..

Try it online.

Explanation:

int i,                         // Index-integer on class-level
    l;                         // Length-integer on class-level
String[]S;                     // String-array of characters on class-level

s->{                           // Method with String as both parameter and return-type
  String q="  ",               //  Temp String containing two spaces to reduce bytes
         t="",                 //  Temp Empty String to reduce bytes
         r[]={t,t,t,t,t};      //  Start with five empty rows
  S=s.toUpperCase()            //  Transform the input-String to uppercase
     .replaceAll("[^A-Z0-9]",t)//  Remove all non alphanumeric characters
     .split(t);                //  And transform it into a String-array of characters
  i=-1;                        //  Set the index-integer on -1 to start with
  l=S.length;                  //  Set the length of the modified input
  for(String c:S){             //  Loop over the characters of the modified input:
    r[0]+=                     //   Append to the first row:
          s("12357BDEFHIJKLMNPRTUVWXYZ",c)      // The first pixel
          +s("012356789ABCDEFGIJOPQRSTZ",c)     // The second pixel
          +s("0123456789ABCDEFGIJOPQRSTZ",c)    // The third pixel
          +s("023456789ABCDEFGIJOPRSTZ",c)      // The fourth pixel
          +s("567CEFGHIJKMNSTUVWXYZ",c)         // The fifth pixel
          +q;                                   // Two trailing spaces
    r[1]+=                     //   Append to the second row:
          s("05689ABCDEFGHKLMNOPQRSUVW",c)      // The first pixel
          +s("4MNXY",c)                         // The second pixel
          +s("1IJT",c)                          // The third pixel
          +s("04KMQXYZ",c)                      // The fourth pixel
          +s("023789ABDHMNOPRUVW",c)            // The fifth pixel
          +q;                                   // Two trailing spaces
    r[2]+=                     //   Append to the third row:
          s("0456ABCDEFGHKLMNOPQRUW",c)         // The first pixel
          +s("245689ABEFHKPRSV",c)              // The second pixel
          +s("012345689ABEFHIJKMNPQRSTWXYZ",c)  // The third pixel
          +s("23456789ABGHPQRSV",c)             // The fourth pixel
          +s("0349ADGHMNOUW",c)                 // The fifth pixel
          +q;                                   // Two trailing spaces
    r[3]+=                     //   Append to the fourth row:
          s("0268ABCDEFGHKLMNOPQRUW",c)         // The first pixel
          +s("0VWXZ",c)                         // The second pixel
          +s("17IJTY",c)                        // The third pixel
          +s("4KNQRVWX",c)                      // The fourth pixel
          +s("035689ABDGHMNOSUW",c)             // The fifth pixel
          +q;                                   // Two trailing spaces
    r[4]+=                     //   Append to the fifth row:
          s("12359ABDEFHIJKLMNPRSWXZ",c)        // The first pixel
          +s("012356789BCDEGIJLOQSUZ",c)        // The second pixel
          +s("01235689BCDEGILOQSTUVYZ",c)       // The third pixel
          +s("012345689BCDEGILOSUZ",c)          // The fourth pixel
          +s("12ACEGHIKLMNQRWXZ",c)             // The fifth pixel
          +q;}                                  // Two trailing spaces
  return"".join("\n",r);}      //  Return the rows joined with new-lines

//  Separated method with String-varargs parameter and String return-type
String s(String...s){          
  return s[0].contains(s[1])?  //  If the String contains the character-String:
                               //   Increase `i` by 1 first with `++i`
    S[++i%l]                   //   Then return the i'th character of the modified input
                               //   with wraparound by using modulo-`l`
   :                           //  Else:
    " ";}                      //   Return a space
\$\endgroup\$
4
  • \$\begingroup\$ You don't seem to have a self-contained example. Class fields, methods and lambdas. I +1'd for taking the time to to it as expected, but the manner here seems a bit invalid. \$\endgroup\$ Commented Jun 15, 2018 at 12:07
  • \$\begingroup\$ @OlivierGrégoire Hmm, I thought class-level fields were allowed, as long as you don't set them on class-level (the function need to be run multiple times without resetting anything to be self-contained). Which is why I have the i=-1 inside the lambda. But maybe I'm incorrect and it isn't allowed according to the meta? EDIT: Something similar is done pretty often in C answers. \$\endgroup\$ Commented Jun 15, 2018 at 12:15
  • \$\begingroup\$ I don't know. That's why I used the word "seems". But that'd be a derived way to instanciate primitive values to their default, having significant impact for a lot of golfing answer. For instance: int i;f->{for(;i++<10;)print(i);} is 1 byte shorter than f->{for(int i=0;i++<10;)print(i);}. \$\endgroup\$ Commented Jun 15, 2018 at 12:23
  • \$\begingroup\$ @OlivierGrégoire That's why I stated the i=-1 is inside the lambda function. Your example doesn't work if you run the same lambda twice, mine does, which is the key difference here. int i;f->{for(i=0;i++<10;)print(i);} would be allowed for example (although not really shorter). \$\endgroup\$ Commented Jun 15, 2018 at 12:30
6
\$\begingroup\$

Japt v2.0a0 -R, 213 211 210 209 206 193 191 190 188 187 bytes

u f\w Ën36 g`...`ò4)nLõd)¤®Í?FgT°:SÃò5n)ù6ÃÕm¸

Try it or test all characters (the extra bytes are due to TIO not supporting Japt v2)


Explanation

Lookup Table

Every group of 4 characters in the backtick enclosed string (represented by ... above to save space and because it contains a bunch of unprintables) is the binary representation of each character (0 for spaces, 1 for characters) with the newlines removed and converted to base-100.

Example

ZZZZZ -> 11111
   Z  -> 00010
  Z   -> 00100 -> 1111100010001000100011111 -> 32575775 -> !::L
 Z    -> 01000
ZZZZZ -> 11111

The Code

u f\w Ën36 g`...`ò4)nLõd)¤®Í?FgT°:SÃò5n)ù6ÃÕm¸     :Implicit input of string U
u                                                  :Uppercase
  f                                                :Match
   \w                                              :  RegEx /[a-z0-9]/gi
      Ë                                            :Map each D in array F
       n36                                         :  Convert D from base-36 to decimal
           g                                       :  Index into
            `...`                                  :    The string described above
                 ò4                                :    Partitions of length 4
                   )                               :  End Indexing
                    n                              :  Convert from base
                     Lõ                            :    Range [1,100]
                       d                           :    Get characters at those codepoints
                        )                          :  End base conversion
                         ¤                         :  Convert to binary
                          ®                        :  Map
                           Í                       :    Convert from binary to decimal
                            ?                      :    If truthy (i.e, 1)
                             Fg                    :      Get the element in F at index
                               T°                  :        T (initially 0) postfix incremented
                                 :                 :    Else
                                  S                :      Space
                                   Ã               :  End map
                                    ò              :  Partitions of length
                                     5n            :    -5 (i.e., weighted towards the end)
                                       )           :  End partition
                                        ù6         :  Left pad each with spaces to length 6
                                          Ã        :End map
                                           Õ       :Transpose
                                            m      :Map
                                             ¸     :  Join with spaces
                                                   :Implicit output joined with newlines
\$\endgroup\$
4
\$\begingroup\$

Ruby, 366 bytes

->s{s.tr!('^0-9A-Za-z','');b=([s]*s.size).map(&:chars);%w(esuu6vfveeeufuvvfhvvhghheucufvhhhhhv j411agg1hhhhghgggh44igrphhihg4hhhaa2 l4e7vuu2efvughssjv44sgllhumue4hal444 p4g121h4h1hhghgghh44ighjhgii14hara48 evvu2ue8euhufuvgfhvohvhhegdhu4e4hh4v).map{|x|w=t='';s.chars{|c|c=~/\w/&&w+="%5b  "%x[c.to_i 36].to_i(36)};w.size.times{|i|t+=w[i]>?0?b[i/7].rotate![-1]:' '};t}}

Try it online!

This can be golfed a lot, but now I've run out of time and ideas. It was harder than I first thought just to get it working.

How it works:

It's not so hard to understand, I'll just explain how the alphabet is coded with an example. Every line of every character is converted to binary and then to base-36.

 AAA   -> 01110 -> E
A   A  -> 10001 -> H
AAAAA  -> 11111 -> V
A   A  -> 10001 -> H
A   A  -> 10001 -> H

The first step is stripping all non-alphanumeric characters from the input string.

Then I generate a lookup table for the final rendering, because I want to print line for line.

After that, iterating on the alphabet line, I create the binary pattern of the letters.

Finally I replace 0 with spaces and 1 with characters from the lookup table.

Feel free to golf further, I know this could be 20-30 bytes shorter (using gsub instead of tr, and so on), but I'm not interested now, unless I can make the alphabet table drastically smaller.

\$\endgroup\$
4
\$\begingroup\$

Charcoal, 172 164 bytes

≔⁺⭆χιαα≔Φ↥S№αιθFθ«E⁵⭆§⪪”)∧%"<⁰ETV´el⟧2[◧À&η²p.±‹§K×GR←∨�X¶⌈hF)ξυ9DUuqε↘Z)s⎚H⊙←<¿.&]~b≧✂⪪XïJ61%ZWm/ειK⮌λ﹪▷(σΠNc←º✳Fb⌕⊘¹ÞEpM&➙δl◨α↑j≕ςL¡ρG⁰/y”⁵⁺κ×⁵⌕αι⎇Iμ§θ⊖L⊞Oυω M⁷±⁵

Try it online! Link is to verbose version of code. Explanation:

≔⁺⭆χιαα

Prefix the digits to the predefined uppercase alphabet.

≔Φ↥S№αιθ

Uppercase the input and filter out all the unsupported characters.

Fθ«

Loop over the remaining characters.

E⁵

Loop over each row, implicitly printing each result on its own line.

⭆§⪪”...”⁵⁺κ×⁵⌕αι

The compressed string is @ovs's large integer constant, converted to binary and reversed. It is then sliced into 180 substrings of 5 characters, and the relevant substring for the current character and row is then looped over.

⎇Iμ§θ⊖L⊞Oυω 

If the bit was set then cyclically print the next character of the filtered input otherwise print a space.

M⁷±⁵

Position the cursor ready to print the next character.

\$\endgroup\$
3
\$\begingroup\$

Perl 5 with -nlaF/[^A-Za-z0-9]+|/, 247 bytes

@l{0..9,A..Z}=unpack("b*",q&....!.?.......G...../.......\....c|...C......'..N.>..c.1~B......I1..~.5.8k....^|!...}.......BH.1..."1..."*FE.....&)=~/.{25}/g;eval'$;[$j%5].=($l{+uc}=~/.{5}/g)[$j++%5]=~s/./$&?uc$F[$i++%@F]:$"/ger.$"x2;'x5for@F;say for@

Try it online!


Explanation

First a lookup table is created in %l using the packed data. This data is a 900-bit binary string of each char packed as a 25-bit binary string (stored as 113 bytes - only 1 more byte than charcoal!), similar to some other answers, so A is:

 AAA 
A   A
AAAAA
A   A
A   A

which, using 0 for space and 1 for A is:

01110
10001
11111
10001
10001

and without the line breaks is:

0111010001111111000110001

Once the lookup is initialised, we iterate over each valid char in @F (which is populated using Perl's -autosplit option) appending to each of the 5 elements of the list @; for each row in the array from the lookup, replacing all 1s with uc$F[$i++%@F] which is the $ith character (modulo @F which is the length of @F) converted to uppercase, and all 0s with $" which defaults to space. Once each index in @; is populated for each character in @F, say prints each line with a trailing newline.

Note: the string after unpack contains unprintables which are escaped using \xXX notation. Verification for score of 247.

\$\endgroup\$
3
\$\begingroup\$

SOGL V0.12, 165 164 163 bytes

⁰CīøDs8↓3‛⁸⁷ω8<t↑\≈⅓dPb¦l═│ƹč<⁷i3ζ°@Ο≠ΖηKπ⁴Φd←⅔Ωī$∞ΧΗf▼xƧqWƨ∑ģpc!ƨ@┐Γ<§5ΛMn«Ιq;⁾№╔1xdψBN≤⁴ζ8□\b╗³╤>↔²Μ±}H}≤╬bφIæ7“2─{rƧ- W}⁰∑M¼nEU{SUZ+;W:?ew;cF+C}X}⁰┌cŗā;{√┼@L*┼

Try it Here!

Explanation:

...“                 big long number of the character data
    2─               convert to a base 2 string
      {r    }        for each number in it
        Ƨ- W           get it's index in "- ": space for 0, dash for 1
             ⁰∑      join up the results
               M¼n   split into groups of 25 - the letters
                  E  save that in variable E

U{                 }⁰ map over the input uppercased
  SUZ+                  push 1234567890 + the alphabet
      ;W                get the current characters index in that string
        :?       }      duplicate, if not 0 (aka if found)
          e               push the variable E
           w              get in it the duplicated number'th item
                            this leavesleaving the array below the item
            ;             get the array ontop
             cF+C         append the character to the array C
                  X     and remove the top item - either the duplicate or the array

┌             push "-"
 c            load the variable C
  ŗ           cycically replace "-" in maps result with the characters of C
   ā          push an empty array - the output
    ;{        for each item in the result of the replacement
      √         squareify it
       ┼        and append that to the output array
        @L*┼    top-to-bottom, left-to-right add 10 spaces to the array
\$\endgroup\$
2
\$\begingroup\$

JavaScript (Node.js), 365 347 bytes

Saved 1 byte thanks to @Scoots

Returns an array of 5 strings. Includes a leading space on each row.

37 36 bytes are lost in converting everything to uppercase and matching [A-Z0-9] :-/

a=>(a=a.toUpperCase(s=[...'     ']).match(/[A-Z\d]/g)).map(x=c=>(g=n=>n<35&&g(n+1,s[n<25?n/5|0:n%5]+=Buffer("mJ*Z?<^#?.&+o@V+`L7ho=Jkm?`:Tm)Km?ZZo@p*#MmjoCZ[=('ZoC#;?-g[RZW[>.cJ#Mmm?<^;Vp5[#p*]?,iM#KAm$$:Mm?0*R[#;-46B#qC;o==*X$(km?0-XDc=$.Mm#%]=X$*-?1M[".slice(parseInt(c,36)*(i=v=4))).map(c=>v+=c%80*80**--i)|v>>n&n<25?a[++x]||a[x=0]:' '))(0))&&s

Try it online!

Character encoding

Characters are encoded upside-down and converted to a custom base-80 with an offset of 4, using the ASCII range [35..114].

Values 35 to 79 are directly mapped to the corresponding ASCII character, while values 0 to 34 are mapped to characters 80 to 114. This allows to decode by just taking the ASCII code modulo 80.

For instance, 'F' is encoded as "RZW[":

....#     00001
....#     00001
..### --> 00111 --> 0000100001001110000111111 --[decimal]--> 1088575 --[-4]--> 1088571
....#     00001
#####     11111

floor(1088571 / 80**3)        = 2    --> (( 2 + 45) mod 80) + 35 = 82  --> 'R'
floor(1088571 / 80**2) mod 80 = 10   --> ((10 + 45) mod 80) + 35 = 90  --> 'Z'
floor(1088571 / 80)    mod 80 = 7    --> (( 7 + 45) mod 80) + 35 = 87  --> 'W'
1088571                mod 80 = 11   --> ((11 + 45) mod 80) + 35 = 91  --> '['

Starting with i = v = 4, it is decoded back to a 25-bit integer by doing:

Buffer("RZW[").map(c => v += c % 80 * 80 ** --i)

In the full code, we actually process an unbounded slice() of the encoded stream, which means that we are likely to iterate significantly more than 4 times. This is not a problem because all iterations with i < 0 will only affect the decimal part of the result, which is ignored anyway by the bitwise operations that immediately follow.

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Can you replace toUpperCase with the i flag in the RegEx? \$\endgroup\$
    – Shaggy
    Commented Jun 15, 2018 at 11:11
  • \$\begingroup\$ @Shaggy That would let the lowercase characters unchanged in the output, which I think is not allowed. \$\endgroup\$
    – Arnauld
    Commented Jun 15, 2018 at 11:13
  • \$\begingroup\$ Ah, looks like you're right, I'd missed that. Best update my own solution! \$\endgroup\$
    – Shaggy
    Commented Jun 15, 2018 at 11:15
  • 1
    \$\begingroup\$ Could you save a byte by matching [A-Z\d] instead of [A-Z0-9]? \$\endgroup\$
    – Scoots
    Commented Jun 15, 2018 at 11:43
1
\$\begingroup\$

C (gcc), 792 690 bytes

#define S strlen
#define V v[1][i]
#define A putchar(32);
#define F(x)(((G(x,0)*92+G(x,1))*92+G(x,2))*92+G(x,3))*92+G(x,4))
#define G(x,y)(f[(x-(x<58?48:55))*5+y]-35)
i,j,l;main(c,v)char**v;{l=S(v[c=1]);char*x[l],t[l+1],*p=t,*f="$dKqK&>%Q3&R`ms&RYXg#gAB/&b_R/$n>Pw&]?vO$cbu+$ccG#$csC+&X7sS$n0w[&X+={&b^%s&b^$W$n3qS%(4\\_&^Bjg&^Bj/%(Pec$xx%S%+L`/%*jjw$cel7&X7oS$NWLO&X7u3$n.U+&^BhG%(')k%'|*/%(+:'%%UO;%%U=K&]`{+";*x=t;for(;i<l;i++){V>96?V-=32:V;(V>47)&(V<58)|(V>64)&(V<91)?*(p++)=V:V;}*p=0;for(;c<S(t);)x[c++]=((__builtin_popcount(F(t[c-1])+x[c-1]-t)%S(t))+t;for(c=6;--c;){for(i=0;i<S(t);i++){for(j=5,l=1<<c*5+3;j--;)if((l>>=1)&F(t[i]){putchar(*x[i]++);!*x[i]?x[i]=t:x;}else A A A}puts(p);}}

Try it online!

Managed to squeeze this under 800 with some variable reuse. Opted to store the font as an array of ints, as although storing it as one long string looked like an attractive idea so many of the 8-bit chunks of the font weren't a nice convenient ASCII character that the escape codes were taking up more characters than the int array did.

Edit: Got under 700 by switching to a string encoding after all - somewhat inspired by many of the other responses here I cobbled together a base-92 representation using (most of) the printable ASCII characters. The representation does include backslashes which need an extra to be escaped but that only happens once in the font.

Other than that there isn't much that's too flashy going on - the input (consisting of the first command-line argument) is copied into a stack array, minus any characters that aren't in the font and with lowercase letters replaced with their uppercase versions, what "pixel" character each full letter starts on is computed (using __builtin_popcount has a painfully long name but was still better than any method of counting on bits I could think of), and then the printing goes through line by line. The compiler of course outputs several times the program length in warnings.

Somewhat degolfed below for your viewing pleasure:

//The defines are listed here for reference. Some are replaced in the below code but I still use F() because it's long.
#define S strlen
#define V v[1][i]
#define A putchar(32);
#define F(x)(((G(x,0)*92+G(x,1))*92+G(x,2))*92+G(x,3))*92+G(x,4))  //How to lookup a font character given an input char x
#define G(x,y)(f[(x-(x<58?48:55))*5+y]-35)                         //Used for looking up the individual parts of a character font
i, j, l;                                           // Declaring some int variables for later use.
main(c,v) char**v; {                               // Declaring afterwards lets us have the int arg default without declaring it
  l = strlen(v[c=1]);                              // Using l as a local variable to shorten S(v[1]) and also giving c an initial value here where there was a spare 1, saving a character over writing the full c=1 init in a later for loop.
  char t[l+1], *p=t, *x[l];                        // Declaring char arrays and char*s and char* arrays. t is oversized if there are any invalid characters in the input, but that's not important for golfing.
  char *f="$dKqK&>%Q3&R`ms&RYXg#gAB/&b_R/$n>Pw&]?vO$cbu+$ccG#$csC+&X7sS$n0w[&X+={&b^%s&b^$W$n3qS%(4\\_&^Bjg&^Bj/%(Pec$xx%S%+L`/%*jjw$cel7&X7oS$NWLO&X7u3$n.U+&^BhG%(')k%'|*/%(+:'%%UO;%%U=K&]`{+";      // The font, encoded base-92 with 5 characters to a letter in the order 0123456789ABCDEF... etc.
  *x=t;                                            // The first character's "pixels" will start at the beginning of the valid input.
  for(; i<strlen(l); i++){                         // Speaking of which, now validate the input.
    v[1][i] > 96 ? v[1][i] -= 32 : v[1][i];        // Change lowercase characters to uppercase. If they aren't actually lowercase characters but have ascii value >96, they won't end up valid after this either and will be edited out on the next line. The false case does nothing, but since with the macro it is one character using the ternary operator saves a character over an if statement even though that case ends up redundant.
    (v[1][i]>47)&(v[1][i]<58)|(v[1][i]>64)&(v[1][i]<91)?*(p++)=v[1][i]:v[1][i];        // If the character is now either a numeral or an uppercase letter, set the next spot in the t array by way of the pointer p and then increment said pointer. 
  }
  *p=0;                                            // Add the null terminator to the t array, our validated input string.
  for(;c<strlen(t);) {                             // Now find out at what index each letter should start getting "pixels" from.
    x[c++] = ((__builtin_popcount(F(t[c-1])+x[c-1]-t)%strlen(t))+t;          // Use the builtin to get the number of on bits/pixels in the previous letter, then add that to the previous letter's starting pixel and take the modulus strlen() of the valid string.
  }
  for(c=6; --c;){                                  // Now start the actual printing. For each line...
    for(i=0; i<strlen(t); i++){                    // For each letter...
      for(j=5, l=1<<c*5+3; j--;) {                 // For each pixel of the 5 on this line...
        if((l>>=1) & F(t[i]) {                     // If it is on...
          putchar(*x[i]++);                        // Print it and increment the pixel-fetching pointer for this letter.
          !*x[i]?x[i]=t:x;                         // If said pointer hit the end of the valid input go back to the beginning.
        } else {
          putchar(32);                             // If it is an off pixel, print a space.
        }
      }
      putchar(32);                                 // After a letter, print two spaces.
      putchar(32);
    }
    puts(p);                                       // This is the cheapest way in character count I could come up with to output a newline. p currently points to the end of t, so it is an empty string and puts just adds a newline.
  }
}
\$\endgroup\$
1
1
\$\begingroup\$

Excel VBA, 816 bytes

An anonymous VBE immediate window function that takes input from range [A1] and outputs to the console.

As far as I am aware, this is the first VBA answer to use base64 compression.

For i=1To[Len(A1)]:c=Mid(UCase([A1]),i,1):y=y &IIf(c Like"[0-9A-Z]",c,""):Next:l=Len(y):Set d=New MSXML2.DOMDocument:Set d=d.createElement("b64"):d.DataType="bin.base64":d.Text="HxHxCSEqRkVUjLvGSJSK0cUYIyGEfB8cfFH66Ju0kkHoo3cxRhdnzTHGuuOHEMIouYyYEPI/IeTH+GN8ccIHIYf/Qw6/jzH6ByF8PvroY/zR+fCic9FFh4gI30UPnw8efiG+Mj6c4D90wX9CCHe5Tgc=":b=d.nodeTypedValue:For i=0To 112:k=Right("00000" &Evaluate("=Dec2Bin("&b(i)&")"),8)&k:Next:For i=1To 5:For j=1To l:c=UCase(Mid(y,j,1)):Z=c Like"[0-9]":s=s &IIf(c Like"[A-Z]",Mid(k,IIf(Z,1,25*(Asc(c)-55)+5*i),5)&" ",IIf(Z,Mid(k,25*(Asc(c)-48)+5*i,5)&" ","")):Next:s=Replace(Replace(s,0," "),1,"#") &vbLf:Next:Do:i=InStr(1+(g*l+h)*6+g,s,"#"):p=(p-e)Mod l:e=i<(g*l+h+1)*6+g:s=IIf(e,Left(s,i-1)&Replace(s,"#",Mid(y,p+1,1),i,1),s):g=g-(0=e):h=h-(g>4):g=g Mod 5:Loop While InStr(1,s,"#"):?s

Note: This answer depends on the Microsoft XML, v3.0 VBA reference

Example I/O

[A1]="'0123456789"
For i=1To[Len(A1)]:c=Mid(UCase([A1]),i,1):y=y &IIf(c Like"[0-9A-Z]",c,""):Next:l=Len(y):Set d=New MSXML2.DOMDocument:Set d=d.createElement("b64"):d.DataType="bin.base64":d.Text="HxHxCSEqRkVUjLvGSJSK0cUYIyGEfB8cfFH66Ju0kkHoo3cxRhdnzTHGuuOHEMIouYyYEPI/IeTH+GN8ccIHIYf/Qw6/jzH6ByF8PvroY/zR+fCic9FFh4gI30UPnw8efiG+Mj6c4D90wX9CCHe5Tgc=":b=d.nodeTypedValue:For i=0To 112:k=Right("00000" &Evaluate("=Dec2Bin("&b(i)&")"),8)&k:Next:For i=1To 5:For j=1To l:c=UCase(Mid(y,j,1)):Z=c Like"[0-9]":s=s &IIf(c Like"[A-Z]",Mid(k,IIf(Z,1,25*(Asc(c)-55)+5*i),5)&" ",IIf(Z,Mid(k,25*(Asc(c)-48)+5*i,5)&" ","")):Next:s=Replace(Replace(s,0," "),1,"#") &vbLf:Next:Do:i=InStr(1+(g*l+h)*6+g,s,"#"):p=(p-e)Mod l:e=i<(g*l+h+1)*6+g:s=IIf(e,Left(s,i-1)&Replace(s,"#",Mid(y,p+1,1),i,1),s):g=g-(0=e):h=h-(g>4):g=g Mod 5:Loop While i<InStrRev(s,"#"):?s
 012  567   6789  0123    34  45678  9012 34567  234   567  
3  45   8       0     4  5 6  9     3         8 5   6 8   9 
6 7 8   9    123    567 78901 0123  4567     9   789   0123 
90  1   0   4         8    2      4 8   9   0   0   1     4 
 234  12345 56789 9012     3  5678   012   1     234  5678

Ungolfed and Explained

The major part of this solution storing the large font as a base 64 string. This is done by first converting the font to binary, where 1 represents an on pixel and 0 represents an off pixel. For example, for 0, this is represented as

      ###     01110
     #  ##    10011
0 -> # # # -> 10101 --> 0111010011101011100101110
     ##  #    11001
      ###     01110

With this approach, the alphanumerics can then be represented as

0: 0111010011101011100101110    1: 1110000100001000010011111
2: 1111000001011101000011111    3: 1111000001001110000111110
4: 0011001010111110001000010    5: 1111110000111100000111110
6: 0111110000111101000101110    7: 1111100001000100010001000
8: 0111010001011101000101110    9: 0111010001011110000111110
A: 0111010001111111000110001    B: 1111010001111101000111110
C: 0111110000100001000001111    D: 1111010001100011000111110
E: 1111110000111001000011111    F: 1111110000111001000010000
G: 0111110000100111000101111    H: 1000110001111111000110001
I: 1111100100001000010011111    J: 1111100100001000010011000
K: 1000110010111001001010001    L: 1000010000100001000011111
M: 1000111011101011000110001    N: 1000111001101011001110001
O: 0111010001100011000101110    P: 1111010001111101000010000
Q: 0110010010101101001001101    R: 1111010001111101001010001
S: 0111110000011100000111110    T: 1111100100001000010000100
U: 1000110001100011000101110    V: 1000110001010100101000100
W: 1000110001101011101110001    X: 1000101010001000101010001
Y: 1000101010001000010000100    Z: 1111100010001000100011111

These segments were concatenated and converted to MSXML base 64, rendering

HxHxCSEqRkVUjLvGSJSK0cUYIyGEfB8cfFH66Ju0kkHoo3cxRhdnzTHGuuOHEMIouYyYEPI/IeTH+GN8ccIHIYf/Qw6/jzH6ByF8PvroY/zR+fCic9FFh4gI30UPnw8efiG+Mj6c4D90wX9CCHe5Tgc=

The subroutine below takes this, back converts to binary, and uses this a reference from which to build an output string, line by line, grabbing first the top 5 pixels of each character, then the second row and so on until the string is constructed.

The subroutine then iterates over the output string and replaces the 'on' pixels with characters from the input string.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
''  Embiggen Function
''
''  @Title  :   Embiggen
''  @Author :   Taylor Scott
''  @Date   :   15 June 2018
''  @Desc   :   Function that takes input, value, and outputs a string in which
''              value has been filtered to alphnumerics only, each char is then
''              scaled up to a 5x5 ASCII art, and each 'pixel' is replaced with
''              a char from value. Replacement occurs letter by letter, line by
''              line
''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function EMBIGGEN(ByVal value As String) As String
    
    Dim DOM         As New MSXML2.DOMDocument, _
        bytes()     As Byte
    
    Dim isNum       As Boolean, _
        found       As Boolean, _
        index       As Integer, _
        length      As Integer, _
        line        As Integer, _
        letter      As Integer, _
        pos         As Integer, _
        alphanum    As String, _
        char        As String, _
        filValue    As String, _
        outValue    As String
        
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Filter input
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    For letter = 1 To Len(value) Step 1             ''  Iterate Accross `Value`
        Let char = Mid$(UCase(value), letter, 1)    ''  Take the nth char
        ''  If the char is alphnumeric, append it to a filtered input string
        Let filValue = filValue & IIf(char Like "[0-9A-Z]", char, "")
    Next letter
    Let length = Len(filValue)                      ''  store length of filValue
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Convert Constant from Base 64 to Byte Array
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    With DOM.createElement("b64")           ''  Construct b64 DOM object
        Let .DataType = "bin.base64"        ''  define type of object`
        ''  Input constructed constant string shown above
        Let .Text = "HxHxCSEqRkVUjLvGSJSK0cUYIyGEfB8cfFH66Ju0kkHoo3cxRhdnz" & _
                     "THGuuOHEMIouYyYEPI/IeTH+GN8ccIHIYf/Qw6/jzH6ByF8PvroY/" & _
                     "zR+fCic9FFh4gI30UPnw8efiG+Mj6c4D90wX9CCHe5Tgc="
        Let bytes = .nodeTypedValue         ''  Pass resulting bytes to array
    End With
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Convert Byte Array to Byte String
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    For index = 0 To 112 Step 1
        '' convert each byte to binary, fill left with `0`s and prepend
        Let alphanum = _
            Right("00000" & Evaluate("=Dec2Bin(" & bytes(index) & ")"), 8) & _
            alphanum
    Next index
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Construct Embiggened Binary String of Input Value
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    For line = 1 To 5 Step 1                ''  iterate across lines
        For letter = 1 To length Step 1     ''  iterate across letters
            ''  take the corresponding letter from
            Let char = UCase(Mid(filValue, letter, 1))
            If char Like "[0-9]" Then       '' if it is a number,
                ''  Add the 5 bit corresponding to number at line
                Let outValue = outValue & _
                    Mid$(alphanum, 25 * Val(char) + 5 * line, 5) & " "
            ElseIf char Like "[A-Z]" Then   '' if it is a letter,
                ''  Add the 5 bits corresponding to letter at line
                Let outValue = outValue & _
                    Mid$(alphanum, 25 * (Asc(char) - 55) + 5 * line, 5) & " "
            End If
            Next letter
        Let outValue = outValue & IIf(line < 5, vbLf, "")
    Next line
    Let outValue = Replace(Replace(outValue, 0, " "), 1, "#")
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Replace #s with Input Value
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Let pos = 0                             ''  Reset position in filValue
    Let line = 0                            ''  Reset line index
    Let letter = 0                          ''  Reset letter index
    Do
        ''  Find the index of the first `#` starting at line and letter
        Let index = _
            InStr(1 + (line * length + letter) * 6 + line, outValue, "#")
        ''  Iterate position in filValue if a `#` is found in that letter & line
        Let pos = (pos - found) Mod length
        ''  check to see if found index is in the correct letter
        Let found = index < (line * length + letter + 1) * 6 + line
        ''  iff so, replace that # with letter in filValue corresponding to pos
        Let outValue = IIf(found, _
            Left(outValue, index - 1) & _
                Replace(outValue, "#", Mid(filValue, pos + 1, 1), index, 1), _
            outValue)
        ''  if not found, them iterate line
        Let line = line - (found = False)
        ''  iterate letter every five iterations of line
        Let letter = letter - (line > 4)
        ''  Ensure that line between 0 and 4 (inc)
        Let line = line Mod 5
    ''  Loop while there are '#'s in outValue
    Loop While InStr(1, outValue, "#")

    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Output
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Let EMBIGGEN = outValue
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''
    ''  Clean Up
    ''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Set DOM = Nothoing
End Function
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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