9
1
Create three programs, which we'll call Rock, Paper, and Scissors.
Each program must be unique, and accept input.
If a program gets any input which is not one of the programs Rock, Paper or Scissors, it must print itself.
RPS style, the programs will each print one of the following four outputs:
- "win" if the running program beats the program that is being input
- "lose" if the running program loses against the program that is being input
- "tie" if the input is equal to the source code of the running program
- The source code of the running program itself for any other input (including an empty input)
General rules:
- The three programs can be in any language. Rock can be in a different language from Paper: same for any other pair.
- They are not restricted by size.
- They must print through STDOUT or closest equivalent, and must print strings or closest equivalent. They must not print to STDERR.
- They need not be full programs. They can be functions, if you wish to get rid of the stuff needed in a program, like C's #includes.
This is a code-golf challenge, where your score is determined by the sum of the programs' sizes. The person with the lowest score wins.
If two people have the same score, the person whose largest program by bytes out of the set Rock, Paper, Scissors is smaller wins.
5I recommend sum instead of average, no need to divide or include annoying thirds. Then, this could just be tagged [tag:code-golf] and [tag:quine] – Redwolf Programs – 2019-11-27T19:48:28.723
I thought the scores would get too boringly small with sums, but then again, that applies to thirds too, – Andrew – 2019-11-27T20:22:28.717
So far both answers have interpreted "If given any input other than what will be specified below, each prints itself" to mean they are allowed to output win/lose/tie for certain inputs that are not the other program. If you intend to keep this requirement I suggest you further reinforce it. – FryAmTheEggman – 2019-11-27T20:42:21.653
1I took the liberty of formatting the challenge description a bit, since it was a bit hard to read with all separated lines instead of paragraphs. If I accidentally removed or misinterpret something, feel free to change it again. And one question: you state the three programs can be in any language, does this mean the Rock program could be in a different language than the Paper program as well? Or you simply mean all languages are open to compete, but the Rock, Paper, and Scissor programs should still be in that same language? – Kevin Cruijssen – 2019-11-28T07:50:37.360
Is a full program mandatory, or could we also do a (lambda) function? Usually functions are allowed by default to get rid of all the fuss every program need mandatory (like
interface M{static void main(String[]a){...}}
for Java instead ofv->{...}
if it's a function. – Kevin Cruijssen – 2019-11-28T08:11:33.710