50
\$\begingroup\$

Your task is to print the hexidecimal times table:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
00 02 04 06 08 0a 0c 0e 10 12 14 16 18 1a 1c 1e 
00 03 06 09 0c 0f 12 15 18 1b 1e 21 24 27 2a 2d 
00 04 08 0c 10 14 18 1c 20 24 28 2c 30 34 38 3c 
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b 
00 06 0c 12 18 1e 24 2a 30 36 3c 42 48 4e 54 5a 
00 07 0e 15 1c 23 2a 31 38 3f 46 4d 54 5b 62 69 
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 
00 09 12 1b 24 2d 36 3f 48 51 5a 63 6c 75 7e 87 
00 0a 14 1e 28 32 3c 46 50 5a 64 6e 78 82 8c 96 
00 0b 16 21 2c 37 42 4d 58 63 6e 79 84 8f 9a a5 
00 0c 18 24 30 3c 48 54 60 6c 78 84 90 9c a8 b4 
00 0d 1a 27 34 41 4e 5b 68 75 82 8f 9c a9 b6 c3 
00 0e 1c 2a 38 46 54 62 70 7e 8c 9a a8 b6 c4 d2 
00 0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 

Specifications:

  • You can print the hex values in uppercase.
  • Your lines can end with a trailing space and the program output can end with a trailing newline.
  • Every hex value must be padded to 2 digits with 0s as shown.

This is , so the shortest answer (measured in bytes) wins.

asked Dec 17, 2016 at 1:16
\$\endgroup\$
8
  • \$\begingroup\$ Related \$\endgroup\$ Commented Dec 17, 2016 at 1:18
  • 5
    \$\begingroup\$ Multiplication tables don't usually include factor 0... :-) \$\endgroup\$ Commented Dec 17, 2016 at 1:55
  • 31
    \$\begingroup\$ @Luis Mendo: How else will school children be able to memorize what 0 times a number is? :P \$\endgroup\$ Commented Dec 17, 2016 at 1:56
  • 1
    \$\begingroup\$ Darn, I wanted to make a solution using hexdump, but that groups into 4-byte blocks. :( \$\endgroup\$ Commented Feb 26, 2017 at 1:04
  • 1
    \$\begingroup\$ Can we have more space between columns if we're consistent? \$\endgroup\$ Commented Jul 10, 2019 at 23:46

70 Answers 70

1
2 3
14
\$\begingroup\$

Python 2, 60 bytes

for n in range(256):r=n%16;print'%02x%s'%(n/16*r,r/15*'\n'),

Try it online!

How it works

For all integers n from 0 to 255, we do the following.

  • We compute (n / 16) ×ばつ (n % 16).

    Over the range of n, both n / 16 and n % 16 independently cover the range 0, ..., 15, so this generates all entries of the multiplication table.

  • We repeat the linefeed character ('\n') (n % 16) / 15 times, which results in the same character when n % 16 = 15 and an empty string otherwise.

  • The format string '%02x%s' turns the two previous results into a single string, first a lowercase hexadecimal integer representation, zero-padded to (at least) two digits, then the generated string.

  • Finally, print..., prints the formatted results.

    Since the print statement ends with a comma, Python will not append a linefeed. Also, before printing the next string, Python will prepend a space unless we're at the beginning of a new line. (source) This happens to format the output exactly like we want to.

answered Dec 17, 2016 at 2:48
\$\endgroup\$
14
\$\begingroup\$

Jelly, 12 bytes

×ばつþ`d4‘ịØhG

Try it online!

How it works

×ばつþ`d4‘ịØhG Main link. No arguments.
4 Set the return value to 16.
 Ḷ Unlength; yield [0, ..., 15].
 ×ばつþ` Build the multiplication table of [0, ..., 15] and itself.
 d4 Divmod 16; yield [p : 16, p % 16] for each product p.
 ‘ Increment quotients and remainders (1-based indexing).
 ịØh Index into the lowercase hexadecimal alphabet.
 G Grid; join columns by spaces, rows by newlines.
answered Dec 17, 2016 at 2:33
\$\endgroup\$
2
  • \$\begingroup\$ That's 12 characters, not bytes. According to the question, answer is measured in bytes, and your answer is 25 bytes and 12 characters. At least according to this website mothereff.in/byte-counter \$\endgroup\$ Commented Dec 18, 2016 at 20:45
  • 20
    \$\begingroup\$ In UTF-8, sure. However, Jelly uses a SBCS, so each character can be encoded using a single byte. \$\endgroup\$ Commented Dec 18, 2016 at 20:59
11
\$\begingroup\$

R, 42 bytes

as.hexmode(sapply(0:15,function(x)x*0:15))

Prints the following:

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
 [1,] "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" "00" 
 [2,] "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "0a" "0b" "0c" "0d" "0e" "0f" 
 [3,] "00" "02" "04" "06" "08" "0a" "0c" "0e" "10" "12" "14" "16" "18" "1a" "1c" "1e" 
 [4,] "00" "03" "06" "09" "0c" "0f" "12" "15" "18" "1b" "1e" "21" "24" "27" "2a" "2d" 
 [5,] "00" "04" "08" "0c" "10" "14" "18" "1c" "20" "24" "28" "2c" "30" "34" "38" "3c" 
 [6,] "00" "05" "0a" "0f" "14" "19" "1e" "23" "28" "2d" "32" "37" "3c" "41" "46" "4b" 
 [7,] "00" "06" "0c" "12" "18" "1e" "24" "2a" "30" "36" "3c" "42" "48" "4e" "54" "5a" 
 [8,] "00" "07" "0e" "15" "1c" "23" "2a" "31" "38" "3f" "46" "4d" "54" "5b" "62" "69" 
 [9,] "00" "08" "10" "18" "20" "28" "30" "38" "40" "48" "50" "58" "60" "68" "70" "78" 
[10,] "00" "09" "12" "1b" "24" "2d" "36" "3f" "48" "51" "5a" "63" "6c" "75" "7e" "87" 
[11,] "00" "0a" "14" "1e" "28" "32" "3c" "46" "50" "5a" "64" "6e" "78" "82" "8c" "96" 
[12,] "00" "0b" "16" "21" "2c" "37" "42" "4d" "58" "63" "6e" "79" "84" "8f" "9a" "a5" 
[13,] "00" "0c" "18" "24" "30" "3c" "48" "54" "60" "6c" "78" "84" "90" "9c" "a8" "b4" 
[14,] "00" "0d" "1a" "27" "34" "41" "4e" "5b" "68" "75" "82" "8f" "9c" "a9" "b6" "c3" 
[15,] "00" "0e" "1c" "2a" "38" "46" "54" "62" "70" "7e" "8c" "9a" "a8" "b6" "c4" "d2" 
[16,] "00" "0f" "1e" "2d" "3c" "4b" "5a" "69" "78" "87" "96" "a5" "b4" "c3" "d2" "e1" 
answered Dec 17, 2016 at 10:28
\$\endgroup\$
2
  • 2
    \$\begingroup\$ How about: as.hexmode(outer(0:15,0:15,`*`)) \$\endgroup\$ Commented Feb 25, 2017 at 0:41
  • 3
    \$\begingroup\$ Or better yet, as.hexmode(0:15%o%0:15) \$\endgroup\$ Commented Sep 5, 2017 at 14:13
11
\$\begingroup\$

Bash, 38

  • 1 byte saved thanks to @MitchellSpector
  • 2 bytes saved thanks to @roblogic
printf %02x\ $[{0..15}*{0..15}]|rs 16
  • Bash expands brace expansions before arithmetic expansions, so the string $[{0..15}*{0..15}] first expands to $[0*0] $[0*1] $[0*2] ... $[0*15] $[1*0] ... $[15*15].
  • The above series of arithmetic expansions then expand to the numerical table contents, as decimal integers.
  • The printf '%02x ' expresses this list of decimal integers as hex, zero-padded to two characters
  • rs 16 reshapes the output to 16 columns wide.

Try it online!


Alternative solution:

Bash + jot, 38

eval '
jot -s\ -w%02x 16 0 - '{0..15}

Try it online!

answered Dec 17, 2016 at 1:37
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Nice solution. It looks like you can shave one byte off by using fmt -52 (without the w). \$\endgroup\$ Commented Dec 18, 2016 at 9:55
  • \$\begingroup\$ nice! btw. in zsh it could be {0..15}\*{0..15} which is 2 bytes shorter :) \$\endgroup\$ Commented Mar 16, 2019 at 19:58
  • 1
    \$\begingroup\$ 38 bytes using rs 16 instead of fmt -52 \$\endgroup\$ Commented Aug 15, 2024 at 4:29
5
\$\begingroup\$

C#6, 98 bytes

()=>{int i,j;for(i=-1;++i<16;)for(j=-1;++j<16;)System.Console.Write($"{i*j:x2} {j<15?"":"\n"}");};

repl.it demo

Standard nested for-loop. Only trick is to print newline when j>=15.

answered Dec 17, 2016 at 6:12
\$\endgroup\$
1
  • \$\begingroup\$ @Metoniem tio.run/# is much superior \$\endgroup\$ Commented Mar 16, 2019 at 21:48
4
\$\begingroup\$

JavaScript (ES6), (削除) 79 (削除ここまで) (削除) 78 (削除ここまで) 77 bytes

f=(i=256)=>i?f(--i)+(i%16*(i>>4)+256).toString(16).slice(1)+`
 `[~i&15&&1]:``
document.write('<pre>'+f())

Edit: Saved 1 byte thanks to @ETHproductions and another byte thanks to @YairRand.

answered Dec 17, 2016 at 12:45
\$\endgroup\$
4
  • \$\begingroup\$ @ETHproductions Bah, the .slice(-2) was left over from when I was doing ('0'+toString(16)). I think I'd already tried ' \n'[+!(~i&15)] but it's the same length. \$\endgroup\$ Commented Dec 17, 2016 at 22:01
  • \$\begingroup\$ @ETHproductions I also saved 1 bytes... \$\endgroup\$ Commented Dec 17, 2016 at 22:14
  • \$\begingroup\$ You can save a byte by replacing (~i&15?' ':'\n') with ' \n'[~i&15&&1] . \$\endgroup\$ Commented Feb 7, 2019 at 4:57
  • \$\begingroup\$ @YairRand I think you mean '\n ' but I get the idea, thanks! \$\endgroup\$ Commented Feb 7, 2019 at 10:21
4
\$\begingroup\$

Haskell, 87 bytes

import Numeric
main=mapM(\x->putStrLn$do y<-s;['0'|x*y<16]++showHex(x*y)" ")s
s=[0..15]

Try it online!

I imagine there's a better way. Maybe depend on the printf package....

answered Mar 15, 2019 at 21:15
\$\endgroup\$
1
4
\$\begingroup\$

K7, 36 bytes

` 0:" "/:'{`hex@`c$x}''{x*/:\:x}@!16
answered Mar 16, 2019 at 14:15
\$\endgroup\$
2
  • \$\begingroup\$ " "/:'(`hex@`c$)''x*/:x:!16 should do it \$\endgroup\$ Commented Apr 14, 2019 at 22:39
  • 1
    \$\begingroup\$ Better yet: (" "/:`hex@')'x*/:x:`c$!16 (26 bytes) \$\endgroup\$ Commented Apr 14, 2019 at 22:47
3
\$\begingroup\$

Stax, 11 bytes

äΔ←ùûv╚ö♦.J

Run and debug it

answered Mar 1, 2019 at 0:48
\$\endgroup\$
3
\$\begingroup\$

MATL, (削除) 19 (削除ここまで) 18 bytes

16:q&*1YAO3Z(!48e!

Try it online!

16:q % Push [0 1 ... 15]
&* % ×ばつ16 matrix of pairwise products
1YA % Convert to hexadecimal. Gives a ×ばつ2 char array 
O3Z( % Assign char 0 to 3rd column. Gives a ×ばつ3 char array
!48e! % Reshape in row-major order as a 48-column char array
 % Implicitly display. Char 0 is shown as space
answered Dec 17, 2016 at 1:37
\$\endgroup\$
3
\$\begingroup\$

Ruby, 49 bytes

256.times{|i|print"%02x "%(i/16*j=i%16),$/*j/=15}

Pretty straightforward use of the % operator equivalent to sprintf.

$/ is the line separator variable (\n by default.)

Note the use of assignments such as j/=15 to avoid longer parentheses (j/15)

answered Dec 17, 2016 at 2:55
\$\endgroup\$
3
\$\begingroup\$

PowerShell, 46 bytes

0..15|%{$i=$_;"$(0..15|%{"{0:X2}"-f($i*$_)})"}

Try it online!

Loops from 0 to 15, sets $i to be that current number, then loops again. Uses the -format operator with the X2 designation to specify the output is heXadecimal padded to 2 spaces with leading zeros.

Of special note, and really the only golf, is that instead of using a (...)-join' ' to take the hex results, encapsulate them in an array, and concatenate them together into a string, we leverage the fact that the default $OutputFieldSeparator value for stringifying an array is a space. That means we can do a string with a script block in it "$(...)" instead, saving 6 bytes.

Those strings are all left on the pipeline, and output via implicit Write-Output at program completion gives us a newline between them for free.

answered Dec 17, 2016 at 7:31
\$\endgroup\$
3
\$\begingroup\$

Python 3, 55 bytes

r=range(16)
for x in r:print(*['%02x'%(x*y)for y in r])

Using %formatting saves quite a few bytes over [2:] usage. So does using * splats on the print function.

answered Feb 8, 2019 at 19:32
\$\endgroup\$
3
\$\begingroup\$

Japt -R, (削除) 20 (削除ここまで) 15 bytes

GÆGÇ*X sGÃùT2 ̧

Try It Online!

GÆGÇ*X sGÃùT2 ̧
G :16
 Æ :Map each X in the range [0,G)
 GÇ : Map the range [0,G)
 *X : Multiply by X
 sG : Convert to base-16 string
 Ã : End map
 ù : Left pad each
 T : With 0
 2 : To length 2
 ̧ : Join with spaces
 :Implicitly join with newlines and output
answered Aug 22, 2017 at 10:42
\$\endgroup\$
2
  • \$\begingroup\$ You just as easily could've done ® instead of Ë ;P \$\endgroup\$ Commented Aug 22, 2017 at 18:05
  • \$\begingroup\$ @ETHproductions: Yeah, but I wanted to play with the shiny new shortcut! :D \$\endgroup\$ Commented Aug 22, 2017 at 18:07
3
\$\begingroup\$

QBasic, 73 bytes

FOR x=0TO 15
FOR y=0TO 15
?HEX$(x*y16円);HEX$(x*y MOD 16);" ";
NEXT
?
NEXT

I golfed a custom procedure for converting to hex digits, before I realized there's a builtin for that. Now my code is shorter and more boring. :^(

Original 103-byte code:

FOR x=0TO 15
FOR y=0TO 15
p x*y16円
p x*y MOD 16
?" ";
NEXT
?
NEXT
SUB p(d)
?CHR$(48+d-7*(d>9));
END SUB
answered Mar 15, 2019 at 21:34
\$\endgroup\$
3
\$\begingroup\$

Factor, 56 bytes

16 iota dup '[ _ [ * "%02X "printf ] with each nl ] each

Try it online!

I went through a progression as I realized matrix words are too long:

{ 16 16 } matrix-coordinates [ Π "%02X"sprintf ] matrix-map simple-table.
{ 16 16 } matrix-coordinates [ [ Π "%02X "printf ] each nl ] each
16 iota dup [ * "%02X"sprintf ] cartesian-map simple-table.
16 iota [ 16 iota [ * "%02X "printf ] with each nl ] each
16 iota dup '[ _ [ * "%02X "printf ] with each nl ] each
answered May 30, 2021 at 5:22
\$\endgroup\$
2
\$\begingroup\$

Mathematica, 46 bytes

Grid@Array[IntegerString[1##,16,2]&,{16,16},0]

Straightforward implementation using the built-in IntegerString, in base 16, padding to length 2. The Array[...,{16,16},0] has the two variables each run from 0 to 15.

answered Dec 17, 2016 at 6:27
\$\endgroup\$
2
\$\begingroup\$

Matlab, 53 Bytes

for i=[0:15]'*[0:15];fprintf('%02X ',i);disp(' ');end

Sample output:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E 
00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D 
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 
00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 
00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A 
00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 
00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 
00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 
00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 
00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4 
00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3 
00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2 
00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1 
answered Dec 17, 2016 at 12:47
\$\endgroup\$
1
  • \$\begingroup\$ Try it online!(sort of...) \$\endgroup\$ Commented Dec 28, 2016 at 21:02
2
\$\begingroup\$

Perl, 48 bytes

for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%}

Try it online!

I'm positive this isn't optimally golfed, but I'll be damned if I can find something better.

Code breakdown:

for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%}
 0..15 #Create a list of the range 0 - 15...
 @%= #...and store it in the array @%
for$a( ){ } #Loop through @% with $a as the iterator
 printf[ string ],[ params ] #Perl's port of the standard printf function
 "%02x " #2-digit (hexit?) padding, followed by space...
 x@% #...repeated 16 times (in scalar context, @% represents the size of array @%)...
 .$/ #...followed by a newline
 map$a*$_,@% #Loops through @%, and using $_ as the iterator, returns a list composed of each member of @% multiplied by the current $a
answered Dec 17, 2016 at 19:28
\$\endgroup\$
2
\$\begingroup\$

Perl 6, 42 bytes

.fmt("%02x").put for (^16 X*^16).rotor: 16

Try it

Expanded:

.fmt("%02x") # format each element of list to lowercase hex
.put # print with trailing newline
for # for each of the following
(
 ^16 # Range upto ( and excluding ) 16
 X* # cross multiplied with
 ^16
).rotor: 16 # break it up into chunks of 16 values
answered Dec 17, 2016 at 21:46
\$\endgroup\$
2
\$\begingroup\$

JavaScript, 104 Bytes

s="";for(a=0;16>a;a++){for(b=0;16>b;b++)c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c);s+="\n"}

Call using variable s:

console.log("HEX Table: " + s)

Ungolfed code:

s=""; // Define s as empty string
for(a=0;16>a;a++){ // For y axis
 for(b=0;16>b;b++) // For x axis
 c=(a*b).toString(16),s=1==c.length?s+(" 0"+c):s+(" "+c); // Multiply and format
 s+="\n" // Add line breaks
}
answered Dec 28, 2016 at 19:58
\$\endgroup\$
3
  • \$\begingroup\$ Isn't "\n" line break? Wow, someone used pure ECMA for once. \$\endgroup\$ Commented Dec 28, 2016 at 22:47
  • \$\begingroup\$ And you should be able to use s+=2>c.length?" 0"+c:" "+c. \$\endgroup\$ Commented Dec 28, 2016 at 22:49
  • \$\begingroup\$ I know this is old, but I noticed a few savings that might help in future challenges too! you can set both a and s to "" since ""*0 is still 0. It's possible to inline your b++ to where it's being used in a*b too for a another slight saving, but if you rewrite the string append to: s+=" "+(0+(a*b++).toString(16)).substr(-2) that'll save a chunk. Should be at 86 bytes with those! Hope that helps! \$\endgroup\$ Commented Aug 22, 2017 at 7:39
2
\$\begingroup\$

C, 61 bytes

i;f(){while(i<256)printf("%02x%c",i%16*(i>>4),++i%16?32:10);}

Wandbox

answered Jan 4, 2017 at 1:27
\$\endgroup\$
1
  • \$\begingroup\$ is that i implicitly deduced as int a standard feature of C? \$\endgroup\$ Commented Jan 4, 2017 at 2:17
2
\$\begingroup\$

C, (削除) 68 (削除ここまで) 66 bytes

f(i){for(i=0;i<256;)printf("%02x%c",i%16*(i++/16),i%16<15?32:10);}

-2 bytes thanks to ceilingcat!

Ungolfed:

f(i){
 for(i=0; i<256;)
 printf("%02x%c", i%16*(i++/16), i%16<15 ? 32 : 10);
}

Prints the zero padded result and either space or newline.

answered Dec 18, 2016 at 2:08
\$\endgroup\$
5
  • \$\begingroup\$ Is that i implicitly deduced as int a standard feature of C? \$\endgroup\$ Commented Jan 4, 2017 at 2:18
  • \$\begingroup\$ @sergiol yes, int is the default assumption. \$\endgroup\$ Commented Jan 4, 2017 at 7:51
  • \$\begingroup\$ Sadly the output is undefined according to C standard (C99 - 6.5.2.2 Function calls). \$\endgroup\$ Commented Aug 22, 2017 at 11:58
  • \$\begingroup\$ Suggest ~i%16 instead of i%16<15 \$\endgroup\$ Commented Feb 7, 2019 at 19:24
  • \$\begingroup\$ How about f(i){for(i=-1;i++<256;)printf("%c%02x",i&15?32:10,i%16*(i/16));}? \$\endgroup\$ Commented Aug 16, 2024 at 10:42
2
\$\begingroup\$

APL (Dyalog), (削除) 44 (削除ここまで) (削除) 43 (削除ここまで) (削除) 36 (削除ここまで) 33 bytes

10 bytes saved thanks to @Adám

Crossed out 44 is still regular 44 ;(

↑,/{(⎕D,⎕A)[16 16⊤⍵],' '} ×ばつ⍨⍳16

Uses ⎕IO←0.

Try it online!

How?

×ばつ⍨⍳16 - multiplication table of 0 .. 15

̈ - for each item

16 16⊤⍵ - take the first 2 digits of hexadecimal encoding

(⎕D,⎕A)[...] - index into "0123456789ABCDEF..."

,' ' - append space

,/ - join each row

- and columnify

Output

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E 
00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D 
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 
00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 
00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A 
00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 
00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 
00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 
00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 
00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 
00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4 
00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3 
00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2 
00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1 
answered Oct 26, 2017 at 22:10
\$\endgroup\$
3
2
\$\begingroup\$

J, 22 bytes

echo,.3{."1 hfd*/~i.16

Try it online!

answered Oct 26, 2017 at 23:19
\$\endgroup\$
2
\$\begingroup\$

Julia, (削除) 83 (削除ここまで) 75 bytes

r=0:15;[([print(num2hex(i*j)[15:16]," ")for i in r],print('\n'))for j in r]
\$\endgroup\$
1
  • \$\begingroup\$ Try it online \$\endgroup\$ Commented Aug 3, 2024 at 13:41
2
\$\begingroup\$

PHP, (削除) 57 (削除ここまで) 56 bytes

while($z<256)printf("
"[$x=$z%16]."%02x ",$x*($z++>>4));

Run with -nr or try it online.

(削除) Note the trailing space in the first line! (削除ここまで) One byte saved by @gwaugh.

answered Aug 22, 2017 at 19:38
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can -1 byte by eliminating the ! and moving the space to the end of the "%02x ". tio.run/… \$\endgroup\$ Commented Feb 7, 2019 at 21:13
2
\$\begingroup\$

Forth (gforth), 65 bytes

: f 16. do cr 16. do i j * 16 /mod hex 1 .r . decimal loop loop ;

Try it online!

Explanation

Nested loop from 0 to 15. Each Iteration:

  • multiply row and column numbers to get result
  • split into first and second digit (first digit will be 0 if result < 16)
  • set base to 16 (hexadecimal)
  • print first digit with no space
  • print second digit with space
  • set base to 10 (decimal)

Code Explanation

: f \ start new word definition
 16. do \ outer loop from 0 to 15
 cr \ output newline
 16. do \ inner loop from 0 to 15
 i j * \ multiply loop indexes
 16 /mod \ get quotient and remainder of dividing by 16
 hex \ set base to 16
 1 .r \ print quotient (equivalent to first digit) right-aligned in space of 1 (no space)
 . \ print second digit (with space)
 decimal \ set base back to 10 (decimal)
 loop \ end inner loop
 loop \ end outer loop
; \ end word definition
answered Feb 8, 2019 at 19:44
\$\endgroup\$
2
\$\begingroup\$

C# (Visual C# Interactive Compiler), 67 bytes

for(int i=0;i<256;)Write($"{(i%16<1?"\n":"")} {i/16*(i++%16):X2}");

Try it online!

answered Mar 15, 2019 at 20:07
\$\endgroup\$
2
\$\begingroup\$

APL(NARS), 42 chars, 84 bytes

{{(⎕D,⎕A)[1+16∣(⌊⍵÷16),⍵]} ×ばつ/ ̈m∘.,m←0,⍳15}

I copy something from others... ×ばつ/ ̈m∘.,m←0,⍳15 would build the multiplication table of 0,⍳15; the function {(⎕D,⎕A)[1+16∣(⌊⍵÷16),⍵]} convert each number in the multiplication table in hex for only 2 digits.

 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
 00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E 
 00 03 06 09 0C 0F 12 15 18 1B 1E 21 24 27 2A 2D 
 00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 
 00 05 0A 0F 14 19 1E 23 28 2D 32 37 3C 41 46 4B 
 00 06 0C 12 18 1E 24 2A 30 36 3C 42 48 4E 54 5A 
 00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 
 00 08 10 18 20 28 30 38 40 48 50 58 60 68 70 78 
 00 09 12 1B 24 2D 36 3F 48 51 5A 63 6C 75 7E 87 
 00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 
 00 0B 16 21 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 
 00 0C 18 24 30 3C 48 54 60 6C 78 84 90 9C A8 B4 
 00 0D 1A 27 34 41 4E 5B 68 75 82 8F 9C A9 B6 C3 
 00 0E 1C 2A 38 46 54 62 70 7E 8C 9A A8 B6 C4 D2 
 00 0F 1E 2D 3C 4B 5A 69 78 87 96 A5 B4 C3 D2 E1 

I see how using functions and ̈ problems are break in simple problems...

answered Mar 16, 2019 at 9:16
\$\endgroup\$
1
2 3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.