Incorpora il tuo contributo


19

Questo è un po 'simile a questa voce coperta di polvere, ma spero che il mio giro su di esso lo renda abbastanza unico. Non sono riuscito a trovare nulla che mi dissuada dal pubblicare questo, ma c'è abbastanza mare là fuori.

Comunque! La sfida:

Il tuo codice riceve una stringa di caratteri; Lo converte in una versione in stile ASCII della stessa stringa, ma con un fermo.

Trasformazione dell'input

  • Gli unici caratteri da supportare sono AZ e 0-9
  • Le lettere minuscole vengono trasformate in maiuscolo
  • Tutto il resto viene rimosso silenziosamente

Disegno del personaggio

  • Ogni "pixel" del carattere ingrandito viene disegnato dalla stringa di input
  • L'ennesimo pixel è uguale all'ennesimo carattere nella stringa di input. Se n è maggiore della lunghezza della stringa di input, tornare all'inizio
  • Le singole lettere sono disegnate da sinistra a destra, dall'alto verso il basso
  • Le lettere successive raccolgono il loro indice di "carattere pixel" da dove era stata interrotta l'ultima lettera (ad es. Con una lunghezza di input di 10, se la prima lettera aveva 9 pixel, il primo pixel della seconda lettera verrà disegnato con il decimo carattere di input, il secondo il pixel verrà disegnato con il primo carattere di input)
  • Ogni lettera è disegnata in una griglia 5x5, completamente imbottita con spazi. Puoi trovare il font che devi usare pre-renderizzato per te in questo pastebin o un po 'più in basso in questo post
  • Ogni lettera viene disegnata sulla stessa riga, quindi il numero totale di interruzioni di riga nell'output sarà 4
  • Ogni lettera è separata da 2 colonne di spazi

Il carattere

 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

Sì, so che il 4 e il Q sono brutti

Un esempio

Ingresso

0123456789

Produzione

 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 

Un altro esempio

Ingresso

a3 B'2

Produzione

 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

Sono vietate le scappatoie standard . Codice golf, quindi non verrà dato un segno di spunta verde.


17
Suggerirei di garantire che l'input contenga solo[A-Z\d] - non credo che il filtraggio di caratteri non validi aggiunga qualcosa alla sfida.
Shaggy,

3
@Shaggy Forse. Ma per lo stesso motivo non credo che rimuova nulla dalla sfida
Scoots



2
Che dire di TRE spazi principali? Sicuramente non lo permetterete!
Magic Octopus Urn,

Risposte:


16

Python 2 , 413 411 373 364 352 345 byte

-1 byte grazie a Kevin Cruijssen .
-9 byte grazie a Jo King .
-1 byte grazie a Lynn .

La stringa di dati contiene la versione non stampabile, con escape di seguito.

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()

Provalo online!

Poiché ogni carattere ha 25 pixel, può essere facilmente codificato in 25 bit. Il numero 126 di base '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'codifica per tutti i caratteri, il 0è codificato dai 25 bit meno significativi, il 1dai 25 bit successivi e il Zè codificato dai 25 bit più significativi. Un singolo carattere è codificato nel seguente ordine:

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è il bit meno significativo, 25il più significativo)

Gli spazi sono codificati da uno zero, i non spazi da uno. Esempio :

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

Provalo online!


Le lettere dovrebbero essere separate da due spazi, quindi +' 'dovrebbe essere +' '. Bella risposta a prescindere, quindi +1 da parte mia.
Kevin Cruijssen,

hai bisogno di .upper()qualcosa da qualche parte, altrimenti le lettere interne finiscono in minuscolo
Jo King il

@JoKing Hai ragione, risolto.
Ovs,

Adoro questo trucco di codifica. Hai scelto la base 92 perché questa è la più grande codifica standard composta da ascii stampabili? potresti essere andato più in alto? anche io ho cercato su Google ma non sono stato in grado di mettere a punto le informazioni sulla base 92 - hai un link?
Giona

@Jonah Non esiste uno standard come la codifica base 92, ecco perché ho implementato la mia logica di decodifica. Finché hai abbastanza cifre distinte, puoi usare qualsiasi base >1.
Ovs

10

APL (Dyalog Unicode) , 228 225 224 214 byte

Programma completo. Richiede stdin per stringa. Stampa su stdout. Circa la metà del codice sta semplicemente decodificando l'alfabeto codificato.

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

__Rappresenta la seguente stringa codificata LZ4 a 143 byte tra virgolette:"⊥\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ááЀ€€€€€€"

Provalo online!

__ Stringa codificata LZ4 a 143 byte tra virgolette

⎕AV⍳ɩ ndices di che nella A Tomic V ector (set di caratteri)

¯125+ aggiungi -125 a quello (per ottenere numeri interi a 8 bit con segno)

¯1(219⌶) Decompressione LZ4

0(220⌶) deserializzare in un array booleano a 36 strati, 5 righe, 5 colonne

(... )⌷ indicizzalo usando i seguenti indici:

⎕A maiuscolo A lphabet

⎕D,anteporre  le D igits

a← conservare in a(per un alfabeto)

(... )∩ intersezione di quanto segue e quello (rimuove input non validi):

 richiesta di input di testo da stdin (console)

  1(819⌶) piega in maiuscolo ( 819sembra Big, 1 è per sì grande invece che piccolo)

i← conservare in i(per i nput)

a⍳d ndices di quello ina

 racchiudi (per indicizzare con ognuno che rappresenta la coordinata principale)

t← conservare in t(per t ext)

, corvo (appiattire)

r← negozio a r(per r avelled)

+/ somma quello (cioè il numero di caratteri necessari per dipingere il disegno)

i⍴⍨ciclicamente r eshape l'ingresso a quella lunghezza

r\ espandere quello; inserire uno spazio a 0 secondi, consumare lettere a 1 secondo

(...) ⍴` rimodellare nella seguente forma:

⍴t la forma del testo

 dividere l'array N-by-5-by5 in una matrice N-by-5 ​​di linee d'arte

trasporre in una matrice 5 per N di linee d'arte (allinea le linee corrispondenti dei personaggi)

Per impostazione predefinita, APL separa elementi semplici di un array nidificato con 2 spazi.


Non proprio! Ci devono essere 2 spazi tra ogni lettera
Scoots

1
@Scoots OK, risolto.
Adám,

@Adám c'è qualcosa che non va in C e D
ngn

9

Python 2 , 428 byte

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)

Provalo online!


Le lettere sono codificate come segue:

Ogni parte unica (ce ne sono 23) viene convertita in binario e un 1 viene aggiunto in primo piano. Quindi viene convertito in base 36.

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

I numeri base-36 risultanti sono:

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

L'iniziale 1viene rimossa, quindi abbiamo un singolo carattere:

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

Ogni lettera ( A-Z0-9) viene quindi codificata in cinque di questi nuovi caratteri.

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

In cinque elenchi:

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

Per mappare l'input su un indice in questi elenchi, l'ordinale è modificato:

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

Poiché gli ordinali non sono 0-35, ma leggermente misti, le 5 liste vengono riorganizzate e concatenate:

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

Per ogni carattere nell'input, vengono trovate 5 lettere e convertite in un 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

Se il numero è inferiore 30, 36viene aggiunto (quello mancante che 1abbiamo rimosso in precedenza)

n+36*(n<30)

Quindi il numero viene riconvertito in binario e 0s e 1s vengono convertiti in e .. Durante la conversione vengono aggiunti due spazi alla fine.

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

Per esempio.

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

Per ognuno .nel risultato, viene sostituito dal carattere successivo dall'input (ripetuto da x)

while'.'in`R`:R=eval(`R`.replace('.',x[0],1));x=x[1:]+s

Bello! Potrei disturbarti per una spiegazione di come funziona? Al momento, questa è magia ai miei occhi.
Scoots

@Scoots On it! :)
TFeld

3
Grazie per averlo aggiunto :) L'intelligenza che vedo nelle risposte su questo sito non manca mai di impressionarmi
Scoots

Poiché le parti sono 5 bit, perché non utilizzare invece la base 32?
Neil,

6

Java 8, 917 907 byte

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]:" ";}

Lo golfò da qui per almeno dimezzare l'attuale numero di byte, si spera.

Provalo online.

Spiegazione:

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

Sembra che tu non abbia un esempio autonomo. Campi di classe, metodi e lambda. Ho fatto +1 per averci dedicato il tempo previsto, ma il modo qui sembra un po 'invalido.
Olivier Grégoire,

@ OlivierGrégoire Hmm, ho pensato che i campi a livello di classe fossero consentiti, purché non li impostassi a livello di classe (la funzione deve essere eseguita più volte senza ripristinare nulla per essere autonoma). Ecco perché ho l' i=-1interno della lambda. Ma forse sono errato e non è consentito secondo il meta? EDIT: Qualcosa di simile viene fatto abbastanza spesso nelle risposte C.
Kevin Cruijssen,

Non lo so. Ecco perché ho usato la parola "sembra". Ma quello sarebbe un modo derivato per instanciare i valori primitivi al loro default, avendo un impatto significativo per molte risposte di golf. Ad esempio: int i;f->{for(;i++<10;)print(i);}è 1 byte più corto di f->{for(int i=0;i++<10;)print(i);}.
Olivier Grégoire,

@ OlivierGrégoire Ecco perché ho affermato che i=-1è all'interno della funzione lambda. Il tuo esempio non funziona se esegui lo stesso lambda due volte, il mio lo fa, che è la differenza chiave qui. int i;f->{for(i=0;i++<10;)print(i);}sarebbe consentito ad esempio (anche se non molto più corto).
Kevin Cruijssen,

5

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

Include uno spazio iniziale su ogni riga.

uf \ w
£ `...` ò4 gXn36) nLõd) ¤r0S r1 @ gT ° Ãò5n) ù6Ãy m¸

Provalo o testa tutti i caratteri (i byte extra sono dovuti al fatto che TIO non supporta ancora Japt v2)


Spiegazione

Tabella di ricerca

Ogni gruppo di 4 caratteri nella stringa (rappresentato ...qui per risparmiare spazio e perché contiene un mucchio di non stampabili) è la rappresentazione binaria di ogni carattere ( 0per spazi, 1per caratteri) con le nuove righe rimosse e convertite in base-100.

Esempio

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

Il codice

                                                :Implicit input of string U
u                                               :Uppercase
  f                                             :Get the array of characters matching
   \w                                           : /[a-z0-9]/gi
\n                                              :Reassign to U
£                                               :Map each character as X
 `...`                                          :  The string described above
      ò4                                        :  Split into strings of length 4
          Xn36                                  :  Convert X from base-36 to decimal
         g    )                                 :  Get the element in the array at that index
                Lõ                              :  Range [1,100]
                  d                             :  Get characters at those codepoints
               n   )                            :  Convert from that base to decimal
                    ¤                           :  Convert to binary
                     r0S                        :  Replace all 0s with spaces
                         r1                     :  Replace all 1s
                           @                    :  By passing each match through a function
                             T°                 :    Postfix increment T (initially 0)
                            g                   :    Get the character in U at that index (Yay, index wrapping!)
                               Ã                :  End replacement
                                ò5n)            :  Split into strings of length 5, weighted towards the end
                                    ù6          :  Left pad each with spaces to length 6
                                      Ã         :End mapping
                                       y        :Transpose
                                         m      :Map
                                          ¸     :  Join with spaces
                                                :Implicitly join with newlines and output

4

Rubino , 366 byte

->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}}

Provalo online!

Questo può essere giocato molto a golf, ma ora ho poco tempo e idee. È stato più difficile di quanto pensassi inizialmente solo per farlo funzionare.

Come funziona:

Non è così difficile da capire, spiegherò solo come l'alfabeto è codificato con un esempio. Ogni riga di ogni personaggio viene convertita in binario e quindi in base-36.

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

Il primo passo è rimuovere tutti i caratteri non alfanumerici dalla stringa di input.

Quindi generi una tabella di ricerca per il rendering finale, perché voglio stampare riga per riga.

Successivamente, ripetendo la riga dell'alfabeto, creo il modello binario delle lettere.

Alla fine sostituisco 0 con spazi e 1 con caratteri dalla tabella di ricerca.

Sentiti libero di giocare a golf ulteriormente, so che questo potrebbe essere più corto di 20-30 byte (usando gsub invece di tr, e così via), ma non mi interessa ora, a meno che non riesca a ridurre drasticamente la tabella alfabetica.


4

Carbone , 172 164 byte

≔⁺⭆χιαα≔Φ↥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⁷±⁵

Provalo online! Il collegamento è alla versione dettagliata del codice. Spiegazione:

≔⁺⭆χιαα

Prefisso le cifre con l'alfabeto maiuscolo predefinito.

≔Φ↥S№αιθ

Metti in maiuscolo l'input e filtra tutti i caratteri non supportati.

Fθ«

Scorri i personaggi rimanenti.

E⁵

Scorri su ogni riga, stampando implicitamente ogni risultato sulla sua riga.

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

La stringa compressa è la costante intera grande di @ovs, convertita in binaria e invertita. Viene quindi suddiviso in 180 sottostringhe di 5 caratteri e la sottostringa pertinente per il carattere e la riga correnti viene quindi ripetuta.

⎇Iμ§θ⊖L⊞Oυω 

Se il bit è stato impostato, stampare ciclicamente il carattere successivo dell'input filtrato, altrimenti stampare uno spazio.

M⁷±⁵

Posiziona il cursore pronto per stampare il carattere successivo.


3

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

@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@

Provalo online!


Spiegazione

Innanzitutto viene creata una tabella di ricerca %lutilizzando i packdati ed. Questi dati sono una stringa binaria a 900 bit di ogni carattere impacchettato come una stringa binaria a 25 bit (memorizzata come 113 byte - solo 1 byte in più rispetto al carbone!), Simile ad alcune altre risposte, quindi Aè:

 AAA 
A   A
AAAAA
A   A
A   A

che, usando 0 per spazio e 1per Aè:

01110
10001
11111
10001
10001

e senza le interruzioni di riga è:

0111010001111111000110001

Una volta inizializzata la ricerca, eseguiamo l'iterazione su ogni carattere valido in @F(che viene popolato utilizzando l' -aopzione utosplit di Perl ) accodando a ciascuno dei 5 elementi dell'elenco @;per ogni riga dell'array dalla ricerca, sostituendo tutti i 1s con i uc$F[$i++%@F]quali è il $ith carattere (modulo @Fche è la lunghezza di @F) convertito in upper case e tutto0 s con le $"quali viene impostato di default nello spazio. Una volta @;popolato ciascun indice per ogni personaggio in @F, saystampa ogni riga con una nuova riga finale.

Nota : la stringa after unpackcontiene non stampabili che sono sfuggiti usando la \xXXnotazione. Verifica per punteggio di 247 .


3

SOGL V0.12 , 165 164 163 byte

⁰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*┼

Provalo qui!

Spiegazione:

...“                 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

2

JavaScript (Node.js) , 365 347 byte

Salvato 1 byte grazie a @Scoots

Restituisce un array di 5 stringhe. Include uno spazio iniziale su ogni riga.

37 36 byte vengono persi nel convertire tutto in maiuscolo e la corrispondenza [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

Provalo online!

Codifica dei caratteri

I caratteri vengono codificati sottosopra e convertiti in una base-80 personalizzata con un offset di 4 , utilizzando l'intervallo ASCII [35..114] .

I valori da 35 a 79 sono mappati direttamente al corrispondente carattere ASCII, mentre i valori da 0 a 34 sono associati ai caratteri da 80 a 114 . Ciò consente di decodificare semplicemente prendendo il codice ASCII modulo 80 .

Ad esempio, 'F' è codificato come "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  --> '['

A partire da i = v = 4 , viene decodificato in un intero a 25 bit effettuando:

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

Nel codice completo, in realtà elaboriamo una sezione illimitata () del flusso codificato, il che significa che è probabile che eseguiamo l'iterazione significativamente più di 4 volte. Questo non è un problema perché tutte le iterazioni con i <0 influenzeranno solo la parte decimale del risultato, che viene comunque ignorata dalle operazioni bit a bit che seguono immediatamente.

Provalo online!


È possibile sostituire toUpperCasecon la ibandiera in RegEx?
Shaggy,

@Shaggy Ciò lascerebbe invariati i caratteri minuscoli nell'output, che penso non sia permesso.
Arnauld,

Ah, sembra che tu abbia ragione, me lo ero perso. Migliore aggiornamento della mia soluzione!
Shaggy,

1
Potresti salvare un byte abbinando [A-Z\d]invece di [A-Z0-9]?
Scoots

1

C (gcc) , 792 690 byte

#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);}}

Provalo online!

Riuscito a comprimerlo sotto 800 con un riutilizzo variabile. Ha scelto di archiviare il carattere come una matrice di ints, come se memorizzarlo come una lunga stringa sembrava un'idea attraente così tanti blocchi di 8 bit del carattere non erano un bel carattere ASCII conveniente che i codici di escape stavano prendendo più personaggi diint matrice.

Modifica: Ho ottenuto meno di 700 passando a una codifica stringa dopo tutto - in qualche modo ispirato da molte altre risposte qui ho messo insieme una rappresentazione di base-92 usando (la maggior parte) dei caratteri ASCII stampabili. La rappresentazione include barre rovesciate che necessitano di un extra per essere sfuggite ma ciò accade solo una volta nel carattere.

A parte questo, non c'è molto che sia troppo appariscente: l'input (costituito dal primo argomento della riga di comando) viene copiato in un array di stack, meno tutti i caratteri che non sono nel font e con lettere minuscole sostituite con il loro versioni maiuscole, viene calcolato il carattere "pixel" che inizia ogni lettera intera (usando __builtin_popcount ha un nome penosamente lungo ma era ancora meglio di qualsiasi metodo di contare su bit che potevo pensare), e quindi la stampa passa riga per riga. Il compilatore ovviamente emette più volte la durata del programma negli avvisi.

Abbastanza degolfato di seguito per il tuo piacere di visione:

//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.
  }
}


1

Excel VBA, 816 byte

Una funzione finestra immediata VBE anonima che accetta input dall'intervallo [A1] e output alla console.

Per quanto ne so, questa è la prima risposta VBA da utilizzare base64 compressione.

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

Nota: questa risposta dipende dal Microsoft XML, v3.0riferimento VBA

Esempio 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 e spiegato

La maggior parte di questa soluzione memorizza il carattere di grandi dimensioni come stringa 64 base. Questo viene fatto convertendo prima il carattere in binario, dove 1rappresenta un pixel attivo e 0rappresenta un pixel spento. Ad esempio, per 0, questo è rappresentato come

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

Con questo approccio, gli alfanumerici possono quindi essere rappresentati come

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

Questi segmenti sono stati concatenati e convertiti in MSXML base 64, rendering

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

La subroutine seguente prende questo, indietro converte in binario e usa questo un riferimento da cui costruire una stringa di output, riga per riga, afferrando prima i primi 5 pixel di ciascun carattere, quindi la seconda riga e così via fino a quando la stringa non viene costruita .

La subroutine quindi scorre la stringa di output e sostituisce i pixel "on" con i caratteri della stringa di input.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''
''  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

1

K (ngn / k) , 230 231 byte

(+1 byte dopo una modifica della lingua impl)

f:{{x,'"  ",/:y}/(#s;5;5)#@[(#c)#"";i;:;(#i:&c:,/(36 25#4_,/+2\a)s)#`c$b s:((b:(48+!10),65+!26)?x-32*(96<x)&x<123)^0N]}

Provalo online!

dove a è una stringa tra virgolette che codifica il carattere. K vede le stringhe come sequenze di byte, quindi un programma contenente un tale valore letterale è valido, ma non può essere eseguito su TIO, poiché il suo modulo HTML tenta di interpretarlo come UTF-8 e lo confonde.

Il conteggio dei byte viene calcolato come:

  • 119 riportato da TIO

  • -2 per nominare la funzione f:

  • -1 per il segnaposto a

  • 2 per un paio di virgolette ""

  • 113 per la lunghezza della stringa letterale ache non contiene caratteri che richiedono l'escape

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.