11
\$\begingroup\$

Cyclic Polyglot Challenge

This is the cops thread. You can find the robbers thread here.

Cyclic Polyglot

A N-element cyclic polyglot is a complete program that can be run in N different languages. In each language, when the program is run with no input (possibly subject to this exception), it should print the name of a language to STDOUT. Specifically, if the program is run in the Kth language, it should print the name of the (K+1)th language. If the program is run in the Nth language (that is, the final language in an N-element cycle), it should print the name of the first language.

An example might be useful.

a = [[ v = 7, puts('Befunge') ]]
__END__
= print("Ruby")
-->*+:292*++,,@
--3    9
--7    *
--^,:-5<

Running this program with Lua prints the string "Ruby". Running this program in Ruby prints the string "Befunge". Running this program in Befunge prints the string "Lua", completing the cycle. This program constitutes a 3-cycle consisting of Lua, Ruby, and Befunge.

The same language cannot appear twice in a cycle, and different versions of the same language (such as Python 2 and Python 3) cannot appear in the same cycle as one another.

Cops

Your challenge is to write an N-cyclic polyglot, where N is at least 2. Then, you must add, replace, and delete some number of characters to the program to produce an M-cyclic polyglot, where M is strictly greater than N. You should then post the shorter, N-cyclic polyglot (and the languages it runs in), as well as the number of characters you changed to produce the longer polyglot. Your score is N, the number of languages in your shorter cycle.

The robbers will try to identify your longer cycle. If, after seven days, no one has successfully cracked your solution, you should edit your answer declaring that it is safe. You should also post your longer M-cyclic polyglot at this time.

Robbers

Given a cop's N-cyclic polyglot and the number of characters they added to produce a larger polyglot cycle, your goal is to produce that larger cycle. If you can produce a longer cycle by adding, deleting, or replacing as many characters as the cop did or fewer characters, you have cracked the cop's polyglot. Your score is the length of the new cycle you've created. Your new polyglot need not be the same as or even similar to the cop's secret polyglot; it only needs to be larger than their existing one.

Your solution may also be cracked. If another robber comes along and produces a cycle strictly longer than yours, starting from the same cop's polyglot, they have stolen your points.

Valid Programming Languages

Since this challenge indirectly involves guessing programming languages used by other participant's, the definition of a programming language for the purposes of this challenge will be a little more strict than the usual definition. A programming language used in this challenge must satisfy all of the following conditions.

Final Notes

  • The code you write should be a standalone program in every language that it is intended to run in. Functions or code snippets are not allowed.
  • Your program will be given no input through STDIN. Likewise, your program should print nothing to STDERR.
  • A cop's score is the number of languages in the cycle of the polyglot they posted. The cop should post the languages that the posted polyglot runs correctly in, as well as the number of characters they added to produce a longer polyglot. They are not responsible for posting the languages the longer, hidden polyglot runs in until their answer is safe.
  • A robber's score is the number of languages the modified polyglot runs in. As with the cop, the robber should post the list of languages the polyglot runs correctly in.
  • The number of characters changed should be computed in Levenshtein distance.
\$\endgroup\$
  • 3
    \$\begingroup\$ "The language must have a freely available interpreter or compiler. Sorry, Mathematica fans, but the robbers need to be able to verify your solution." Whats wrong with the Wolfram Open Cloud? sandbox.open.wolframcloud.com \$\endgroup\$ – Scott Milner Jul 5 '17 at 2:37
  • \$\begingroup\$ I was unaware of such a thing, as I have a local copy of Mathematica on my computer. Comment removed. \$\endgroup\$ – Silvio Mayolo Jul 5 '17 at 2:39
  • \$\begingroup\$ Is it ok for N=2 and M=3? \$\endgroup\$ – mdahmoune Jul 5 '17 at 10:13
  • \$\begingroup\$ Yes, that's fine. Your score will simply be 2 then, but that's perfectly acceptable. \$\endgroup\$ – Silvio Mayolo Jul 5 '17 at 12:02
1
\$\begingroup\$

C (gcc), 126 bytes

M=N+1

Levenshtein(polyglot(M),polyglot(N)) is 36 bytes

#include<stdio.h>
#define print(a) main(){int z[1];if(sizeof(0,z)==4)printf("C(gcc)");else printf("Perl5");}
print("C++(gcc)")

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Cracked (with Levenshtein of 10) \$\endgroup\$ – Stephen Jul 5 '17 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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