Skip to main content
added 29 characters in body
Source Link
Xcali
  • 17k
  • 2
  • 17
  • 42

Perl 5, 6767 57 + 1 (-n-p) = 6858 bytes

$_=$\=$_=10**$_/10+($_>1).0 x($_-2).1;for$i;for$i(2..lengthy///c){say;s/^.//;$_.=0}s/0$/1/;say}{ 

Try it online!Try it online!

Takes the input implicitly (-np). ConvertsConvert that to a string10 to the power of 1 (iffthe input > 0) followed by n-2 zeros, followed by aminus 1 and add one if the input is greater than one. Outputs thethat as a string, then removes first character and appends a 0, looping until it has output n-1 rows. For the last row, replaceimplicitly output the final character with a 1 before printingcopy of the first row which has been stored in $\.

Perl 5, 67 + 1 (-n) = 68 bytes

$_=($_>1).0 x($_-2).1;for$i(2..length){say;s/^.//;$_.=0}s/0$/1/;say 

Try it online!

Takes the input implicitly (-n). Converts that to a string of 1 (iff input > 0) followed by n-2 zeros, followed by a 1. Outputs the string, then removes first character and appends a 0, looping until it has output n-1 rows. For the last row, replace the final character with a 1 before printing.

Perl 5, 67 57 + 1 (-p) = 58 bytes

$\=$_=10**$_/10+($_>1);for$i(2..y///c){say;s/.//;$_.=0}}{ 

Try it online!

Takes the input implicitly (-p). Convert that to 10 to the power of the input minus 1 and add one if the input is greater than one. Outputs that as a string, then removes first character and appends a 0, looping until it has output n-1 rows. For the last row, implicitly output the copy of the first row which has been stored in $\.

deleted 62 characters in body
Source Link
Xcali
  • 17k
  • 2
  • 17
  • 42

Perl 5, 71 +167 + 1 (-n) = 7268 bytes

$_=($_>1).0 x($_-2).1;for$i(2..length){say;s/^1/0/;s/01^./10/;$_.=0}s/0$/1/;say 

Try it online!Try it online!

Takes the input implicitly (-n). Converts that to a string of 1 (iff input > 0) followed by n-2 zeros, followed by a 1. Outputs the string, then removes the 1 on the frontfirst character and switches the position of the only remaining 1 with theappends a 0 before it, looping until it has output n-1 rows. For the last row, replace the final character with a 1 before printing.

Perl 5, 71 +1 (-n) = 72 bytes

$_=($_>1).0 x($_-2).1;for$i(2..length){say;s/^1/0/;s/01/10/}s/0$/1/;say 

Try it online!

Takes the input implicitly (-n). Converts that to a string of 1 (iff input > 0) followed by n-2 zeros, followed by a 1. Outputs the string, then removes the 1 on the front and switches the position of the only remaining 1 with the 0 before it, looping until it has output n-1 rows. For the last row, replace the final character with a 1 before printing.

Perl 5, 67 + 1 (-n) = 68 bytes

$_=($_>1).0 x($_-2).1;for$i(2..length){say;s/^.//;$_.=0}s/0$/1/;say 

Try it online!

Takes the input implicitly (-n). Converts that to a string of 1 (iff input > 0) followed by n-2 zeros, followed by a 1. Outputs the string, then removes first character and appends a 0, looping until it has output n-1 rows. For the last row, replace the final character with a 1 before printing.

Source Link
Xcali
  • 17k
  • 2
  • 17
  • 42

Perl 5, 71 +1 (-n) = 72 bytes

$_=($_>1).0 x($_-2).1;for$i(2..length){say;s/^1/0/;s/01/10/}s/0$/1/;say 

Try it online!

Takes the input implicitly (-n). Converts that to a string of 1 (iff input > 0) followed by n-2 zeros, followed by a 1. Outputs the string, then removes the 1 on the front and switches the position of the only remaining 1 with the 0 before it, looping until it has output n-1 rows. For the last row, replace the final character with a 1 before printing.