| Bytes | Lang | Time | Link |
|---|---|---|---|
| 277 | Tcl | 170107T010159Z | sergiol |
| nan | 05AB1E | 170112T200731Z | Magic Oc |
| 076 | Bubblegum | 170621T202410Z | Anders K |
| 205 | C | 170113T221257Z | dim |
| 113 | Ruby | 170108T175945Z | Level Ri |
| 154 | JavaScript ES6 | 170106T145044Z | Arnauld |
| 2658 | PowerShell | 170106T144710Z | AdmBorkB |
Tcl, 211 chars, 277 bytes
lmap {j b _ n u A V L} {──┘ " " ┌─────┐ ┌───┐ └───┘ ┌─┐ └─┘ └──} {puts " $b$A $A $_ $A $A $n
A $j $V $V $b$V $V $V$b$L
$n $n $A $_$b$A $A
B ┘$b$V$b$V $V $b$u $V └
$b$_$b$A$b$A$b$n
X $j $b$u $u $u$b$L──"}
05AB1E, 101 bytes + 5 UTF-8 bytes = 116 Total Bytes = 106 Bytes
(LEGACY 05AB1E VERSION, NO LONGER ON TIO)
•=(Ín§Àoà`œ¯_eè8y1ÜŸ,Ú®:¹$:,õKA–x[Âì0ãXÔfz}y×ì¹Ï½uEÜ5äÀTë@ºQÈ™ñó:ò…Eä•6B"102345"" ┌─┐└┘"‡6ävyN" A B X"èì}»
The compression:
•=(Ín§Àoà`œ¯_eè8y1ÜŸ,Ú®:¹$:,õKA–x[Âì0ãXÔfz}y×ì¹Ï½uEÜ5äÀTë@ºQÈ™ñó:ò…Eä•
# Pattern, converted to base-6 in base-6=214.
111023102310222223102310231022231112251425142511111425142514251114221022231022231023102222231110231023151114251114251425111114222514251411102222231110231110231110222311111225111114222514222514222511142222
# Actual base-6 pattern.
1110231023102222231023102310222311
1225142514251111142514251425111422
1022231022231023102222231110231023
1511142511142514251111142225142514
1110222223111023111023111022231111
1225111114222514222514222511142222
#Pattern split into chunks of 34.
┌─┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐ ┌───┐
──┘ └─┘ └─┘ └─┘ └─┘ └─┘ └──
┌───┐ ┌───┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐
┘ └─┘ └─┘ └─┘ └───┘ └─┘ └
┌─────┐ ┌─┐ ┌─┐ ┌───┐
──┘ └───┘ └───┘ └───┘ └────
# Pattern after replacing 0,1,2,3,4,5 with appropriate blocks.
The conversion:
6B # Convert back to base-6.
"102345"" ┌─┐└┘"‡ # Replace numbers with appropriate counterparts.
6ä # Split into 6 equal parts (the rows).
vy } # For each row (chunk).
N" A B X"èì # Push label at index [i], prepend to line.
» # Print all separated by newlines.
Using the CP-1252 encoding.
Bubblegum, 76 bytes
00000000: 92d6 3000 5431 1505 1403 50e8 4e0a aafc ..0.T1....P.N...
00000010: 9f62 15e6 a3ff 61fa dc05 e06d 8b66 cbc7 .b....a....m.f..
00000020: e6b6 cff8 519a b85a 3eb6 b67d 95c0 0feb ....Q..Z>..}....
00000030: 35b5 521d 7f7e 68af a916 fa20 d999 564d 5.R..~h.... ..VM
00000040: 1f03 d559 59ed 265c f243 42be ...YY.&\.CB.
Uses box-drawing characters from the VT100 alternate character set, which TIO can’t demonstrate. Run in a UNIX terminal for best results. My terminal converts the ACS to UTF-8 on copy-and-paste, so you can see the effect here.
anders@change-mode:/tmp$ bubblegum xnor.zlib
┌─┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐ ┌───┐
A ──┘ └─┘ └─┘ └─┘ └─┘ └─┘ └──
┌───┐ ┌───┐ ┌─┐ ┌─────┐ ┌─┐ ┌─┐
B ┘ └─┘ └─┘ └─┘ └───┘ └─┘ └
┌─────┐ ┌─┐ ┌─┐ ┌───┐
X ──┘ └───┘ └───┘ └───┘ └────
▒┼␍␊⎼⎽@␌▒┼±␊-└⎺␍␊:/├└⎻$
Well, the challenge didn’t say we need to take the terminal back out of ACS mode before returning to the shell. Good luck with that.
C, 213 205 bytes
For a change, the C program size, on this challenge, isn't completely ridiculous compared to other languages.
#define X(a) u[i]=C[a],l[i++]=C[(a)+4]
p(n,c){char u[34],l[34],*C=" ┐┌──└┘ ",i=0;while(i<34)X(n&3),n>>=1,X((n&1)*3);printf(" %.33s\n%c %.33s\n",u,c,l);}main(){p(0xD5D4,'A');p(0x14EB6,'B');p(0x649C,'X');}
Ungolfed, define expanded, and commented:
p(n,c){
// u is the upper line of the graph, l the lower line
char u[34],l[34],*C=" ┐┌──└┘ ",i=0;
while(i<34)
u[i]=C[n&3], // using the two LSBs to set the transition char depending on the current and next state
l[i++]=C[(n&3)+4], // do for both upper and lower lines
n>>=1, // shift bits right to go to next state
u[i]=C[(n&1)*3], // using only the LSB to set the "steady" char depending on current state only
l[i++]=C[((n&1)*3)+4]; // do for both upper and lower lines
printf(" %.33s\n%c %.33s\n",u,c,l);
}
main() {
// Call p for each graph
// Constants are chosen so the display is consistent with the request.
// Each bit represents a state, but the order is reversed
// (leftmost is put on lowest significant bit, after a 0)
p(0xD5D4,'A');p(0x14EB6,'B');p(0x649C,'X');
}
Note: the C string must not contain unicode characters. All displayable characters must be plain old 8-bit chars (but they may be chosen in the extended range). So basically, the validity of the output depends on your code page.
Ruby, 113 bytes
counting printed symbols as one byte as authorised by the challenge (I was surprised to discover they are actually 3 bytes.)
6.times{|i|s=' A B X'[i]
'D]zunIWkF]nIRukFH'.bytes{|b|s+=' ┌─┐───┘ └'[(b*2>>i/2*2&6)-i%2*6,2]}
s[1]=' '
puts s}
6 lines of output lends itself to an encoding of 6 bits per each character of the magic string. But the magic string characters actually encode for each transition thus:
least significant bit 0 New value for A
1 Current value for A
2 New value for B
3 Current value for B
4 New value for X
5 Current value for X
most significant bit 6 Always 1 (to remain in printable range)
This is decoded to find the 2 characters that must be printed for each transition (the first of which is either space or a horizontal line.)
The 8-character strings for the upper and lower rows overlap: The last two characters for the upper row 11 are two horizontal lines, which matches with what is needed for the first two characters of the lower row 00. The 8 characters for the lower row wrap around: they are last 6 and first 2 characters of the symbol string.
Ungolfed code
6.times{|i|s=' A B X'[i] #iterate through 6 lines of output. Set s to the 1st character.
'D]zunIWkF]nIRukFH'.bytes{|b| #for each byte in the magic string
s+=' ┌─┐───┘ └'[(b*2>>i/2*2&6)- #add 2 bytes to s, index 0,2,4, or 6 of the symbol string depending on relevant 2 bits of the magic string.
i%2*6,2] #if the second (odd) row of a particular graph, modify index to -6,-4,-2, or 0
} #(ruby indices wrap around. mystring[-1] is the last character of the string.)
s[1]=' ' #replace intitial ─ of the curve with space to be consistent with question
puts s #output line
}
JavaScript (ES6), 163 158 154 bytes
NB: counting UTF-8 characters as bytes, as authorized by the challenge.
_=>[..." A B X"].map((c,i)=>c+" "+[...Array(33)].map((_,j)=>j%2?" ─"[p^i&1]:" ┐┌─└┘ "[p+(p=[27370,42843,12878][i>>1]>>j/2&1)*2+i%2*3]).join``,p=0).join`
`
Demo
let f =
_=>[..." A B X"].map((c,i)=>c+" "+[...Array(33)].map((_,j)=>j%2?" ─"[p^i&1]:" ┐┌─└┘ "[p+(p=[27370,42843,12878][i>>1]>>j/2&1)*2+i%2*3]).join``,p=0).join`
`
console.log(f())
Saved 4 bytes thanks to Neil
PowerShell, 255 characters, 265 bytes (UTF-8)
$a=' 012 012 0111112 012 012 01112
A 113 413 413 413 413 413 411
01112 01112 012 0111112 012 012
B 3 413 413 413 41113 413 4
0111112 012 012 01112
X 113 41113 41113 41113 41111'
0..4|%{$a=$a-replace$_,('┌─┐┘└'[$_])};$a
This works on my computer, but doesn't seem to parse the bytes correctly on TIO...
This sets $a to be a multi-line string filled with numbers and spaces, then loops 0..4|%{...}. Each iteration, we -replace the appropriate digit $_ with the appropriate character '┌─┐┘└'[$_] and store it back into $a. Then, we just leave $a on the pipeline and output is implicit.
