Skip to main content
Correcting the answer
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68

Actually, 1414 18 bytes

A simple algorithm.

Edit: Fixing a bug for n == 1

;;¬╤$@u*'1@+╪i ;;D╤$0D@H@u*'1@+╪i 

Ungolfing

  Implicit input: n ;;  Duplicate n twice. ¬╤$D╤$  Push str(10**(n-21)) @u0D@H  Push n+1str(10**(n-1))[:-1] * @u*  Push str(10**(n-2)) * (n+1)   '1@+ Append a "1"   ╪ Split into chunks of length n   i Flatten this list onto the stack   Implicit print 

Try it online!Try it online!

Actually, 14 bytes

A simple algorithm.

;;¬╤$@u*'1@+╪i  Implicit input: n ;; Duplicate n twice. ¬╤$ Push str(10**(n-2)) @u Push n+1 * Push str(10**(n-2)) * (n+1) '1@+ Append a "1" ╪ Split into chunks of length n i Flatten this list onto the stack Implicit print 

Try it online!

Actually, 14 18 bytes

A simple algorithm.

Edit: Fixing a bug for n == 1

;;D╤$0D@H@u*'1@+╪i 

Ungolfing

  Implicit input: n ;;  Duplicate n twice. D╤$  Push str(10**(n-1)) 0D@H  Push str(10**(n-1))[:-1] @u*  Push str * (n+1)   '1@+ Append a "1"   ╪ Split into chunks of length n   i Flatten this list onto the stack   Implicit print 

Try it online!

Correcting the answer
Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68

Actually, 1214 bytes

Based on Emigna's 05AB1E answerA simple algorithm.

;;D@²r♀%♂Y╪i;;¬╤$@u*'1@+╪i 

Ungolfing

  Implicit input: n ;;  Duplicate n twice. D Decrement one duplicate  ¬╤$ @ SwitchPush str(10**(n-1 with an n2)) ²r @u Get [0 ..Push n**2-1]n+1   ♀% * Get each item of the range moduloPush str(10**(n-1 2)) * (n+1)  ♂Y '1@+ Check for equalityAppend toa 0"1"   ╪ Split into chunks of length n   i Flatten this list onto the stack   Implicit print 

Try it online!Try it online!

Actually, 12 bytes

Based on Emigna's 05AB1E answer.

;;D@²r♀%♂Y╪i 

Ungolfing

 Implicit input: n ;; Duplicate n twice. D Decrement one duplicate  @ Switch n-1 with an n ²r Get [0 .. n**2-1]   ♀% Get each item of the range modulo n-1  ♂Y Check for equality to 0 ╪ Split into chunks of length n i Flatten this list onto the stack Implicit print 

Try it online!

Actually, 14 bytes

A simple algorithm.

;;¬╤$@u*'1@+╪i   Implicit input: n ;;  Duplicate n twice. ¬╤$ Push str(10**(n-2)) @u Push n+1 * Push str(10**(n-2)) * (n+1)  '1@+ Append a "1"   ╪ Split into chunks of length n   i Flatten this list onto the stack   Implicit print 

Try it online!

Source Link
Sherlock9
  • 12.4k
  • 1
  • 32
  • 68

Actually, 12 bytes

Based on Emigna's 05AB1E answer.

;;D@²r♀%♂Y╪i 

Ungolfing

 Implicit input: n ;; Duplicate n twice. D Decrement one duplicate @ Switch n-1 with an n ²r Get [0 .. n**2-1] ♀% Get each item of the range modulo n-1 ♂Y Check for equality to 0 ╪ Split into chunks of length n i Flatten this list onto the stack Implicit print 

Try it online!