# Block of digits

Output/print this block of text:

1234567890
2468013579
3691470258
4815926037
5049382716
6172839405
7306295184
8520741963
9753108642
0987654321


Acceptable formats include:

• Trailing newlines/whitespace
• List of strings
• List of lists of characters
• List of lists of integers

However, list of integers is not acceptable because the last line is not an integer.

This is . Shortest answer in bytes wins. Standard loopholes apply.

## Mathematica, 33 bytes

Mod[1##,11]~Mod~10&~Array~{10,10}


Try it online! (Using Mathics.)

The cell at 1-based index (x,y) has value ((x*y) % 11) % 10

# Python 2, 48 46 bytes

n=10
while n:print('00987654321'*n)[n::n];n-=1


Try it online!

• Welcome to PPCG, and amazing first answer! We hope you'll stick around and contribute more :-) – ETHproductions Jun 26 '17 at 21:50
• @ETHproductions thanx :))) – mdahmoune Jul 6 '17 at 12:03

# Python 2, 49 47 bytes

n=1
exec"print('01234567890'*n)[n::n];n+=1;"*10


Try it online!

• nice exec use.. – mdahmoune Jun 29 '17 at 16:55

# Jelly, 7 bytes

⁵×þ%‘%


Try it online!

Uses Martin's algorithm.

# MATL, 12 11 bytes

Saved a byte thanks to Luis. I keep forgetting the & is a shortcut for duplicating and transposing.

10:&*11\10\


Try it online!

Using @Martin's algorithm: x*y % 11 % 10

Explanation:

10            % Pust 10 to the stack. Stack: 1
:           % 1-based range. Stack: [1 2 3 ... 10]
&          % Duplicate range. Stack: [1 2 3 ... 10],[1 2 3 ... 10]
% Transpose last range. Stack [1 2 3 ... 10],[1;2;3 ...10]
*         % Multiply with broadcasting. Stack: [1 2 3 ...;2 4 6...] (10-by-10 array)
11       % Push 11 to the stack. Stack [1 2 3 ...;2 4 6 ...], 11
\      % Modulus.
10    % Push 10 to the stack.
\   % Modulus
% Implicit display


Same bytecount:

10t:&*11\w\

• You can save a byte replacing t!* by&* – Luis Mendo Jun 26 '17 at 10:13
• @LuisMendo double backticks if you have a backslash at the end of code snippet in comments. – Martin Ender Jun 26 '17 at 10:14
• @MartinEnder Thanks! I never remember how that works, so I went for the easy way :-) – Luis Mendo Jun 26 '17 at 10:14
• @LuisMendo yeah it's a bit confusing with posts and comments using different syntax. – Martin Ender Jun 26 '17 at 10:16
• Thanks @LuisMendo! That's not in the docs is it? – Stewie Griffin Jun 26 '17 at 10:21

## APL (Dyalog), 13 bytes

10|11|∘.×⍨⍳10


Try it online!

A port of my Mathematica answer.

      ∘.×⍨      ⍝ Multiplication table of...
⍳10   ⍝ The list from 1 to 10.
11|          ⍝ mod 11.
10|             ⍝ mod 10.


## CJam (17 bytes)

A,:)_f{f*Bf%Af%N}


Online demo

## Retina, 59 bytes

Byte count assumes ISO 8859-1 encoding.


10$* 1 ,1$
,1+
$_¶ (?<=(¶?.+)+)1$#1$* 1{10}1? ,(1*)$.1


Try it online!

### Explanation

Another implementation of the ... % 11 % 10 algorithm. The fun part of doing it with a regex is that we can take care of both modulo computations at once.


10$*  Initialise the string to ten 1s. 1 ,1$


Replace each of those with a comma, a one, and the prefix in front of that one. This gives ,1,11,...,1111111111, i.e. a unary range.

,1+
$_¶  Now replace each of the range elements with the entire string followed by a linefeed. This gives us a 10x10 grid of unary numbers indicating the current column. (?<=(¶?.+)+)1$#1$*  Match each 1 and determine which row it's on by repeating group one that many times. Replace the 1 with that many 1s. This multiplies the values in each row by the row's 1-based index. 1{10}1?  Now let's do mod 11, mod 10 in one step. To do mod 11, we'd normally just remove all 1{11} from the string to be left with the remainders. And then we'd remove 1{10} after that. But if we just remove ten 1s plus another if possible, the regex engine's greediness will do mod 11 for us as long as possible, and if not, then it'll try at least mod 10. ,(1*)$.1


Finally, we just convert each number to decimal by replacing it with its length.

# 05AB1E, 14 bytes

11GTLN*11%T%})


Try it online!

Uses Martin's algorithm, as usual.

• Oh, there's an algorithm for that pattern. That explains why I'm 30 bytes above the average answer. – Magic Octopus Urn Jun 30 '17 at 13:47

l=[1..10]
f=[[x*imod11mod10|i<-l]|x<-l]


# Javascript (ES6), 70 64 56 bytes

_=>[...1e9+''].map((_,a,b)=>b.map((_,c)=>-~a*++c%1‌​1%10))


Saved 4 bytes thanks to Shaggy and 8 bytes thanks to Arnauld.

• 66 bytes: _=>[...a=Array(10)].map((_,x)=>[...a].map((_,y)=>(x+1)*++y%11%10)). You save me 4 bytes, I save you 4 bytes :) – Shaggy Jun 26 '17 at 10:05
• Thanks a lot. You also fixed a bug, so I shaved another 2 bytes of your solution ;-) – Luke Jun 26 '17 at 10:11
• You can save 5 bytes by using the 3rd parameter of the callback in the first map() and 3 more bytes by using 1e9+'' instead of Array(10). That leads to _=>[...1e9+''].map((_,x,a)=>a.map((_,y)=>-~x*++y%11%10)). – Arnauld Jun 26 '17 at 11:20
• @Arnauld: Thanks for the 1e9 trick. I didn't know that one. I did think about using the third argument, but for some reason I didn't use it. – Luke Jun 27 '17 at 11:40
• I've recently compiled a list of similar tricks here. – Arnauld Jun 27 '17 at 11:51

# Japt, 1612 11 bytes

Turns out this was my 200 (undeleted) answer here :)

Looks like this is the same formula Martin spotted.

Aõ
£®*X%B%A


Test it (-R flag for visualisation purposes only)

• 4 bytes saved thanks to Luke pointing out that returning an array of arrays was permissible.

## Explanation

Aõ    :Generate an array of integers from 1 to 10, inclusive.
£     :Map over each element in the array, returning...
®     :Another map of the same array, which...
*X    :Multiplies the current element of the inner function by the current element of the outer function...
%B    :Modulus 11...
%A    :Modulus 10.
:Implicit output of resulting 2D array

• Beat me to it... You can drop the last two characters, and instead use the -R flag – Luke Jun 26 '17 at 9:53
• Even better, drop the last four characters. It seems that's allowed... – Luke Jun 26 '17 at 9:57
• Yup, looks like you're right, thanks, @Luke :) – Shaggy Jun 26 '17 at 9:58

# Java 8, 84 bytes

o->{String r="";for(int x=0,y;++x<11;r+="\n")for(y=0;++y<11;r+=x*y%11%10);return r;}


Uses the same algorithm as @MartinEnder's Mathematica answer: 1-indexed x*y%11%10.

Explanation:

Try it here.

o->{                     // Unused Object parameter and String return-type
String r="";           //  Result-String
for(int x=0,y;++x<11;  //  Loop (1) from 1 to 11 (exclusive)
r+="\n")           //    And append a new-line after every iteration
for(y=0;++y<11;      //   Inner loop (2) from 1 to 11 (exclusive)
r+=x*y%11%10       //    And append the result-String with x*y%11%10
);                   //   End of inner loop (2)
//  End of loop (1) (implicit / single-line body)
return r;              //  Return result-String
}                        // End of method


# Python 2, 58 52 bytes

-6 bytes thanks to offcialaimm.

Uses Martin's algorithm which I have no understanding of how he came up with it so fast. o0

r=range(1,11)
print[[x*y%11%10for y in r]for x in r]


Try it online!

# Pyth, 13 bytes

mme%*kd11STST


Try it here

-1 thanks to KarlKastor.

Let's duuuuuuupe!

• Save one byte if you use e instead of % T – KarlKastor Jun 26 '17 at 12:11
• @KarlKastor ...and I was remembering it ._. – Erik the Outgolfer Jun 26 '17 at 12:12

# R, 19 bytes

1:10%o%1:10%%11%%10


Try it online!

The least "R"-looking bit of R code I have ever written. Uses the same algorithm as Martin Ender's answer (and almost all the other answers as well). x %o% y is the same as outer(x, y).

# Charcoal, 30 29 19 bytes

Ｆχ«ＦχＩ﹪﹪×⁺¹ι⁺¹κ¹¹χ⸿


Try it online!

Uses Martin's formula.

• 10 bytes saved thanks to Neil, proving once more that I have still so much to learn...
• You don't need trailing »s and while you can use ω instead of ”” you can save a whole bunch of bytes by using ⸿ as this then becomes Ｆχ«ＦχＩ﹪﹪×⁺¹ι⁺¹κ¹¹χ⸿. (Before I knew about ⸿ I would have suggested Ｊ⁰ι which would still have saved a number of bytes.) – Neil Jun 29 '17 at 9:49
• @Neil The ⸿ is the reverse operator, what does it do at the end of your code without arguments? Is it documented? – Charlie Jun 29 '17 at 9:57
• No, ⮌ is the Reverse operator, ⸿ is the move cursor to start of next line character (like ¶ but can be in a separate string). – Neil Jun 29 '17 at 10:17

# C (gcc), 70 bytes

f(x,y){for(x=0;x++<10;puts(""))for(y=0;y++<10;putchar(x*y%11%10+48));}


Try it online!

# QBIC, 17 bytes

[|?[|?a*b%11%z';


This, of course, uses Martin's Method. It translates to this QBasic code.

## Explanation

[|               FOR A = 1 to 10 ([ starts a FOR loop, | delimits the list of arguments;
a FOR loop with 0 args loops from 1 to 10 by default with increment 1.
?              PRINT a newline
[|            Start a second FOR loop from 1-10, iterator b
?           PRINT
a*b%11%z   the result of Martin's formula.
'; and suppress newlines/tabs/spaces


# C#, 81 bytes

_=>{var r="";for(int x=0,y;++x<11;r+="\n")for(y=0;++y<11;r+=x*y%11%10);return r;}


Same algorithm as most of the other answers and essentially the C# port of @Kevins Java answer.

# Retina, 79 bytes


12345678902468013579369147025848159260375049382716
.*
$&$&
O$^50>. .{10}$&¶


Try it online!

# GolfScript, 37 24 bytes

10,{){\)*11%10%}+10,%}%


Try it online!

-13 thanks to a clever trick Martin Ender suggested.

• if you turn it into a full program ({ --> ;, } --> ), you can at least drop the first [. – Martin Ender Jun 26 '17 at 16:28
• It's a lot shorter to use a simple nested loop instead of the zip technique though: {){\)*11%10%}+10,/n}10,/ – Martin Ender Jun 26 '17 at 16:32
• @MartinEnder Umm...you seem to be overusing /. ;) – Erik the Outgolfer Jun 26 '17 at 16:35
• @MartinEnder Oh I see what you did...you used int blk + -> {int space contents-of-blk}. – Erik the Outgolfer Jun 26 '17 at 16:36
• @MartinEnder ok I've implemented your + trick...although I altered your code a bit – Erik the Outgolfer Jun 26 '17 at 16:43

# C (gcc), 59 bytes

f(n,t){for(n=11;++n<121;putchar(t?t%10+48:10))t=n/11*n%11;}


Try it online!

# Retina, 93 85 bytes


10$*T M!&T+ m$
;110$*T10$*
1
09876543210
m(?<=^\1;\1{0,9}(T+))T
C
(?<!C.{108})\S



Try it online!

• 71 bytes: Try it online! No idea where the magic number of 109 derives from through. – Neil Jun 29 '17 at 10:09

## Pyke, 15 bytes

TD]UMha*11%e)P


Try it here!

## Pyke, 13 bytes

TS F~u0+*i>i%


Try it here!

TS            -  [1, 2, 3, 4, 5, 6, 7, 8, 9]
F~u0+*i>i% - for i in ^:
~u0+      -     "01234567890"
*     -    ^ * i
i>   -   ^[i:]
i% -  ^[::i]


for(;9>=$y++||9>=$x+=$y=print" ";)echo($x+1)*$y%11%10;  Try it online! # PHP, 56 bytes for(;$x++<=9;print"
")for($y=0;$y++<=9;)echo$x*$y%11%10;


Try it online!

• You can drop the brackets (). – Christoph Jun 26 '17 at 10:53
• -2 bytes: for(;<0>$y++||10>$x+=$y=print"\n";)echo($x+1)*$y%11%10; – Titus Jun 27 '17 at 17:07 • ... or for($x=1;11>++$y||11>$x+=$y=print"\n";)echo$x*\$y%11%10; – Titus Jun 27 '17 at 17:15

# J, 27 bytes

1":(10|11|*&>:)"0/~@(i.@9:)


Try it online!

Uses the same trick as in Martin Ender's Mathematica answer.

## TECO, 45 bytes

1un@i/
/10<@i/01234567890/jl10<qnc0a^t>jtl%n>


A (fairly) straightforward implementation of Rod's Python answer.

1un           !initialize register n to 1!
@i/<nl>/      !insert a newline!
10<           !loop for 10 rows!
@i/01234567890/  !insert the mysterious string of digits!
j             !move point to start of buffer!
l             !move forward past the newline!
10<           !loop for 10 digits on a line!
qnc           !move point forward by n characters!
0a^t          !print the character at point!
>             !end inner loop!
j             !move point to start of buffer!
t             !print (empty) line!
l             !move to start of digit string!
%n            !increment register n (for next line)!
>             !end outer loop!


Using <ESC>-terminated inserts and a control character for the ^T command would save another three five bytes, at the expense of readability.

Using Martin's mod-11/mod-10 formula actually makes it longer at 43 bytes using controls for ^A and ^T, mostly because TECO doesn't have a mod operator.

0ur10<%run10<qn-10"g-11%n'qn\r0a^Tqr%n>^a
^A>


Mod 11 is done in an ongoing fashion by incrementing the number in qn by -11 whenever it exceeds 10. The qn\r0a^T sequence inserts the number in the editing buffer as decimal digits, reverses past the last digit, retrieves it from the buffer and types it, essentially doing mod-10.

I expected it to be shorter. Oh, well.