Create a square of increasing size by replicating the initial code
Pyth, 2 bytes
Try it online! Also Try it doubled, tripled!
How does that work?
\n is the command that prints its argument with a trailing newline, while returning it simultaneously. So, each time you make an insertion, you turn the integer literal 5 into a number containing N copies of 5 concatenated, and the leading newlines basically make sure it's printed the appropriate number of times, thus keeping it square.
42 32 30 bytes
s=[this.s]+0; s=[this.s]+0; console.log(s);console.log(s);
This works by appending a
s each time the first half of the code is run, and printing
- The current environment can be referred to with
this. This allows us to do
this.sin place of
- An array plus a number returns a string.
[1,2,3] + 4 === "1,2,34"
- When stringifying an array,
undefinedis converted to the empty string, which means that
[undefined] + 0 === "0".
Put together, this means that we can express the first half (generating a string of zeroes) in just 13 bytes. If using
alert instead of
console.log is allowed, we can save 4 more bytes by shortening the second half.
05AB1E, 2 bytes
Try it online!
Port of my Pyth answer.