4
\$\begingroup\$

Challenge

Create 2 programs A and B

  • The output of program A is exactly program B

  • The output of program B is exactly program A

  • Neither program should depend on inputs to yield the correct output

  • A and B are not identical programs

  • A and B are of different programming languages

  • Neither program may be equivalent to itself in the other language. For example, if the chosen languages are C and C++, the C++ program must not be a valid and equivalent C program, else the "inter-language" requirement is redundant

A solution should include:

Scoring

The score for a solution is:

  • The length of the shortest program +

  • The combined length of the names of both programming languages, as they appear on tio.run

The reason for this unusual scoring is because this constitutes the combined length of the minimum information necessary to communicate your solution.


This is my first post to Code Golf. Any edits to this post to increase clarity or appropriate vocabulary are welcome.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Welcome to the site. I would really recommend removing the name penalty. "Common name" is not going to be clear for a lot of instances. I don't really get the reason this was included in the first place and it just leads to trouble down the road when people try to golf the language name. \$\endgroup\$
    – Wheat Wizard
    Jan 11, 2020 at 1:26
  • 2
    \$\begingroup\$ Also not an issue or even something that needs to be changed, but the penultimate and antepenultimate bullets are redundant, both are implied by the last bullet point. \$\endgroup\$
    – Wheat Wizard
    Jan 11, 2020 at 1:27
  • \$\begingroup\$ So essentially, this is a multi-language quine that can't be a polyglot. \$\endgroup\$
    – lyxal
    Jan 11, 2020 at 1:49
  • \$\begingroup\$ @PostRockGarfHunter I did suspect that the "Common name" qualifier may cause some problems, but for now I'd like to leave it as a (maybe naive) experiment in seeing how such an odd type of scoring will play out. \$\endgroup\$ Jan 11, 2020 at 1:51
  • \$\begingroup\$ @Jono2906 no problem if either program can "speak" both languages, i.e. is a valid program in both languages, but if it gives the same output in both, that violates the last rule. See Jo King's answer \$\endgroup\$ Jan 11, 2020 at 1:54

2 Answers 2

3
\$\begingroup\$

><> and Gol><>, 18 bytes + 3 + 6 = 27

'3d*:5-0@o~r{?H>o<

Try it online!

and

"3d*:5-0@o~r{?H>o<

Try it online!

Both output the same program, but with the first character flipped between ' and ". Neither program is equivalent to itself in the other language, since the behaviour of @ differs.

\$\endgroup\$
5
  • \$\begingroup\$ So the first is a Gol><> quine and the second is a ><> quine that both just happen to produce the same output in the other language? Seems that makes them equivalent to me, but what do I know? \$\endgroup\$
    – Neil
    Jan 11, 2020 at 1:29
  • \$\begingroup\$ Indeed this solution is quite a "near-miss", but both programs have different outputs in each language as outputted by "try it online". I'm interested to see how the problem becomes (presumably) more complicated with non-golfing and more dissimilar languages \$\endgroup\$ Jan 11, 2020 at 1:37
  • \$\begingroup\$ Sure, by running the first program in ><> and the second program in Gol><> they output each other, but that's not what I said. \$\endgroup\$
    – Neil
    Jan 11, 2020 at 1:42
  • 1
    \$\begingroup\$ Yes this is a valid. By "near-miss" I meant that it narrowly dodges each restriction i.e. 1. the programs are not identical, 2. the languages are not the same, and 3. neither program is equivalent in the other language \$\endgroup\$ Jan 11, 2020 at 1:42
  • 1
    \$\begingroup\$ Ah I see now, both programs are equivalent to each other in the same language. \$\endgroup\$
    – Neil
    Jan 11, 2020 at 1:44
2
\$\begingroup\$

Jelly, 13 bytes + 8 = score 21

“Ṿ;⁾v`+/ŒṘ”v`

Try it online!

RAD

'“Ṿ;⁾v`+/ŒṘ”v`'

Try it online!

A Jelly quine that wraps itself in single quotes, such that the resultant RAD program simply prints the original Jelly program back out.

Thanks to @JoKing for golfing the language name for the second program!

\$\endgroup\$
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.