| Bytes | Lang | Time | Link |
|---|---|---|---|
| 087 | Swift 6 | 250429T131646Z | macOSist |
| 095 | Tcl | 171103T013442Z | sergiol |
| 013 | Vyxal 3 Ṁ | 240923T120300Z | pacman25 |
| 101 | Swift | 240814T135950Z | Daniel |
| 041 | Fortran GFortran | 240815T041812Z | roblogic |
| 038 | Bash | 161217T013756Z | Digital |
| 073 | Red | 240815T082239Z | Galen Iv |
| 063 | Excel VBA | 170822T175321Z | Taylor R |
| 073 | Excel | 240814T044825Z | Taylor R |
| 086 | Go | 240813T174242Z | bigyihsu |
| 011 | 05AB1E | 190321T094035Z | Kevin Cr |
| 034 | Uiua | 240729T024819Z | noodle p |
| 009 | Vyxal | 240801T054547Z | lyxal |
| 102 | Setanta | 240728T223931Z | bb94 |
| 056 | Factor | 210530T052235Z | chunes |
| 022 | Vyxal j | 210530T032744Z | emanresu |
| 016 | MathGolf | 190321T091006Z | maxb |
| 015 | Charcoal | 190316T235526Z | ASCII-on |
| 036 | Perl 6 | 190319T003451Z | bb94 |
| 161 | Ink | 190209T005830Z | Sara J |
| 036 | K7 | 190316T141508Z | yiyus |
| 084 | APLNARS | 190316T091622Z | user5898 |
| 024 | Pyth | 190315T221017Z | Scott Ar |
| 073 | QBasic | 190315T213429Z | DLosc |
| 087 | Haskell | 190315T211536Z | dfeuer |
| 058 | Mouse2002 | 190315T211416Z | MooseOnT |
| 067 | C# Visual C# Interactive Compiler | 190315T200741Z | Gymhgy |
| 011 | Stax | 190301T004855Z | recursiv |
| 015 | Japt R | 170822T104235Z | Shaggy |
| 065 | Forth gforth | 190208T194411Z | reffu |
| 055 | Python 3 | 190208T193212Z | Beefster |
| 056 | PHP | 170822T193840Z | Titus |
| 077 | JavaScript ES6 | 161217T124523Z | Neil |
| 105 | Jq 1.5 | 171105T002436Z | jq170727 |
| 075 | Julia | 171103T021047Z | EricSher |
| 079 | Java 8 | 171027T075815Z | Kevin Cr |
| 045 | VBA Excel | 171027T073645Z | remoel |
| 022 | J | 171026T231945Z | FrownyFr |
| 033 | APL Dyalog | 171026T221019Z | Uriel |
| 026 | q/kdb+ | 170822T084404Z | mkst |
| 066 | C | 161218T020800Z | Karl Nap |
| 066 | VBA | 161228T214951Z | Joffan |
| 060 | Proton | 170822T165725Z | Business |
| 073 | Python 2 | 161217T041250Z | 0xffcour |
| 045 | Perl 5 | 170821T191307Z | Xcali |
| 066 | Python 3 | 170821T184834Z | 0WJYxW9F |
| 063 | Common Lisp | 170222T182105Z | user6516 |
| 544 | /// | 170226T010913Z | boboquac |
| 588 | /// | 170225T023137Z | Esolangi |
| 050 | k | 170222T231047Z | zgrep |
| 047 | SmileBASIC | 170222T215750Z | 12Me21 |
| 089 | Python2 | 161217T105652Z | Yytsi |
| 061 | C | 170104T012707Z | user5634 |
| 104 | JavaScript | 161228T195805Z | Julian L |
| 017 | 05AB1E | 161219T182448Z | Osable |
| 056 | Scala | 161219T173546Z | corvus_1 |
| nan | 161217T214614Z | Brad Gil | |
| 048 | Perl | 161217T192824Z | Gabriel |
| 034 | Octave | 161217T192636Z | rahnema1 |
| 012 | Jelly | 161217T023324Z | Dennis |
| 053 | Matlab | 161217T124704Z | Owen Mor |
| 042 | R | 161217T102840Z | JAD |
| 046 | PowerShell | 161217T073107Z | AdmBorkB |
| 046 | Mathematica | 161217T062735Z | Greg Mar |
| 098 | C#6 | 161217T061243Z | Link Ng |
| 060 | Python 2 | 161217T024805Z | Dennis |
| 049 | Ruby | 161217T025529Z | Level Ri |
| 068 | WinDbg | 161217T015254Z | milk |
| 018 | MATL | 161217T013712Z | Luis Men |
| 023 | Pyth | 161217T011942Z | Maltysen |
Swift 6, 87 bytes
for i in 0...15{print((0...15).map{("0\(String(i*$0,radix:16)) ").suffix(3)}.joined())}
Tcl, 95 bytes
time {incr i
time {lappend s [format %02x [expr ($i-1)*([incr j]-1)]]} 16
puts $s
unset j s} 16
time {incr i
set j 0
time {puts -nonewline [format %02x\ [expr ($i-1)*$j]]
incr j} 16
puts ""} 16
set i 0
time {set j 0
time {puts -nonewline [format %02x\ [expr $i*$j]]
incr j} 16
puts ""
incr i} 16
Swift, 101 Bytes
import iAd
(0...15).map{for j in 0...15{print(String(format:"%02x",$0*j),terminator:j>14 ?"\n":" ")}}
Fortran (GFortran), 41 bytes
print'(16Z3.2)',((j*i,j=0,15),i=0,15)
end
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 16reshapes the output to 16 columns wide.
Alternative solution:
Bash + jot, 38
eval '
jot -s\ -w%02x 16 0 - '{0..15}
Red, 73 bytes
repeat i 16[repeat j 16[prin to-hex/size i - 1 *(j - 1)2 prin" "]print""]
Excel VBA, 63 Bytes
Anonymous function that takes no input and outputs to the VBE immediate window. Calculates a 1-D array of outputs using the array multiplication of an intermediate value stored in [A1].
For r=0To 15:[A1]=r:?Join([Dec2Hex((Column(A:P)-1)*A1,2)]):Next
Alternate Version, 44 Bytes
Anonymous VBE immediate window function that takes no input and outputs hex multiplication table to the range [A1:P16]
[A1:P16]="=Dec2Hex((Row()-1)*(Column()-1)),2)
Note: this solution uses a standard Excel output method which may or may not meet the requirements of the kolmogorov-complexity tag.
Pure VBA, 64 Bytes
An anonymous VBE immediate window function.
For r=0To 15:For c=0To 15:?Right("0"+Hex(r*c),2)" ";:Next:?:Next
Excel, 73 bytes
An anonymous function that outputs the entire table within the calling cell, as required by the kolmogorov-complexity tag.
=LET(c,COLUMN(A:P)-1,CONCAT(DEC2HEX((ROW(1:16)-1)*c,2)&IF(c>14,"
"," ")))
Alternate Version, 41 bytes
If the table may be output to the activesheet object directly, the code may be golfed down significantly to
=DEC2HEX((ROW(1:16)-1)*(COLUMN(A:P)-1),2)
Go, 86 bytes
import."fmt"
func f(){for i:=range 16{for j:=range 16{Printf(`%02x `,i*j)}
Println()}}
05AB1E, 12 11 bytes
15Ýδ*16‰hJ»
-1 byte removing the D before the δ, since when no input is given, it'll use the last item on the stack implicitly instead, and therefore use the list twice.
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]
# Create a multiplication table of this list:
δ # Apply double-vectorized:
# (since there is not input given; use this list twice)
* # Multiply
16‰ # Take the divmod 16 for each
h # Convert each number to hexadecimal
J # Join the inner-most pairs together
» # Join each inner list by spaces, and then each string by newlines
# (and output the result implicitly)
Uiua, 37 34 bytes
≡&p≡/$"_ _"⊏∵⊟⌊⊃÷◿16⊞×.°⊏HexDigits
HexDigits # "0123456789abcdef"
°⊏ # [0 1 2 3 ... 15]
⊞×. # multiplication table
⌊⊃÷◿16 # divmod by 16
# division is first digit, remainder is second digit
∵⊟ # pair the division and remainder
⊏ # index each number into the hex digits string
≡/$"_ _" # join rows on spaces
≡&p # print each line
Edit (37 → 34): I learned that HexDigits is a built-in constant.
Vyxal, 72 bitsv2, 9 bytes
16ʁ:v*H2↳›⁋
Bitstring:
010000010101010011100000010011001000100110001001111100111100011010000110
I can do a packed answer too :p
Explained
16ʁ:v*H2↳›⁋
16ʁ # The range [0, 16],
: # Pushed twice
v* # [lhs * range [0, 16] for lhs in range [0, 16]]
H # With result converted to hexadecimal
2↳› # And padded to be two characters, with a 0 if needed.
⁋ # Join all sublists on spaces, then the entire thing on newlines
💎
Created with the help of Luminespire.
Setanta, 102 bytes
s:="0123456789abcdef"t:=""le i idir(0,16){le j idir(0,16)t+=s[i*j//16]+s[i*j%16]+" "t+="\n"}scriobh(t)
Factor, 56 bytes
16 iota dup '[ _ [ * "%02X "printf ] with each nl ] each
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
Vyxal j, 22 bytes
15ʀƛ15ʀ*ƛk6τ:L1=[0p];Ṅ
15ʀ # List 0...15
ƛ # Map to...
15ʀ # 0...15
* # Multiplied by (number)
ƛ ; # Map to...
k6τ # Base16
:L1=[0p] # Prepend 0 as necessary
Ṅ # Join by spaces
MathGolf, 16 bytes
☻r■mÉε*¢0═ uM∞/n
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
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
Perl 6, 49 36 bytes
say ($_ <<*<<^16).fmt("%02x")for ^16
Old solution:
for ^16 ->\a {printf "%02x ",a*$_ for ^16;say ""}
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}
}
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.
K7, 36 bytes
` 0:" "/:'{`hex@`c$x}''{x*/:\:x}@!16
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...
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
Haskell, 87 bytes
import Numeric
main=mapM(\x->putStrLn$do y<-s;['0'|x*y<16]++showHex(x*y)" ")s
s=[0..15]
I imagine there's a better way. Maybe depend on the printf package....
C# (Visual C# Interactive Compiler), 67 bytes
for(int i=0;i<256;)Write($"{(i%16<1?"\n":"")} {i/16*(i++%16):X2}");
Japt -R, 20 15 bytes
GÆGÇ*X sGÃùT2 ¸
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
Forth (gforth), 65 bytes
: f 16. do cr 16. do i j * 16 /mod hex 1 .r . decimal loop loop ;
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
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.
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.
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.
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
Julia, 83 75 bytes
r=0:15;[([print(num2hex(i*j)[15:16]," ")for i in r],print('\n'))for j in r]
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:
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
VBA (Excel), 45 Bytes
By using VBA Immediate Window.
[A1:P16]="=DEC2HEX((row()-1)*(column()-1),2)"
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.
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
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.
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.
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.
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)
- 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
Python 3, 66 bytes
r=range(16)
for i in r:print(*[('0'+hex(j*i)[2:])[-2:]for j in r])
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
///, 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.
///, 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.
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
SmileBASIC, 56 51 47 bytes
I=RND(16)J=RND(16)LOCATE I*3,J?HEX$(I*J,2)EXEC.
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
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
}
05AB1E, 17 bytes
16F15ÝN*8o+h€¦ðý»
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.
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
}
Perl 6, 42 bytes
.fmt("%02x").put for (^16 X*^16).rotor: 16
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
Perl, 48 bytes
for$a(@%=0..15){printf"%02x "x@%.$/,map$a*$_,@%}
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
Octave, 34 bytes
disp(num2str((a=0:15)'*a,'%02x '))
Jelly, 12 bytes
⁴Ḷ×þ`d⁴‘ịØhG
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.
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
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"
PowerShell, 46 bytes
0..15|%{$i=$_;"$(0..15|%{"{0:X2}"-f($i*$_)})"}
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.
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.
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"}");};
Standard nested for-loop. Only trick is to print newline when j>=15.
Python 2, 60 bytes
for n in range(256):r=n%16;print'%02x%s'%(n/16*r,r/15*'\n'),
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.
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)
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.......
MATL, 19 18 bytes
16:q&*1YAO3Z(!48e!
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
