The Challenge

Write two programs P and Q such that:

  • P and Q are written in the same language
  • The output of P is Q
  • The output of Q is P
  • P and Q are both non-empty

Simple enough. Surely that's been done here before. Where this gets interesting is the scoring.


  • P and Q are selfish, they don't want to sheir their precious characters! The primary means of scoring is the number of source characters existing in both P and Q. The lower the number the better.
  • If two programs share the same number of characters, the sum length of their programs will be the tie breaker.

Clarification and Example

There's two ways to interpret this and I feel an example would best explain which is correct.

We say the programs aabb and bbcc share a single character, b, NOT two characters b and b

  • \$\begingroup\$ I think you should at least require that the two programs are nonempty. You might want to let this sit in the sandbox a while, since there are probably other things I haven't thought of that might hurt your chances at getting interesting answers. \$\endgroup\$ Commented Jan 21, 2020 at 6:17
  • \$\begingroup\$ @FryAmTheEggman nice catch! \$\endgroup\$
    – Mason
    Commented Jan 21, 2020 at 6:21
  • \$\begingroup\$ Possible duplicate: Mutually exclusive quines. If we assume this challenge is also asking for proper quines, the winner of the linked challenge will also win here (primary score 0 and shortest length sum as the tiebreaker). If non-proper quines are allowed, P and Q should at least be distinct, otherwise the answer zone will be flooded with trivial answers like P = Q = 1. \$\endgroup\$
    – Bubbler
    Commented Jan 21, 2020 at 6:43
  • \$\begingroup\$ @Bubbler oh wow, that was pretty much my original thought, but I though only allowing no overlap might exclude too many languages. Guess I was wrong XD \$\endgroup\$
    – Mason
    Commented Jan 21, 2020 at 6:54


Browse other questions tagged or ask your own question.