23
2
A Quat is a combination of a quine and the popular esolang cat program.
Challenge
The challenge is to write a standard cat program. Whatever the user inputs, the program will echo the input to stdout.
However, when the length of the input is greater than 0 and a multiple of 4, the program should output its own source code. Quat comes from the Portuguese quatro, which translates to 'four'.
Rules
- Standard loopholes apply
- You may not read the source code from a file
- An empty input should produce an empty output
Bonus
If your input length is a multiple of 4 you can earn a 25% bonus by printing the quine length/4
times. Another 5% bonus if you seperate the output by spaces (no trailing space allowed).
Test cases
The following test cases apply for the program in%4=0?cat:self
(not a real language).
<empty input> -> <empty output>
input -> input
1234 -> in%4=0?cat:self
12345678 -> in%4=0?cat:self
0% bonus
12345678 -> in%4=0?cat:selfin%4=0?cat:self
25% bonus
12345678 -> in%4=0?cat:self in%4=0?cat:self
30% bonus
Scoring
This is code-golf. Shortest code in bytes wins.
Can the input have multiple lines? – LegionMammal978 – 2015-12-10T23:14:34.213
@LegionMammal978 Ofcourse, let
\n
be the new line character, for 1 byte of input – Bassdrop Cumberwubwubwub – 2015-12-11T08:36:55.617Okay, it just complicates input in my language, which must be read one line at a time. – LegionMammal978 – 2015-12-11T11:20:42.723
Are built-ins for quines allowed? (see: Seriously)
– Addison Crump – 2015-12-11T11:48:25.137@FlagAsSpam I don't mind, but I think a meta-post is more appropriate here. – Bassdrop Cumberwubwubwub – 2015-12-11T12:16:44.050
@Bas I meant for your question, not in general. But okie den. – Addison Crump – 2015-12-11T12:17:50.297
@FlagAsSpam The OP of What counts as a proper quine? says "Clearly, any quine in HQ9+ or a related language is not a proper quine," and I don't see any contention over that point in the answers. I'm pretty sure I've seen that same point made in other posts.
– ThisSuitIsBlackNot – 2015-12-11T15:45:10.300Is there any maximum input size we have to support? (I.e. do we have to buffer all 5 gigabytes of input until deciding whether to output them or the own source code?) – Paŭlo Ebermann – 2015-12-12T10:34:40.647