| Bytes | Lang | Time | Link |
|---|---|---|---|
| 253 | C64 BASIC | 250919T201814Z | jdt |
| 205 | JavaScript ES8 | 250917T234319Z | Arnauld |
| 144 | 05AB1E | 250918T084253Z | Kevin Cr |
| 041 | Charcoal | 250917T185445Z | Neil |
C64 BASIC, 288 253 bytes
0 ?cH(147):INPUTN:dID(99),H(99),X(99)
1 D(73)=40:H(73)=-1:X(73)=75
2 D(74)=-40:H(74)=1:X(74)=85
3 D(75)=-1:H(75)=-40:X(75)=74
4 D(85)=1:H(85)=40:X(85)=73
5 C=74:P=1524
6 fOI=1TON:O=0:IFpE(P+H(C))>32tHO=66+2*(C>74)
7 IFO=0tHC=X(C):O=C
8 pOP,O:P=P+D(C):nE
JavaScript (ES8), 205 bytes*
* counting each box-drawing character as one byte, as per the challenge rules
The golfiest method for this kind of challenge is usually to create each possible output from the beginning until it matches the input and return the next iteration.
But ... this is not what I'm doing here. This code is a silly attempt at actually updating the input. It turns out to be even longer than I thought it would be.
Expects an empty string (or anything falsy) for no input.
s=>s?(g=k=>q=(4*s.split(/\S/).length-k)**.5)(3)^g(7,p=''.padEnd(q/2),i=q&3)?i&1?i&2?s+`
${p}╯`:`╭${p}
`+s:s.replace(/.+/g,s=>i?s+' ╮'[+!p++]:'╰ '[++p<q/2|0]+s):s.replace(i%3?/ /:/ (?![^]* )/,'│─'[i&1]):'╭'
05AB1E, 144 'bytes'
¬"│"DVQi"╭
"ìë¬ðQiRðY.;Rë.BDнθ" ─"s1«нk©dićðÜ"─╮"®è«š»ë¤¤ðQi¦θðQ"╯│"sès»sðs.;ë\\ðåiRð"─".;Rëg©i"╮"«ë®<i"
╯"«ë®ĀiθYQi.B¬g"╯"jª»ë.B1ú»Rð"╰".;Rë"╭
I/O as multi-line strings.
Try it online or verify the first 100 iterations.
Explanation:
TODO: Will first try to golf it more later on..
NOTE: Even though we can count the ╭╮╰╯─│ as 1 byte each in our program, it still costs more bytes than any ASCII-characters would have, since 05AB1E tries to interpret them as dictionary strings.. So all loose characters "│", "─", "╮", "╯", "╰" could have been '│, '─, '╮, '╯, '╰; all paired characters "╭\n", " ─", "─╮", "╯│" could have been „╭\n, „ ─, „─╮, „╯│; and the triplet "\n ╯" could have been …\n ╯ otherwise, saving 10 bytes in total.
Charcoal, 41 bytes
WS≔⁺ψ⁻ι ψFψ¿⊟KD²✳φ✳⁺²φ§│─⊘φ«✳φ§╭╰╯╮⊘φ≧⁺⁶φ
Try it online! Link is to verbose version of code. Takes input as a list of newline-terminated strings. Explanation:
WS≔⁺ψ⁻ι ψ
Append the input to the predefined null byte, but strip out any spaces.
Fψ
Loop over the input plus the null byte, thus producing an output extended by one character.
¿⊟KD²✳φ
Is there room to turn right?
✳⁺²φ§│─⊘φ
If not, then just draw the appropriate line.
«✳φ§╭╰╯╮⊘φ
If there is, then draw the appropriate corner, and...
≧⁺⁶φ
... turn right.
Note: TIO unnecessarily inserts 3 extra characters into its -vl output. Its count also includes 12 extra bytes that are normally needed to represent the box-drawing characters.
