Fixed Repeating Output is a challenge originally invented by Esolang user AnotherUser05 which shows that a language supports loops and I/O.
Challenge
A program that solves the challenge has to do these steps in order:
- Reads a decimal integer
x
from any sort of input (e.g.: STDIN, file). - Then, print
1
forx
times to any sort of output (e.g.: STDOUT, file). - Then, print
0
to any sort of output (e.g.: STDOUT, file). As an exception, outputting the0
via exit code is not allowed because that would be unfair.
For example, if the input is 5
, then:
1
1
1
1
1
0
and
111110
are both valid outputs, but
101111
is not a valid output.
A program doesn't have to output the 1
's and the 0
to the same destination, but it still has to print the 1
's first, then the 0
. The behavior when x
is negative is undefined.
This is code-golf, so shorter program wins.
x
is 0? And does it explicitly have to be a program using input and output, or would just a function returning a string count? \$\endgroup\$x
is 0, it prints0
because printing1
zero times is the same as doing nothing. For the second question, I'm not the original author of the challenge so let's say that it counts. \$\endgroup\$1,1,1,1,1,0
as the output. What about1 1 1 1 1 0
? Or[1,1,1,1,1,0]
? \$\endgroup\$