45
5
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the middle of the current code.
It is quite hard for me to define this task very well, so I'll give you an example:
Let's say your initial code was
CODE
and that it printed:0
Then, insert
CODE
in the middle: your code becomesCOCODEDE
and it should print:00 00
Re-insert
CODE
in the middle: your code becomesCOCOCODEDEDE
and should print:000 000 000
And so on. Your answer should theoretically work after any number of iterations, but I understand if, due to language performance limitations, it cannot run reasonably over a certain threshold.
Some rules:
You can use any printable ASCII (32-127) as the character to use for your square. Your choice needs to be constant (You should use the same character for each iteration).
The initial output square must have side-length 1.
An ascii-art square is defined as a string with N lines (separated by N-1 linefeeds / newlines), and with each line containing N copies of the chosen character.
Your output isn't allowed to contain any extraneous whitespace, other than a trailing newline.
You can use the defaults for input and output (programs or functions are allowed, but snippets are not).
The middle of your code is defined as the point where the source code can be split in two parts such that the two are equal.
Your answers will be scored by the length of your original program, in bytes. The lowest byte count wins. In case there's a tie, the answer that was submitted earlier wins.
You can use this program to apply the insertions without having to do that by hand.
1
I must admit I was inspired by this quine question posted earlier. If people think it is too close, I'll happily delete this. Also excuse me if I made any mistakes, I am still not too experienced with the rules here. :)
– None – 2018-02-02T12:15:43.9602
Welcome to PPCG! I suggest using the Sandbox for your future challenges.
– user202729 – 2018-02-02T12:17:47.6637Welcome to the site! Excellent use of another challenge for inspiration without falling into the dupe trap :) – Shaggy – 2018-02-02T13:31:21.087
Your helper program doesn't work for programs with multiple lines. How about this modified version from the other question?
– Jo King – 2018-02-03T00:09:00.353@JoKing Oh whoops, fixed now. I actually modified my Python program to take input from command line arguments rather that STDIN, which removes the issues. I'd rather not have a reference implementation in Brainfuck, but thanks anyway for pointing that out! – None – 2018-02-03T09:49:09.080
1@user77954 But my brainfuck code is shorter than your python :( (has anyone ever said that before?) – Jo King – 2018-02-03T11:33:59.070