| Bytes | Lang | Time | Link |
|---|---|---|---|
| 192 | JavaScript ES6 | 250526T143424Z | Arnauld |
| 065 | Jelly | 250526T195522Z | Jonathan |
| 241 | Python 3 | 250526T170032Z | jpa |
| 067 | Charcoal | 250526T130709Z | Neil |
| 258 | Ruby | 250526T111137Z | Level Ri |
JavaScript (ES6), 192 bytes
Uses the 12th font without the columns of whitespace.
f=(s,n,S=` 455
7 639
C2+2B
836 A
111 `[R="replace"](/.+/g,s=>(n+"")[R](e=/\w/g,n=>s[R](e,c=>" --/__"[[4061,41,411,795,98,603,2779,28,987,1883][n]>>"0x"+c-1&1&&c]||"|"))))=>s?f(s!=S&&s,-~n):S
Method
The digits in this font can be described with 12 separate parts of one or several characters. They are either on or off. We label them with hexadecimal digits 1 to C. The pattern also includes spaces and a + in the center.
455 ___
7 639 | |/|
C2+2B -> |-+-|
836 A |/| |
111 ---
Labels greater than \$5\$ are reserved for the most common character | so that a lookup table is only needed for the other ones. The order of the labels was otherwise chosen to minimize the size of the bitmasks once converted to decimal (many equivalent solutions exist).
We generate the ASCII-art representation of all numbers from \$1\$ to \$+\infty\$1 until we find the one matching the input, then return the next one.
1: The first iteration actually attempts to render "undefined", leading to a string that doesn't match any valid input.
Jelly, 65 bytes
“®ṇs¢Ị8h⁵ƘPḟẈḊṚÐTḄɓ¡ṇƓ4ḶVṠ:⁶ÐḷKñœ’ṃ“ /|)(\_”s3s3ɓỴZs3iⱮ@Ṗ}Ḍ‘ṃZ€ZY
A full program that accepts a string argument and prints to stdout.
How?
“...’ṃ“ /|)(\_”s3s3ɓỴZs3iⱮ@Ṗ}Ḍ‘ṃZ€ZY - Link: list of characters, InputArt
“...’ - 2143653348009571447353888914930329561628051130270532338528823129948739132031
ṃ“ /|)(\_” - in base seven with digits 0-7 = "_ /|)(\"
s3s3 - split into threes, split into threes
ɓ - new dyadic chain - f(InputArt, Parts=that)...
Ỵ - split {InputArt} at newline characters
Z - transpose
s3 - split into threes -> InputParts
iⱮ@ - 1-indices of {InputParts} in:
Ṗ} - {Parts} without the right
or 0 if not found
Ḍ - cast from decimal
‘ - increment
ṃ - in base ten with digits 1-9,0 = {Parts}
Z€ - transpose each
Z - transpose
Y - join with newline characters
- implicit, smashing print
Python 3, 241 bytes
i=input
j=''.join
d=j(map(j,zip(i(),i(),i())))
c="| _/(\)"*49;f=j(c[x//49]+c[x//7]+c[x] for x in b'KkWG19lr]rra2@13ro1r>9lxQraNr1')
n=0
while d:n=n*10+f.index(d[:9])//9;d=d[9:]
for y in 0,1,2:print(j(f[int(x)*9:][:9]for x in str(n+1))[y::3])
Input and output use input() and print() for stdin/stdout.
Using the 3x3 monospace font.
Explanation of implementation:
- Font
fis stored column by column in compressed format, 3 symbols per character. - Input lines are interleaved to
d dis parsed 9 characters at a time, and index in font is used as the numeric value of the digit- Output is formatted line by line
Charcoal, 67 bytes
≔⪪”{➙d↗≧?↥R(⊞νu»I³§±↑⊞φ⌊⎇Lχ8YΣZ|+&ςR↥ÞJ~Z⌊C”⁹ε↑⪪⍘⊕⍘⪪⭆θ⭆⟦ζηθ⟧§λκ⁹εε³
Try it online! Link is to verbose version of code. Uses the smallest monospaced font in the list. Explanation: Processes the data vertically, rotating the input and output.
”...” Compressed rotated font data
⪪ ⁹ Split into individual digits
≔ ε Save into variable
⭆θ⭆⟦ζηθ⟧§λκ Input rotated and joined
⪪ ⁹ Split into individual digits
⍘ ε Decoded using font as custom base
⊕ Incremented
⍘ ε Encoded using font as custom base
⪪ ³ Split into columns
↑ Output rotated
If Charcoal had a transpose operator then ⭆θ⭆⟦ζηθ⟧§λκ could be ⪫Z⮌E³Sω for a saving of 4 bytes.
Ruby, 258 bytes
->s{y=n=0;t=s.size/9
t.times{|i|j='/\/ /__| |_|| ((( '.index s[1+3*i+=t]+s[2+3*i+=t]
n=n*10+j/2+j%2*6}
(["%d"%-~n]*3*$/).bytes{|k|print k>10?' _ __ __ __ _ __ _ _ / \/| _)__)|_||_ |_ /(_)(_|\_/ | /____) |__)|_) / (_) _|'[k%48*3+y,3]:$/%y+=30}}
Uses the smallest font on the list, which is equal size 3x3 characters. The number of digits in the input is therefore t=s.size/9, rounded down.
Function takes a newline-separated string as an argument and prints a newline-separated string.
Each digit is identified by the 1st character on the 2nd and 3rd row. These are combined into a 2-character string and searched for in a magic string. The digit is given by j/2 with a correction of j%2/6(since 7 returns an incorrect index of 3 instead of 14, when it finds the two spaces that straddle the data for digits 1 and 2.) The total is kept in n
n+1 = -~n is converted into 3 copies of the string representation of n, separated by newlines. This is then processed one Ascii code at a time. if the Ascii code is not newline, we find the correct 3 output characters in the big string with index [k%48*3+y,3]. If it is a newline, we output a newline and increment y by 30 to find the correct output characters for the next row.