Print the f × f times table

46

4

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.

Esolanging Fruit

Posted 2016-12-17T01:16:15.437

Reputation: 13 542

Related – Luis Mendo – 2016-12-17T01:18:02.700

Also related

– Digital Trauma – 2016-12-17T01:45:58.540

4Multiplication tables don't usually include factor 0... :-) – Luis Mendo – 2016-12-17T01:55:14.777

28@Luis Mendo: How else will school children be able to memorize what 0 times a number is? :P – milk – 2016-12-17T01:56:11.837

@milk It's simpler in many languages to start counting from 0. – Esolanging Fruit – 2016-12-21T02:59:28.310

1Darn, I wanted to make a solution using hexdump, but that groups into 4-byte blocks. :( – HyperNeutrino – 2017-02-26T01:04:21.213

@HyperNeutrino: You can tell how to format, with eg. hexdump -e'16/1 "%02X "" "'.

– ბიმო – 2019-03-16T20:03:54.080

Can we have more space between columns if we're consistent? – Adám – 2019-07-10T23:46:30.527

Answers

2

Stax, 11 bytes

äΔ←ùûv╚ö♦.J

Run and debug it

recursive

Posted 2016-12-17T01:16:15.437

Reputation: 8 616

14

Jelly, 12 bytes

⁴Ḷ×þ`d⁴‘ịØhG

Try it online!

How it works

⁴Ḷ×þ`d⁴‘ịØhG  Main link. No arguments.

⁴             Set the return value to 16.
 Ḷ            Unlength; yield [0, ..., 15].
  ×þ`         Build the multiplication table of [0, ..., 15] and itself.
     d⁴       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.

Dennis

Posted 2016-12-17T01:16:15.437

Reputation: 196 637

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 https://mothereff.in/byte-counter

– Ciprum – 2016-12-18T20:45:34.277

18

In UTF-8, sure. However, Jelly uses a SBCS, so each character can be encoded using a single byte.

– Dennis – 2016-12-18T20:59:11.253

14

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.

Dennis

Posted 2016-12-17T01:16:15.437

Reputation: 196 637

11

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" 

JAD

Posted 2016-12-17T01:16:15.437

Reputation: 2 898

1How about:

as.hexmode(outer(0:15,0:15,`*`)) – ixodesbeta – 2017-02-25T00:41:50.513

2Or better yet, as.hexmode(0:15%o%0:15) – Giuseppe – 2017-09-05T14:13:37.257

10

Bash + coreutils, 40

  • 1 byte saved thanks to @MitchellSpector
printf %02x\  $[{0..15}*{0..15}]|fmt -52
  • 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
  • fmt -52 formats the integers as 47 character wide lines, giving the desired alignment. Note fmt tries to make lines goal characters wide. By default, this is 7% shorter than width. 52*93% -1 (for newline) = 47.

Try it online.

Digital Trauma

Posted 2016-12-17T01:16:15.437

Reputation: 64 644

1Nice solution. It looks like you can shave one byte off by using fmt -52 (without the w). – Mitchell Spector – 2016-12-18T09:55:07.593

nice! btw. in zsh it could be {0..15}\*{0..15} which is 2 bytes shorter :) – ბიმო – 2019-03-16T19:58:31.457

5

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.

Link Ng

Posted 2016-12-17T01:16:15.437

Reputation: 593

+1, but it seems repl.it doesn't like $"" – Metoniem – 2017-02-22T10:25:14.780

@Metoniem https://tio.run/# is much superior

– HyperNeutrino – 2019-03-16T21:48:32.423

4

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.

Neil

Posted 2016-12-17T01:16:15.437

Reputation: 95 035

@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. – Neil – 2016-12-17T22:01:59.993

@ETHproductions I also saved 1 bytes... – Neil – 2016-12-17T22:14:26.630

You can save a byte by replacing (~i&15?' ':'\n') with ' \n'[~i&15&&1] . – Yair Rand – 2019-02-07T04:57:45.873

@YairRand I think you mean '\n ' but I get the idea, thanks! – Neil – 2019-02-07T10:21:07.050

3

MATL, 19 18 bytes

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

Try it online!

16:q   % Push [0 1 ... 15]
&*     % 16×16 matrix of pairwise products
1YA    % Convert to hexadecimal. Gives a 256×2 char array 
O3Z(   % Assign char 0 to 3rd column. Gives a 256×3 char array
!48e!  % Reshape in row-major order as a 48-column char array
       % Implicitly display. Char 0 is shown as space

Luis Mendo

Posted 2016-12-17T01:16:15.437

Reputation: 87 464

3

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.

AdmBorkBork

Posted 2016-12-17T01:16:15.437

Reputation: 41 581

3

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....

dfeuer

Posted 2016-12-17T01:16:15.437

Reputation: 1 016

2

Using no imports you could do mapM(pure"0123456789abcdef")".."!!(x*y)++" " for the same bytecount, but you're right with printf 81 bytes.

– ბიმო – 2019-03-16T01:09:51.697

3

K7, 36 bytes

` 0:" "/:'{`hex@`c$x}''{x*/:\:x}@!16

yiyus

Posted 2016-12-17T01:16:15.437

Reputation: 31

" "/:'(\hex@`c$)''x*/:x:!16` should do it – Alexander Belopolsky – 2019-04-14T22:39:08.357

Better yet: (" "/:\hex@')'x*/:x:`c$!16` (26 bytes) – Alexander Belopolsky – 2019-04-14T22:47:17.943

2

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)

Level River St

Posted 2016-12-17T01:16:15.437

Reputation: 22 049

2

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.

Greg Martin

Posted 2016-12-17T01:16:15.437

Reputation: 13 940

2

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 

Owen Morgan

Posted 2016-12-17T01:16:15.437

Reputation: 221

Try it online!(sort of...) – Pavel – 2016-12-28T21:02:39.783

2

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

Gabriel Benamy

Posted 2016-12-17T01:16:15.437

Reputation: 2 827

2

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

Brad Gilbert b2gills

Posted 2016-12-17T01:16:15.437

Reputation: 12 713

2

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.

Karl Napf

Posted 2016-12-17T01:16:15.437

Reputation: 4 131

Is that i implicitly deduced as int a standard feature of C? – sergiol – 2017-01-04T02:18:31.700

@sergiol yes, int is the default assumption. – Karl Napf – 2017-01-04T07:51:36.203

Sadly the output is undefined according to C standard (C99 - 6.5.2.2 Function calls). – Jasmes – 2017-08-22T11:58:14.563

Suggest ~i%16 instead of i%16<15 – ceilingcat – 2019-02-07T19:24:59.003

2

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
}

Julian Lachniet

Posted 2016-12-17T01:16:15.437

Reputation: 3 216

Isn't "\n" line break? Wow, someone used pure ECMA for once. – Zacharý – 2016-12-28T22:47:19.720

And you should be able to use s+=2>c.length?" 0"+c:" "+c. – Zacharý – 2016-12-28T22:49:27.227

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! – Dom Hastings – 2017-08-22T07:39:32.920

2

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

Shaggy

Posted 2016-12-17T01:16:15.437

Reputation: 24 623

You just as easily could've done ® instead of Ë ;P – ETHproductions – 2017-08-22T18:05:23.977

@ETHproductions: Yeah, but I wanted to play with the shiny new shortcut! :D – Shaggy – 2017-08-22T18:07:08.217

2

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.

Beefster

Posted 2016-12-17T01:16:15.437

Reputation: 6 651

1

Python 2, 112 109 100 96 73 Bytes

R=range(16)
for i in R:print' '.join('0'*(i*j<16)+hex(i*j)[2:]for j in R)

Try it online!

  • saved 3 bytes: Thanks to Wheat Wizard; predefined range(16) into R which is used twice.
  • saved 9 bytes: Crunched up the earlier if statement into a single statement.
  • saved 4 bytes: crunched the statements in 2nd 'for' block.
  • saved 23 bytes: Thanks @J843136028: used list comprehension

officialaimm

Posted 2016-12-17T01:16:15.437

Reputation: 2 739

1You can predefine range(16) with R=range(16) and replace each instance of range(16) with R. – Post Rock Garf Hunter – 2016-12-17T05:07:27.203

1You can use list comprehension and starred expressions to save variables. See my answer (currently below). – 0WJYxW9FMN – 2017-08-21T18:51:43.060

Thanks, @J843136028 I did some changes and got to 73 bytes, and kept it a bit different than your answer. :) – officialaimm – 2017-08-22T11:41:09.433

1

Python2, 102 97 92 90 89 bytes

i=1
exec"print' '.join('%02x'%(j-x)*(i>0)for x,j in enumerate(range(0,16*i,i)));i+=1;"*16

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

Try it online!

Yytsi

Posted 2016-12-17T01:16:15.437

Reputation: 3 582

1

Octave, 34 bytes

disp(num2str((a=0:15)'*a,'%02x '))

rahnema1

Posted 2016-12-17T01:16:15.437

Reputation: 5 435

1

05AB1E, 17 bytes

16F15ÝN*8o+h€¦ðý»

Try it online!

16F               For N in [0,15]
   15Ý            Push [0, ..., 15]
      N*          Multiply by N
        8o+       Add 256
           h      Take the uppercase hexadecimal representation
            €¦    Remove the leading 1 of each value
              ðý  Join with spaces
                » End for and join everything with newlines

There might be a better way to handle this in 05AB1E.

Osable

Posted 2016-12-17T01:16:15.437

Reputation: 1 321

8o can be to save a byte. Although you're right that there might be a better way. :) – Kevin Cruijssen – 2019-03-21T09:42:28.220

Indeed! ;) Such commands didn't exist back then; pushing 256 was the 2-byte command žz. See Info.txt on November 12th 2016. Nice to see that the language is still evolving and that people use it :D .

– Osable – 2019-03-22T13:32:23.853

Ah ok. I knew the small number constants are pretty new, but thought the for 256 was there longer. But I see your answer is from December 2016, so I can understand it wasn't there yet at the time. :) I've seen some 05AB1E answers from 2016 that didn't even had implicit input yet.. – Kevin Cruijssen – 2019-03-22T13:41:35.080

1

VBA, 66 bytes

For m=0To 15:For n=0To 15:?Right(Hex(256+n*m)&" ",3);:Next:?:Next

Enter in Immediate window in VBA editor. Adding 256 to the expression to convert to hexadecimal is only shorter because the concatenater "&" requires a space after it to separate from alphabetic strings.

Joffan

Posted 2016-12-17T01:16:15.437

Reputation: 832

Alternatively you could use For m=0To 15:For n=0To 15:?Right("0"+Hex(n*m)+" ",3);:Next:?:Next for the same bytecount (which is 65 not 66 by the way) – Taylor Scott – 2017-08-22T17:57:56.187

1

C, 61 bytes

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

Wandbox

o79y

Posted 2016-12-17T01:16:15.437

Reputation: 509

is that i implicitly deduced as int a standard feature of C? – sergiol – 2017-01-04T02:17:19.370

1

SmileBASIC, 56 51 47 bytes

I=RND(16)J=RND(16)LOCATE I*3,J?HEX$(I*J,2)EXEC.

12Me21

Posted 2016-12-17T01:16:15.437

Reputation: 6 110

1

k, 50 bytes

`0:" "/'("0123456789abcdef"@16 16\)''{x*\:/:x}@!16

Alas, it is hindered by the lack of a built-in hexadecimal printer.

Reading right-to-left, more-or-less:

                                               !16 / make the array {0, 1, 2, ..., 15}
                                     {x*\:/:x}@    / cartesian product of the array multiplied by itself, results in a table
        (                         )''              / for each row, for each column
                            16 16\                 / decode int to two digits in base 16
         "0123456789abcdef"@                       / get the characters to form a string
   " "/'                                           / join the columns with a space, the table is now an array 
`0:                                                / print the array, each element is one line

zgrep

Posted 2016-12-17T01:16:15.437

Reputation: 1 291

1

///, 588 bytes

/;/\/ //|/\/\///A/00 |B/
A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9 B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6FfG8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 96 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1 

A more readable version with newlines:

/]
[///;/\/ //|/\/\///A/00 |B/
A|C;0|D;1|E;2|F;3|G;4|H;5|I;6|J;7|K;8/]
[AAAAAAAAAAAAAAAAB01C2C3C4C5C6C7C8C9CaCbCcCdCeCf ]
[B02C4C6C8CaCcCeD0D2D4D6D8DaDcDe B03C6C9CcCfD2D5D]
[8DbDeE1E4E7EaEd B04C8CcD0D4D8DcE0E4E8EcF0F4F8Fc ]
[B05CaCfD4D9DeE3E8EdF2F7FcG1G6Gb B06CcD2D8DeE4EaF]
[0F6FcG2G8GeH4Ha B07CeD5 1cE3EaF1F8FfG6GdH4HbI2I9]
[ B08D0D8E0E8F0F8G0G8H0H8I0I8J0J8 B09D2DbE4EdF6Ff]
[G8H1HaI3IcJ5JeK7 B0aD4DeE8F2FcG6H0HaI4IeJ8K2Kc 9]
[6 B0b 16E1EcF7G2Gd 58I3IeJ9K4Kf 9a a5 B0c 18E4F0]
[FcG8 54I0IcJ8K4 90 9c a8 b4 B0d 1aE7F4G1GeHbI8J5]
[K2Kf 9c a9 b6 c3 B0eDcEaF8G6H4I2J0JeKc 9a a8 b6 ]
[c4 d2 B0fDeEdFcGb 5aI9J8K7 96 a5 b4 c3 d2 e1 

Pretty simple if you know how /// works. It's just a few string replacements.

Esolanging Fruit

Posted 2016-12-17T01:16:15.437

Reputation: 13 542

1

///, 544 bytes

Well, everyone's doing /// answers now:

/|/\/\///Z/\/ |P/
0B|MZ9|LZ8|KZ7|JZ6|IZ5|HZ4|GZ3|FZ2|EZ1|C/BBB|B/0A|AZ0/0CCCCC0P1A2A3A4A5A6A7A8A9AaAbAcAdAeAfP2A4A6A8AaAcAeE0E2E4E6E8EaEcEeP3A6A9AcAfE2E5E8EbEeF1F4F7FaFdP4A8AcE0E4E8EcF0F4F8FcG0G4G8GcP5AaAfE4E9EeF3F8FdG2G7GcH1H6HbP6AcE2E8EeF4FaG0G6GcH2H8HeI4IaP7AeE5EcF3FaG1G8GfH6HdI4IbJ2J9P8E0E8F0F8G0G8H0H8I0I8J0J8K0K8P9E2EbF4FdG6GfH8I1IaJ3JcK5KeL7PaE4EeF8G2GcH6I0IaJ4JeK8L2LcM6PbE6F1FcG7H2HdI8J3JeK9L4LfMa a5PcE8F4G0GcH8I4J0JcK8L4M0Mc a8 b4PdEaF7G4H1HeIbJ8K5L2LfMc a9 b6 c3PeEcFaG8H6I4J2K0KeLcMa a8 b6 c4 d2PfEeFdGcHbIaJ9K8L7M6 a5 b4 c3 d2 e1

I replaced \s0 through \s9 with A then E through M, 0 0 with C, \n00 0 with P, /\s with Z and finally // with |, adding all these at the front of the code as I went.

Try it online!

boboquack

Posted 2016-12-17T01:16:15.437

Reputation: 2 017

1

Python 3, 66 bytes

r=range(16)
for i in r:print(*[('0'+hex(j*i)[2:])[-2:]for j in r])

0WJYxW9FMN

Posted 2016-12-17T01:16:15.437

Reputation: 2 663

1

Perl 5, 45 bytes

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

Try it online!

Xcali

Posted 2016-12-17T01:16:15.437

Reputation: 7 671

1

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.

Titus

Posted 2016-12-17T01:16:15.437

Reputation: 13 814

1

You can -1 byte by eliminating the ! and moving the space to the end of the "%02x ". https://tio.run/##K8go@G9jXwAkyzMyc1I1VCpsjEzNNAuKMvNK0jSUuJSiVSptVSpUDc1i9dRVDYwqFNR1VCq1gOq0te3sTDQ1rf//BwA

– 640KB – 2019-02-07T21:13:10.277

1

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 

Uriel

Posted 2016-12-17T01:16:15.437

Reputation: 11 708

36, just by removing no-ops and using a variable: ⍪' ',⍨G G 2⍴⍉(⎕D,⎕A)[G⊥⍣¯1∘.×⍨⍳G←16]

– Adám – 2017-10-26T22:26:55.940

@Adám thanks! I was just about to edit some of these changes, but yours is shorter – Uriel – 2017-10-26T22:30:40.320

33: ↑,/{(⎕D,⎕A)[16 16⊤⍵],' '}¨∘.×⍨⍳16

– Adám – 2017-10-26T22:39:32.757

1

Java 8, 98 90 79 bytes

v->{for(int i=0;i<256;System.out.printf("%02x%c",i/16*(i++%16),i%16<1?10:32));}

Explanation:

Try it here.

v->{                    // Method with empty unused parameter and no return-type
  for(int i=0;          //  Index-integer, starting at 0
      i<256;            //  Loop from 0 to 256
    System.out.printf(  //   Print with format:
      "%02x             //    the lowercase 2-digit hexadecimal representation
           %c",         //    + a character
       i/16             //     `i` divided by 16 (integer division in Java truncates)
       *(i++%16)        //     multiplied by `i` modulo-16
                        //     (and increase `i` by 1 afterwards with `i++`)
       i%16<1?          //     If `i` is now a multiple of 16:
        10              //      Replace `%c` with a new-line
       :                //     Else:
        32)             //      Replace `%c` with a space instead
  );                    //  End of loop
}                       // End of method

Kevin Cruijssen

Posted 2016-12-17T01:16:15.437

Reputation: 67 575

1@OlivierGrégoire Oops.. thanks for noticing. Back to 79 bytes (although old 79-byte answer was i%16*(i>>4), but I like i/16 more than i>>4. – Kevin Cruijssen – 2017-10-27T11:22:47.790

1

Julia, 83 75 bytes

r=0:15;[([print(num2hex(i*j)[15:16]," ")for i in r],print('\n'))for j in r]

EricShermanCS

Posted 2016-12-17T01:16:15.437

Reputation: 121

1

Ink, 169 167 161 bytes

VAR r=-1
-(l)
~temp c=0
~r++
{r>15:->END}
-(v)
{h((r*c)/16)}{h(r*c)}
~c++
{c>15:->l}<> ->v
==function h(n)
{n%16-10:
-0:a
-1:b
-2:c
-3:d
-4:e
-5:f
-else:{n%16}
}

Try it online!

Ungolfed

VAR row=-1                                  // Declare a global variable which keeps track of the current row.
-(line)                                     // A named gather point, which can be jumped to later.

~temp column = 0                            // Declare a local varialbe called column, and set it to 0. Locals use 2 bytes more than globals, but they also reset the value if the line is later reached again.
~row++                                      // Increment the row counter.
{row>15:->END}                              // If we're about to start a 17th row, we terminate the program instead. If not, we continue onwards...

-(number)                                   // Another place to jump to
{digit((row*column)/16)}{digit(row*column)} // Calculate the two digits of the number and pass each of them to the digit function defined below to print them.
~column++                                   // Increment the column counter
{column>15:->row}<> ->number                // If we're done with this row we divert to row, to print another row. Otherwise, we concatenate a space to this row and divert to number.

== function digit(n) ==                     // Declare a function which prints a single hex digit.
{n%16-10:                                   // Multi-line conditional - basically a switch statement.
-0:a                                        // If n mod 16 is 10, write an a
-1:b                                        // If it's 11, write a b
-2:c                                        // ...etc...
-3:d
-4:e
-5:f
-else:{n%16}                                // If none of those matched, write n mod 16, as it'll be the same in hex and decimal
}                                           // End of conditional, and also of the function - it doesn't return anything.

Edit: Saved 2 bytes by using stitches instead of knots.
Edit: Saved 3 bytes by tweaking the printing function, and another 3 bytes by rewriting the main logic to use gathers instead of stitches.

Sara J

Posted 2016-12-17T01:16:15.437

Reputation: 2 576

Hello and welcome to PPCG. Would it be possible to provide an online testing environment for ease of verification of your solution? – Jonathan Frech – 2019-02-09T01:14:27.230

1

QBasic, 73 bytes

FOR x=0TO 15
FOR y=0TO 15
?HEX$(x*y\16);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*y\16
p x*y MOD 16
?" ";
NEXT
?
NEXT
SUB p(d)
?CHR$(48+d-7*(d>9));
END SUB

DLosc

Posted 2016-12-17T01:16:15.437

Reputation: 21 213

1

05AB1E, 12 bytes

15ÝDδ*16‰hJ»

Try it online.

Explanation:

15Ý           # Create a list in the range [0,15]: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
   D          # Duplicate this list
    δ*        # Multiply each pair double vectorized
      16‰     # Take the divmod 16 for each
         h    # Convert each number to hexadecimal 
          J   # Join the pairs together
           »  # Join each inner list by spaces, and then each string by newlines
              # (and output the result implicitly)

Kevin Cruijssen

Posted 2016-12-17T01:16:15.437

Reputation: 67 575

1Good idea using to get the leading 0's. – Emigna – 2019-03-21T09:42:26.337

@Emigna Remembered it from some date/time related challenges where leading 0s were mandatory as well (where I used divmod 10). :) Too bad there isn't a 1-byte constant for integers 16 and 32, though.. I use those more often than the 1-bytes 95 and 36, although I guess those were added later, so I kinda understand why these constants are there as 1-byte instead of 2-byte. – Kevin Cruijssen – 2019-03-21T09:45:27.753

Yeah, 16 should definitely be a candidate as a 1-byte constant. Should be the most used 2-digit number. I don't think I've used 36 much, if ever. 95 was needed a lot in ascii challenges previously. Although I haven't seen many uses for it recently, I still feel as if it has a place. – Emigna – 2019-03-21T09:51:00.337

@Emigna I understand the use of constants 95 and 36, for ASCII and Base challenged respectively. I just feel like there are indeed much better candidates for 1-byte constants than these. These small-number builtins were added later however, after the 2-byte constants already existed, which is probably why it's like it is now. Changing it now would also invalidate quite a few answers.. Ah well. Btw, completely unrelated: do you know how to update the wiki? Some commands are incorrect/missing (like to reset the counter_variable, or , , which should be Ž, ž, ż instead). – Kevin Cruijssen – 2019-03-21T09:58:21.377

I haven't updated (or even looked at) the wiki, so I'm not 100% certain. I presume you could just fork it and make a pull request as with code updates. @Mr.Xcoder will know for sure as he's done a lot of work on it. – Emigna – 2019-03-21T10:04:43.423

0

Pyth - 24 23 bytes

Looking to golf the padding.

jjL;c16%L"%02x"*M^U16 2

Try it online here.

Maltysen

Posted 2016-12-17T01:16:15.437

Reputation: 25 023

Maybe add 256 and then take off the first digit after converting to string? Maybe that's what you're doing. I really don't know Pyth :-P – Esolanging Fruit – 2016-12-17T02:24:04.180

@Challenger5 I'm just using Python's format strings – Maltysen – 2016-12-17T04:15:07.430

0

WinDbg, 85 68 bytes

Formatting the output manually:

.for(rip=0;.<100;rip=.+1){.printf"%02x%c",./10*(.%10),a+(f>.%10)*16}

Or using a built-in to format the output, which also outputs some bonus text. Also 68 bytes:

.for(rip=0;.<100;rip=.+1){eb(8<<16)+. .%10*(./10)};db/c10 8<<16 L100

-17 bytes because it turns out the pseudo-register $ip can be read with ., so using that one instead of $t0.

WinDbg's default base is 16 so this looks essentially like it's just code to print the 10x10 decimal multiplication table.

How it works:

.for (r ip=0; .<100; r ip=.+1)        * Loop 256 times
{
    .printf "%02x%c", ./10*(.%10),    * Print the result, padded to 2 places
        a+(f>.%10)*16                 * Print a space or \n if end of line
}

* OR:

.for (r ip=0; .<100; r ip=.+1)        * Loop 256 times
{
    eb (8<<16)+. .%10*(./10)          * Put the result in memory
};
db /c10 8<<16 L100                    * Print the memory as bytes in lines of length 16

Sample output:

0:000> .for(rip=0;.<100;rip=.+1){.printf"%02x%c",./10*(.%10),a+(f>.%10)*16}
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

0:000> * OR:

0:000> .for(rip=0;.<100;rip=.+1){eb(8<<16)+. .%10*(./10)};db/c10 8<<16 L100
02000000  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00  ................
02000010  00 01 02 03 04 05 06 07-08 09 0a 0b 0c 0d 0e 0f  ................
02000020  00 02 04 06 08 0a 0c 0e-10 12 14 16 18 1a 1c 1e  ................
02000030  00 03 06 09 0c 0f 12 15-18 1b 1e 21 24 27 2a 2d  ...........!$'*-
02000040  00 04 08 0c 10 14 18 1c-20 24 28 2c 30 34 38 3c  ........ $(,048<
02000050  00 05 0a 0f 14 19 1e 23-28 2d 32 37 3c 41 46 4b  .......#(-27<AFK
02000060  00 06 0c 12 18 1e 24 2a-30 36 3c 42 48 4e 54 5a  ......$*06<BHNTZ
02000070  00 07 0e 15 1c 23 2a 31-38 3f 46 4d 54 5b 62 69  .....#*18?FMT[bi
02000080  00 08 10 18 20 28 30 38-40 48 50 58 60 68 70 78  .... (08@HPX`hpx
02000090  00 09 12 1b 24 2d 36 3f-48 51 5a 63 6c 75 7e 87  ....$-6?HQZclu~.
020000a0  00 0a 14 1e 28 32 3c 46-50 5a 64 6e 78 82 8c 96  ....(2<FPZdnx...
020000b0  00 0b 16 21 2c 37 42 4d-58 63 6e 79 84 8f 9a a5  ...!,7BMXcny....
020000c0  00 0c 18 24 30 3c 48 54-60 6c 78 84 90 9c a8 b4  ...$0<HT`lx.....
020000d0  00 0d 1a 27 34 41 4e 5b-68 75 82 8f 9c a9 b6 c3  ...'4AN[hu......
020000e0  00 0e 1c 2a 38 46 54 62-70 7e 8c 9a a8 b6 c4 d2  ...*8FTbp~......
020000f0  00 0f 1e 2d 3c 4b 5a 69-78 87 96 a5 b4 c3 d2 e1  ...-<KZix.......

milk

Posted 2016-12-17T01:16:15.437

Reputation: 3 043

0

Scala, 56 bytes

for(x<-0 to 15){for(y<-0 to 15)printf("%02x ",x*y);println}

Ungolfed:

for(x<-0 to 15){
  for(y←0 to 15)
    printf("%02x ",x*y);
  println
}

Explanation:

for(x<-0 to 15){        //count from 0 to 15 using the variable x
  for(y←0 to 15)          //count from 0 to 15 using the variable y
    printf("%02x ",x*y);    //print x*y as a hex string with leading zeros and a width of 2 characters
  println                 //print a newline
}

corvus_192

Posted 2016-12-17T01:16:15.437

Reputation: 1 889

0

Common Lisp, 88 70 69 63 bytes

(#1=dotimes(j 16)(#1#(k 16)(format t"~2,'0x "(* k j)))(terpri))

Using idea from here

A bit of explanation

~2,'0x ;display in hexadecimal, padding with minimum two digits, padding symbol is 0

user65167

Posted 2016-12-17T01:16:15.437

Reputation:

0

q/kdb+, 46 26 bytes

Solution:

-1" "sv'($)4h$x*/:x:(!)16;

Example:

q)-1" "sv'($)4h$x*/:x:(!)16;
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

Explanation:

-1" "sv'string 4h$x*/:x:til 16; / ungolfed solution
                        til 16  / range 0..15
                      x:        / save in variable x
                  x*/:          / x multiplied by each-right (generate 0..15*0..15)
               4h$              / cast result to byte array (0x00...)
        string                  / convert byte array to string
  " "sv'                        / join (sv) each (') with space (" ")
-1                            ; / write to stdout and swallow return value

Notes:

  • -20 byte saving by complete re-write.

streetster

Posted 2016-12-17T01:16:15.437

Reputation: 3 635

0

Proton, 60 bytes

x=0;eval("print(' '.join('%02x'%(x*y)for y:0..16));x++;"*16)

Try it online!

Business Cat

Posted 2016-12-17T01:16:15.437

Reputation: 8 927

0

Excel VBA, 58 54 Bytes

Anonymous VBE immediate window function that takes no input and outputs the FxF hex multiplication table to the range [A1:P16]

[A1:P16]="=Right(0&Dec2Hex((Row()-1)*(Column()-1)),2)"

Taylor Scott

Posted 2016-12-17T01:16:15.437

Reputation: 6 709

0

J, 22 bytes

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

Try it online!

FrownyFrog

Posted 2016-12-17T01:16:15.437

Reputation: 3 112

0

VBA (Excel), 45 Bytes

By using VBA Immediate Window.

[A1:P16]="=DEC2HEX((row()-1)*(column()-1),2)"

remoel

Posted 2016-12-17T01:16:15.437

Reputation: 511

0

Tcl, 98 bytes

time {incr i
set j 0
time {puts -nonewline [format %02x\  [expr ($i-1)*$j]]
incr j} 16
puts ""} 16

Try it online!

Tcl, 102 bytes

set i 0
time {set j 0
time {puts -nonewline [format %02x\  [expr $i*$j]]
incr j} 16
puts ""
incr i} 16

Try it online!

Will golf it more later!

sergiol

Posted 2016-12-17T01:16:15.437

Reputation: 3 055

0

Jq 1.5, 105 bytes

def h:[("0123456789abcdef"/"")[.[]]]|add;[range(16)*range(16)|[(./16|floor),.%16]|h]|_nwise(16)|join(" ")

Expanded (jq has no "%x" formatting so we roll our own)

def tohex:                 # convert [x,y] to hex string "xy"
  [("0123456789abcdef"/"")[.[]]] | add;

[   range(16)*range(16)    # generate values
  | [(./16|floor), .%16]   # convert to [x,y] digits base 16
  | tohex                  # convert to hex string
]
| _nwise(16)               # split into subarrays of length 16
| join(" ")                # convert subarrays to strings

Try it online!

jq170727

Posted 2016-12-17T01:16:15.437

Reputation: 411

0

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

reffu

Posted 2016-12-17T01:16:15.437

Reputation: 1 361

0

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!

Embodiment of Ignorance

Posted 2016-12-17T01:16:15.437

Reputation: 7 014

0

Mouse-2002, 58 bytes

8&WSIZE (qx.-^x.0y:(y.q<^y.x.y.*&!HEX " "y.1+y:)"!"x.1+x:)

Try it online!

MooseOnTheRocks

Posted 2016-12-17T01:16:15.437

Reputation: 191

0

Pyth, 24 bytes

V16FZU16p+%"%02x"*ZNd)pb

Try it online!

Might post an explanation or ungolfed version later.

Qapples

Posted 2016-12-17T01:16:15.437

Reputation: 11

0

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...

RosLuP

Posted 2016-12-17T01:16:15.437

Reputation: 3 036

0

Charcoal, 16 15 bytes

E¹⁶⭆¹⁶﹪%02x ×ιλ

Try it online! Link is to verbose version of code.

Alternative 16-byter using automatic grid output of Wolfram lists: ▷LE¹⁶E¹⁶﹪%02x×κμ

Explanation

E¹⁶                      Map for i from 0 to 15 (with k as index variable, but here it's the same as i)
    ⭆¹⁶                  Map for l from 0 to 15 (with m as index variable), then join with "" into a string
       ﹪                Modulo (used for Python's string format here)
         %02x            Input formatted (%), padded with zeros (0) to length two (2)
                         as a hexadecimal number (x), with a space ( ) at the end
              ×ιλ        i * l

ASCII-only

Posted 2016-12-17T01:16:15.437

Reputation: 4 687

0

Perl 6, 49 36 bytes

say ($_ <<*<<^16).fmt("%02x")for ^16

Old solution:

for ^16 ->\a {printf "%02x ",a*$_ for ^16;say ""}

bb94

Posted 2016-12-17T01:16:15.437

Reputation: 1 831

0

MathGolf, 16 bytes

☻r■mÉε*¢0═ uM∞/n

Try it online!

Explanation

It might be shorter to do it with a loop, I'll have to try that.

☻                  push 16
 r                 range(0, n)
  ■                cartesian product with itself
   mÉ              explicit map using next 3 operators
     ε*            reduce list by multiplication
       ¢           convert to/from hexadecimal
        0          push 0
         ═         pad list elements with zeroes to equal length
                   space character
           u       join with separator (joins on space)
            M      push 24
             ∞     pop a, push 2*a = 48 (each line is 48 characters long)
              /    pop a, b : push(a/b), split strings
               n   newline char, or map array with newlines

maxb

Posted 2016-12-17T01:16:15.437

Reputation: 5 754