# Create an ASCII-to-hex table for Mark Watney

Inspired by this SciFi.SE question.

### Background (with minor spoiler):

In the movie The Martian, protagonist Mark Watney uses an ASCII table to look up hexadecimal values of ASCII characters so he can attempt to communicate back to Earth.*

### Challenge

With no input, output the following ASCII table exactly like this:

Dec Hex    Dec Hex    Dec Hex  Dec Hex  Dec Hex  Dec Hex   Dec Hex   Dec Hex
0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60   112 70 p
1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q
2 02 STX  18 12 DC2  34 22 "  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r
3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s
4 04 EOT  20 14 DC4  36 24 $52 34 4 68 44 D 84 54 T 100 64 d 116 74 t 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B { 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \ 108 6C l 124 7C | 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D } 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~ 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL  The final newline is optional. With the newline, the md5 of the output is 58824a1dd7264c0410eb4d727aec54e1. Without, it is 41b6ecde6a3a1324be4836871d8354fe. In case it helps, this is the output from the ascii Linux command with the usage info at the top chopped off. You can recreate this on Ubuntu as follows: sudo apt-get install ascii ascii | tail -n+7  You may not use the ascii utility (or similar) in your answers. Because ASCII characters are small Enough with this silly meme already! I am aware this is similar to Print the ASCII table, but I believe the formatting of the output in this question is significantly more complex and warrants a different question. *Note, I have not yet seen this movie. • So the program can be hard-coded?? – TanMath Jan 5 '16 at 19:58 • @TanMath Are you referring to use of the ascii utility in answers - if so, see my edit - its not allowed. – Digital Trauma Jan 5 '16 at 20:01 • +1 for the silly meme ... but why another challenge with no input? – edc65 Jan 5 '16 at 20:11 • @msh210 The code-golf tag implies shortest code in bytes if not otherwise stated. I'm trying to apply the DRY principle ;-). Similarly, unless otherwise stated, entries may be programs or functions. – Digital Trauma Jan 5 '16 at 20:29 • Must traling whitespace be exactly as shown? (i.e.2 spaces on the first line, none on the others) – Level River St Jan 5 '16 at 21:00 ## 15 Answers # JavaScript (ES6), 323 332 353 Edit I managed to shorten this a bit Step 1, believe it or not, using an array of 16 chars is shorter than toString + toUpperCase Step 2, fiddling around to use .map instead of for, so that I can transform it all to a single expression function, avoding console.log and/or return. Edit 2 Moved DEL at place 0, idea borrowed from Cole Cameron H=x=>(x=[...'0123456789ABCDEF']).map((d,r)=>x[S='slice'](0,8).map(c=>(o+=${w=c*16+r} ${c+d} [S](-z)+("DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".substr((w+1&127)*3,3)||String.fromCharCode(w)),z=c<5?8:9,'Dec Hex '[S](0,c<2?z+2:z)),o+= ,z=7).join ,o='')[0]+o  MD5: 41B6ECDE6A3A1324BE4836871D8354FE Pixel perfect, I'd say LESS GOLFED H=x=>( x=[...'0123456789ABCDEF'], a="DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ", o='', // the string o will contain the body (16 rows) x.map((d,r)=> ( // main loop, r is thr row number, d is the second hex digit to print o+=\n, z=7, x.slice(0,8).map(c=> // loop on 8 columns, c is both column number and digit to print ( // append the column to o o += ${w=c*16+r} ${c+d} .slice(-z) + (a.substr((w+1&127)*3,3)||String.fromCharCode(w)), z=c<5?8:9, // adjust the column size 'Dec Hex '.slice(0,c<2?z+2:z) // column head, right size ) // the .map result is the 8 columns heading ).join  // join the heading in a single string ))[0] // any element of the result map is the heading + o // concatenate the body )  Test H=x=>(x=[...'0123456789ABCDEF']).map((d,r)=>x[S='slice'](0,8).map(c=>(o+=${w=c*16+r} ${c+d} [S](-z)+("DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".substr((w+1&127)*3,3)||String.fromCharCode(w)),z=c<5?8:9,'Dec Hex '[S](0,c<2?z+2:z)),o+= ,z=7).join ,o='')[0]+o /* TEST */ console.log=x=>O.textContent=x console.log(H()) <pre id=O></pre> # C, 307310308307 305 bytes Finally working 100%. i,j,z=127;main(){for(;j++<8;)printf("Dec Hex%*s",j<3?4:j<6||j>7?2:3,"");for(;i<143&&putchar(!i|i>z?10:32);i+=16)i=i>z?i%z:i,printf("%*d %02X ",i>95?4:3,i,i),i%z>31?putchar(i):printf("%.3s","DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US "+(i+1)%128*3);}  Output: $ ./a.out
Dec Hex    Dec Hex    Dec Hex  Dec Hex  Dec Hex  Dec Hex   Dec Hex   Dec Hex
0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60   112 70 p
1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q
2 02 STX  18 12 DC2  34 22 "  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r
3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s
4 04 EOT  20 14 DC4  36 24 $52 34 4 68 44 D 84 54 T 100 64 d 116 74 t 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B { 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \ 108 6C l 124 7C | 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D } 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~ 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL$ ./a.out > file.txt
$md5sum file.txt 41b6ecde6a3a1324be4836871d8354fe file.txt  Ungolfed: /* some variables for the trip */ i,j,z=127; main() { /* print header row */ for(;j++<8;) printf("Dec Hex%*s", j<3?4:j<6||j>7?2:3, ""); /* Iterate through ASCII values, print a space after every column, newline after every 8th value */ for(;i<143 && putchar(!i|i>z ? 10 : 32); i+=16) { /* print dec/hex value */ printf("%*d %02X ", i>95?4:3, i, i=i>z?i%z:i); /* print character or friendly name for non-printable characters */ i%z>31 ? putchar(i) : printf("%.3s", "DELNULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US "+(i+1)%128*3); } }  Try it on Ideone. Edit: 2 more bytes. Many thanks to Dan Allen and Digital Trauma. • Also, you don't need the #include <stdio.h> – Digital Trauma Jan 5 '16 at 22:01 • @DigitalTrauma: You can in GCC. You can't in C. – DevSolar Jan 6 '16 at 8:36 • @DevSolar It's not a GCC thing. In K&R C, the compiler, not having the declaration of printf and putchar, will guess, and guess right. On the other hand, it's undefined behaviour in standard C99, but who cares - it works as expected in all compilers that I know – edc65 Jan 6 '16 at 9:00 • 305 if you change the first line to x,y,z=127; and replace the 4 occurences of 127 with z. Adds 6 characters but takes 8 away. – Persixty Jan 7 '16 at 9:05 • Clever trick, putting the DEL at first place. I'll borrow this idea. I would upvote now just for this one, but I already upvoted yesterday :) – edc65 Jan 8 '16 at 9:02 # Bubblegum, 535 bytes 0000000: e0 05 2f 02 0f 5d 00 22 19 48 62 01 d3 1f 78 e2 ../..].".Hb...x. 0000010: 9a a0 8e 4e 5d d1 b4 c1 77 aa 32 58 ca 97 55 7e ...N]...w.2X..U~ 0000020: a8 01 87 7d db e4 00 55 8f c0 49 67 b6 56 02 5e ...}...U..Ig.V.^ 0000030: ae b2 4d e2 a9 f4 7f 99 a8 56 9e b7 4c 60 a4 79 ..M......V..L.y 0000040: 6a 76 54 11 90 72 d6 b7 19 df 2f 57 39 2d 21 c0 jvT..r..../W9-!. 0000050: d1 4c 5e d6 21 29 c8 ed 7c a9 7b 8c 85 dc 62 a1 .L^.!)..|.{...b. 0000060: 65 98 e1 0b a7 36 83 c8 ca 88 0c 57 22 f6 56 1e e....6.....W".V. 0000070: 45 03 b6 74 21 a8 39 52 e9 71 b4 98 ed 71 38 9f E..t!.9R.q...q8. 0000080: 2d dc 21 d7 bf 60 41 cc bb bd a7 cb 0b 17 8d 65 -.!..A........e 0000090: 05 13 04 0f 6c bb 67 62 aa c7 ad 6b be 9e 46 77 ....l.gb...k..Fw 00000a0: 35 b9 91 85 f5 47 31 2f c7 ec da c0 00 0e a6 48 5....G1/.......H 00000b0: 01 ba 8b cd b0 34 81 c4 74 9f 4e 3b c3 d0 f7 10 .....4..t.N;.... 00000c0: 46 a0 55 8d 49 5d b7 b0 c9 79 ac e5 5f ef 49 f2 F.U.I]...y.._.I. 00000d0: b0 1b 71 3a e1 30 7a fc ce a7 a8 d5 c3 9a 35 1a ..q:.0z.......5. 00000e0: 4e 27 92 40 4b b5 9b c4 0d 5c e8 cd 71 00 bd c1 N'.@K....\..q... 00000f0: ca aa d2 05 dc e1 0f d9 19 1d 6f 14 87 b3 e4 e8 ..........o..... 0000100: 9e 82 64 d8 e4 76 e7 24 0a 0e 88 72 a1 12 44 95 ..d..v.$...r..D.
0000110: d4 78 82 bd da 71 f3 fb 03 00 d1 4b c8 80 cb 49  .x...q.....K...I
0000120: 0b 98 be 26 ba 3e e8 82 e2 14 9b ba 1a cf bf bc  ...&.>..........
0000130: 30 4e c4 e8 7e b4 d5 46 e6 bc 73 97 c5 ed a6 e2  0N..~..F..s.....
0000140: 06 02 e7 1b 74 4d da 73 fb 15 68 50 c0 ed 32 9b  ....tM.s..hP..2.
0000150: 0d d7 49 d5 c1 a2 e9 07 2c 77 81 6c d3 8d 59 26  ..I.....,w.l..Y&
0000160: 1c 35 ec 2b 7e cb 3a f1 cc 45 a9 e5 6d 3e 33 ca  .5.+~.:..E..m>3.
0000170: 56 3c 8a 8d f6 13 e9 59 d4 52 07 44 ab 5e bc f4  V<.....Y.R.D.^..
0000180: 1f ed f8 9c 8b 48 e1 c4 6c fd 47 d5 04 cc 6e aa  .....H..l.G...n.
0000190: 3f 54 b8 cc cd 09 01 6d 20 3c 42 c9 44 da b1 c1  ?T.....m <B.D...
00001a0: 69 80 12 26 6b 65 e1 4d 1c c3 48 36 2b 14 00 61  i..&ke.M..H6+..a
00001b0: 04 6b 9a 59 2a 53 e3 64 a7 4f dd cc be 2c 20 5e  .k.Y*S.d.O..., ^
00001c0: f7 c7 64 34 e6 12 a6 44 c1 69 35 76 05 db 13 ab  ..d4...D.i5v....
00001d0: 52 10 b5 8e da 8e c5 3c 4c d0 69 0b 19 18 67 ef  R......<L.i...g.
00001e0: 44 1c 7b 70 63 98 95 40 28 6e 3d e7 44 cb 24 83  D.{pc..@(n=.D.$. 00001f0: 88 62 63 3c 02 1c e7 db db 02 56 ae cd 9c e0 9c .bc<......V..... 0000200: 1c a1 c1 ae d1 dd 7b b7 e6 bd 5b 38 ee 75 c5 6c ......{...[8.u.l 0000210: 06 16 6c b2 fb 00 00 ..l....  This above program uses LZMA compression. Try it online! • I think you can do better than that... ;-) – Digital Trauma Jan 5 '16 at 20:08 • Not in Bubblegum... – Dennis Jan 5 '16 at 20:10 • How many bytes would you need to print the entire novel The Martian? – Alex A. Jan 5 '16 at 21:31 • @DigitalTrauma It's easy... You only have to execute a prefix attack on SHA-256... – LegionMammal978 Jan 6 '16 at 12:15 ## C, 385384 358 bytes i,n,j;char a[100]="NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US DEL";z(o){printf("%3d %02X %.*s ",j,j,3,a+o);}main(){for(;i<8;i++){printf("%3s %3s ","Dec","HEX ");}printf("\n");for(;n<16;n++){for(j=n;j<=n+112;j+=16){if(j==127)z(96);else j<32?z(j*3):printf("%3d %02X %c ",j,j,j);}printf("\n");}return 0;}  The guy above beat me to the punch but I still wanted to submit because I enjoyed this one. De-golfed: #include<stdio.h> i,n,j; char a[100] = "NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US DEL"; z(o){printf("%3d %02X %.*s ",j,j,3,a+o);} main(){ for(;i<8;i++){printf("%3s %3s ","Dec","HEX ");}printf("\n"); for(;n<16;n++){ for(j=n;j<=n+112;j+=16){ if(j==127)z(96); else j<32?z(j*3):printf("%3d %02X %c ",j,j,j); } printf("\n"); } return 0; }  UPDATE : replaced a var with j. Saved a byte ;) UPDATE2: Trimmed a few extra thingys and functionized a print thingy to save some bytes. • Similar to many answers, you don't have the correct spacing between columns. Also s/HEX/Hex/. – Digital Trauma Jan 6 '16 at 1:26 • I must have missed the chapter explaining the thingy c keyword ;-P – Digital Trauma Jan 6 '16 at 16:17 # JavaScript ES6 432405398 385 o="Dec Hex " o=${o}  ${o}${o+o+o+o} ${o}${o}\n
for(i=0;i<16;i++){for(j=0;j<8;j++){k=i+j*16
o+=k>9&&k<16?' ':k<96||k>99?'  ':'   '
o+=k+" "+(k<16?0:'')+k.toString(16).toUpperCase()+" "
o+=k>31?String.fromCharCode(k):"NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".substr(k*3,3)
}o+="\n"}
console.log(o.substr(0,o.length-2)+'DEL')

• ES5 I take it? ES6 you could do things like ${o}${o} ${o+o+o+o}${o} ${o}. – Neil Jan 6 '16 at 18:04 • @Neil Thanks! I added the change and the trailing space is taken care of. – wolfhammer Jan 6 '16 at 19:12 • Actually you can go one step further since literal newlines are legal inside backticks (not sure how to demonstrate that in a comment). – Neil Jan 7 '16 at 11:52 # Golfscript, 225 bytes "\x04\x04\x02\x02\x02\x03\x03\x02"{"Dec Hex"" ":s@*}%n[128,{3s*\+-4>s+.~.96<@>\256+16base{10,"ABCDEF"1/+=}%1>{+}/}%"\x1f\xbb\x89\xbc\xaf\x82=F\xd7U%\x80\x8a\xf6\xc7U\xa6al)A\xf6\x19\xfe\x03\x83\xef-\x9f\xe7m\xeb\x82h\xf3\xbfEm6V\x1fD\x8c\xd7~\xcb\x95&(\x1e/:\x8e\xc5\xb0\x0b\xd6\xd4\xd09\xdd""\xff\x1e"{base}/{90,65>1342s++1/=}%3/32/"\x7f"{,32>}%1/*]zip{s*}%16/zip{s*n}%  # Python 2.7, 389 Bytes Probably not going to try and trim this down anymore, but it was fun to get it this far. r=range c='NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ' h='' p=['']*16 o=[11,11,9,9,9,10,10,9] e=['%3s '%str(i)+('%02X ')%(i)+('DEL',c[i*3:i*3+3].strip() if i<32 else chr(i))[i<127] for i in r(128)] for i in r(8): l=e[i*16:(i+1)*16] h+='Dec Hex'.ljust(o[i]) p=[p[j]+l[j].ljust((0,o[i])[i<7]) for j in r(16)] print h+'\n'+'\n'.join(p)  # Python 3.4, 216 Bytes Also valid Python 2.7. Used FryAmTheEggman's idea/suggestion about curses.ascii.controlnames, which saves almost 100 bytes. import curses.ascii as a o='' w=4,4,2,2,2,3,3,1 for x in w:o+='Dec Hex'+' '*x o+=' ' for n in range(16): o+='\n' for x in w:o+='%3d %02X %-*s'%(n,n,x,n>31and[chr(n),'DEL'][n>126]or a.controlnames[n]);n+=16 print(o)  $ python ascii.py | md5
58824a1dd7264c0410eb4d727aec54e1


# Ruby (2.2.2p95), 277 295 306 331 364

a='Dec Hex  ';puts"#{a}  "*2+a*4+" #{a}"*2,16.times.map{|i|8.times.map{|j|(k=i+j*16;k==127?'  127 7F DEL':"#{k} #{'%.2X'%k} #{'NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US  '[k*3..k*3+2]||k.chr}").rjust(j<2?10+j :9+j/6)}.join}


ungolfed

s = "Dec Hex    " * 2 + "Dec Hex  " * 4 + " Dec Hex  " * 2
a = 127.times.map { |i|
"#{i} #{'%.2X'%i} #{'NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US  '[i*3..i*3+2]||i.chr}"
}
a << '  127 7F DEL'
x = 16.times.map { |i|
8.times.map { |j|
a[i + j * 16].rjust(j < 2 ? 10 + j : 9 + j / 6)
}.join
}.join "\n"
puts s, x

• The control name array really kills me here. Still hoping to find something similar to Python's curses.ascii for Ruby... – Connor Clark Jan 19 '16 at 21:44

# Microscript II, 1314 bytes

Probably far from optimal.

"Dec Hex    "pp"Dec Hex  "ppps"Dec Hex   "ppoP"  0 00 NUL  16 10 DLE  32 20    48 30 0  64 40 @  80 50 P   96 60   112 70 p\n  1 01 SOH  17 11 DC1  33 21 !  49 31 1  65 41 A  81 51 Q   97 61 a  113 71 q\n  2 02 STX  18 12 DC2  34 22 \"  50 32 2  66 42 B  82 52 R   98 62 b  114 72 r\n  3 03 ETX  19 13 DC3  35 23 #  51 33 3  67 43 C  83 53 S   99 63 c  115 73 s\n  4 04 EOT  20 14 DC4  36 24 $52 34 4 68 44 D 84 54 T 100 64 d 116 74 t\n 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u\n 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v\n 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w\n 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x\n 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y\n 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z\n 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B {\n 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \\ 108 6C l 124 7C |\n 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D }\n 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~\n 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL"  • How do I test this? – Digital Trauma Jan 6 '16 at 16:18 • @DigitalTrauma I'll add a link to the github repo to the answer. Run the interpreter with the program as the first line of the input. – SuperJedi224 Jan 6 '16 at 20:04 • Congrats. You made the most boring answer on this contest. ò_ó +1 – user48538 Jan 7 '16 at 19:40 • @zyabin101 Well, it is about 30 bytes shorter than simply printing the string all at once would likely be. – SuperJedi224 Jan 7 '16 at 20:11 ## JavaScript, 41541342314114064024142 412 bytes x=>eval('a=${d="Dec Hex  "}  [r="repeat"](2)+d[r](3)+${d} [r](2)+d+ ;z="NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".match(/.{3}/g);z[127]="DEL";for(j=i=0;i<128;i++){a+=(" "+((b=i%8*16)+j)).slice(-3)+" "+(0+(c=b+j).toString(16).toUpperCase()).slice(-2)+" "+(c<32||i==127?z[c]:String.fromCharCode(c))+(b==112? :(b < 80 ? " " : " "));if(b==112)j++}a')  I couldn't figure out how to print the chars prior to char code 32, so just listed them as a string. The hash I've got seems to match (41b6ecde6a3a1324be4836871d8354fe). Demo + Ungolfed: function t() { a = ${d="Dec Hex  "}  .repeat(2) + d.repeat(3) + ${d} .repeat(2) + d + "\n"; z = "NULSOHSTXETXEOTENQACKBELBS HT LF VT FF CR SO SI DLEDC1DC2DC3DC4NAKSYNETBCANEM SUBESCFS GS RS US ".match(/.{3}/g); z[127] = "DEL"; for (j = i = 0; i < 128; i++) { a += (" " + ((b = i % 8 * 16) + j)).slice(-3) + " " + (0 + (c = b + j).toString(16).toUpperCase()).slice(-2) + " " + (c < 32 || i == 127 ? z[c] : String.fromCharCode(c)) + (b==112?"\n":(b < 80 ? " " : " ")); if(b==112)j++; } return a } document.write("<pre>" + t() + "</pre>") 1 - fixed spacing 2 - again fixed spacing • Huh, in mobile Chrome <pre> doesn't monospace, though it should. – nicael Jan 5 '16 at 20:55 • I don't think that's qute the spacing the question's asking for. – SuperJedi224 Jan 5 '16 at 21:00 • @Dig oy wtf. I see this 0.0 – nicael Jan 5 '16 at 21:04 • @Digital I've fixed the spacing. – nicael Jan 6 '16 at 7:57 • @Digital You after the last column? Ok, but that doesn't even affect the appearance... – nicael Jan 6 '16 at 16:14 # MATLAB, 363 bytes Not as small as C but comparable... h='';s=@sprintf;for i=[4 4 2 2 2 3 3 2]h=s([h 'Dec Hex%*s'],i,'');end h=[h 10];a='NULDLESOHDC1STXDC2ETXDC3EOTDC4ENQNAKACKSYNBELETBBS CANHT EM LF SUBVT ESCFF FS CR GS SO RS SI US ';for i=0:15for j=0:7k=i+16*j;if j<2b=1+6*i+3*j;h=[h s('%3d %02X %-3s ',k,k,a(b:b+2))];else h=[h s('%*d %02X %c ',3+(j>5),k,k,k)];end end h=[h(1:end-1) 10];end disp([h(1:end-2) 'DEL']);  • Do I have to download the free trial, or is there some other way I can test your answer? Or can you claim the md5 of the output is correct? – Digital Trauma Jan 6 '16 at 16:15 • You can run it in GNU Octave, but I already did and this version lacks the additional padding between columns 6, 7 and 8. Apart from that, it's correct. – Rainer P. Jan 6 '16 at 18:14 • Yes, you are right. Corrected the code. This happens, if you have the golfed and ungolfed variant side by side. Corrected some typos. Interestingly I get a different ascii|tail -n=+7 (first row last two spaces are missing) (Ubuntu 15.10). I never noticed, that in matlab variables named d and e behave differently. (for i=1:2d=10;end; % Syntax error) (for i=1:2k=10;end; % Just fine) – Jonas Jan 7 '16 at 17:23 # ///, 998 bytes / /\/\/// / /Dec Hex / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 / 9 /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /A /B /C /D /E /F / /    NUL 6DL 2 80 4@ 0P 6 12 pSOH 7DC3! 91 5 1Q 7a 13 qSTX 8DC4" 02 6 2R 8b 14 rETX 9DC5# 13 7 3S 9c 15 sEOT 0DC6$ 24 84T 00d 16	tENQ 1NAK 7% 35 95U 01e 17	uACK 2SYN 8& 46 	06V 02f 18	v	BEL 3ET9' 57	 	1G 7W 03g 19	wBS4CAN 0( 68 	2H 8X 04h 20	xHT5EM1) 79 	3I 9Y 05i 21	y
0L 6SU2* 8: 	4J 0Z 06j 22	z
1VT7ES3+ 9; 	5K 1[ 07k 23	{
2F 8FS4, 0< 	6L 2\\ 08l 24	|
3CR9GS5- 1= 	7M 3] 09m 25	}
4SO0RS6. 2> 	8N 4^ 10n 26	~
5SI1US7\/ 3? 	9O 5_ 11o 27	DEL


Try it online!

# PHP, 330 321 bytes

$a=[NUL,SOH,STX,ETX,EOT,ENQ,ACK,BEL,BS,HT,LF,VT,FF,CR,SO,SI,DLE,DC1,DC2,DC3,DC4,NAK,SYN,ETB,CAN,EM,SUB,ESC,FS,GS,RS,US,127=>DEL];foreach($t=[3,3,1,1,1,2,2,0]as$i)echo'Dec Hex ',str_repeat(' ',$i);echo"
";for($x=0;$x<16;)for($y=$x++;$y<128;$y+=16)printf("% 3d %1$02X % -".$t[$y/16].s.($y<112?' ':"
"),$y,$a[$y]?:chr($y));


Try it online!

Less golfy:

$a=[NUL,SOH,STX,ETX,EOT,ENQ,ACK,BEL,BS,HT,LF,VT,FF,CR,SO,SI,DLE, DC1,DC2,DC3,DC4,NAK,SYN,ETB,CAN,EM,SUB,ESC,FS,GS,RS,US,127=>DEL];$t=[3,3,1,1,1,2,2,0];

foreach( $t as$i )
echo 'Dec Hex ', str_repeat( ' ', $i ); echo" \n"; for($x=0; $x<16; ) { for($y=$x++;$y<128; $y+=16 ) { printf( "% 3d %1$02X % -" . $t[$y/16] . 's' . ( $y<112 ?' ' : "\n" ),$y, $a[$y] ?: chr($y) ); } }  ## Common Lisp (SBCL), 309 (progn(format t"~{~v,0TDec Hex ~}"#1='(0 11 22 31 40 49 59 69))(dotimes(y 16)(fresh-line)(loop for x from 0 for k in #1#for i =(+(* 16 x)y)do(format t"~v,0T~3d ~2,'0x ~a"k i i(if(graphic-char-p #2=(code-char i))#2#(case i(8"BS")(9"HT")(10"LF")(12"FF")(13"CR")(127"DEL")(t(string-upcase(char-name #2#)))))))))  A script to be run which outputs the following to standard output, ie. the version without a final newline (md5: 41b6ecde6a3a1324be4836871d8354fe). Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex 0 00 NUL 16 10 DLE 32 20 48 30 0 64 40 @ 80 50 P 96 60  112 70 p 1 01 SOH 17 11 DC1 33 21 ! 49 31 1 65 41 A 81 51 Q 97 61 a 113 71 q 2 02 STX 18 12 DC2 34 22 " 50 32 2 66 42 B 82 52 R 98 62 b 114 72 r 3 03 ETX 19 13 DC3 35 23 # 51 33 3 67 43 C 83 53 S 99 63 c 115 73 s 4 04 EOT 20 14 DC4 36 24$  52 34 4  68 44 D  84 54 T  100 64 d  116 74 t
5 05 ENQ  21 15 NAK  37 25 %  53 35 5  69 45 E  85 55 U  101 65 e  117 75 u
6 06 ACK  22 16 SYN  38 26 &  54 36 6  70 46 F  86 56 V  102 66 f  118 76 v
7 07 BEL  23 17 ETB  39 27 '  55 37 7  71 47 G  87 57 W  103 67 g  119 77 w
8 08 BS   24 18 CAN  40 28 (  56 38 8  72 48 H  88 58 X  104 68 h  120 78 x
9 09 HT   25 19 EM   41 29 )  57 39 9  73 49 I  89 59 Y  105 69 i  121 79 y
10 0A LF   26 1A SUB  42 2A *  58 3A :  74 4A J  90 5A Z  106 6A j  122 7A z
11 0B VT   27 1B ESC  43 2B +  59 3B ;  75 4B K  91 5B [  107 6B k  123 7B {
12 0C FF   28 1C FS   44 2C ,  60 3C <  76 4C L  92 5C \  108 6C l  124 7C |
13 0D CR   29 1D GS   45 2D -  61 3D =  77 4D M  93 5D ]  109 6D m  125 7D }
14 0E SO   30 1E RS   46 2E .  62 3E >  78 4E N  94 5E ^  110 6E n  126 7E ~
15 0F SI   31 1F US   47 2F /  63 3F ?  79 4F O  95 5F _  111 6F o  127 7F DEL


### Details

• (0 11 22 31 40 49 59 69) contains the position of each column in a line, as obtained by inspecting the desired output. There were many corner cases that are simply better handled by hard-coding the exact position for each column and letting the ~T format directive tabulate as needed.

• Since names of characters are implementation-dependent, this code targets only the SBCL interpreter (I tested with CCL, which uses other names). I rely on char-name for most non-graphic characters, but some of them have explicit mappings to the expected output.

### Ungolfed

(progn
(format t"~{~v,0TDec Hex  ~}" '(0 11 22 31 40 49 59 69))
(dotimes(y 16)
(fresh-line)
(loop for x from 0
for k in '(0 11 22 31 40 49 59 69)
for i = (+ (* 16 x) y)
for c = (code-char i)
do (format t
"~v,0T~3d ~2,'0x ~a"
k
i
i
(if (graphic-char-p c)
c
(case i
(8"BS")
(9"HT")
(10"LF")
(12"FF")
(13"CR")
(127"DEL")
(t (string-upcase (char-name c)))))))))
`