Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
17 votes
2 answers
645 views

Quine/Error Quine Polyglot

Your task is simple: Write a program that can be run in two languages. It should be a normal quine (prints its own source code) in language 1, and should be an error quine (generates an error message ...
Esolanging Fruit's user avatar
45 votes
3 answers
2k views

Klein Topololyglots

Klein is a 2D language I have designed that can be embedded on 12 different topological surfaces. A Klein program can be run on different surfaces by changing the command line arguments. The ...
Wheat Wizard's user avatar
  • 96.6k
20 votes
6 answers
1k views

Anaglot Polygrams

Task Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n. No two languages should be the same however different ...
Wheat Wizard's user avatar
  • 96.6k
9 votes
6 answers
808 views

Backwards and forwards polyglot quine!

You must make a polyglot that outputs its source code in one language and its source code backward in another. Unlike the normal rules, you are allowed to read the current file or use a builtin to get ...
user avatar
18 votes
16 answers
3k views

Plus or minus polyglots!

Your submission must take a list of numbers (in whatever list format your language supports, or using multiple function / command-line parameters) or a string of numbers separated by any character ...
user avatar
19 votes
6 answers
2k views

Contradictory Polyglots

Well, everyone loves Polyglots. You will be given two integers, in any standard form of input (no hardcoding). Your task is to write a polyglot which finds the minimum value in a language and the ...
Mr. Xcoder's user avatar
  • 42.3k
28 votes
10 answers
2k views

GCD / LCM Polyglots!

Your challenge is to make a program or function that outputs the GCD of its inputs in one language and the LCM of its inputs in another. Builtins for GCD or LCM (I'm looking at you, Mathematica) are ...
user avatar
5 votes
3 answers
626 views

The Big Bang Polyglot [duplicate]

Everyone loves The Big Bang Theory, right? And everyone loves polyglots, right? So let's combine them! Task Your task in each language is quite basic. You must output the name of the one of the 5 main ...
caird coinheringaahin g's user avatar
70 votes
10 answers
6k views

Rock, Polyglot, Scissors

Write a program that is a polyglot in three languages that plays rock–paper–scissors. The input for any version of the program is always one of the strings rock or ...
Calvin's Hobbies's user avatar
61 votes
40 answers
9k views

Calculate a square and a square root!

You must make a polyglot that outputs the square of the input in one language and the square root of the input in another. The shortest answer in bytes wins! You must have a precision of at least 3 ...
user avatar
4 votes
1 answer
389 views

Labyrinth Polyglot [closed]

Create a program that can create a randomly arranged maze (The path of the maze changes each time) with exactly 1 exit and one enterance and a minimum size of 8x4 and max size of 32x32, with the exact ...
GracefulLemming's user avatar
22 votes
7 answers
791 views

Print Polyglot Pieces

Typically, polyglots are constructed in such a manner that each language can ignore parts of the code that are present for other languages, by wrapping them in string literals, using comment syntax, ...
user avatar
301 votes
451 answers
125k views

Add a language to a polyglot

This is an answer-chaining challenge in which each answer builds on the previous answer. I recommend sorting the thread by "oldest" in order to be sure about the order in which the posts are ...
user avatar
19 votes
1 answer
681 views

Make a regex polyglot

Write a regex that works in at least 2 regex flavors (or versions), and match a different string in each flavor (or version) it is running in. The strings to be matched in this challenge are the ...
jimmy23013's user avatar
  • 36.9k
13 votes
10 answers
955 views

Multi-lingual Challenge

After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages? Your answer needs to accept boolean input ...
steenbergh's user avatar
  • 8,094
51 votes
16 answers
4k views

Tips for creating polyglots

A polyglot is a program that can be run in 2 or more different programming languages. What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a ...
jimmy23013's user avatar
  • 36.9k
7 votes
1 answer
537 views

Comment-free polyglot with different, nontrivial, behaviour per language

This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on ...
user avatar
39 votes
15 answers
3k views

What will you bring for Thanksgiving?

Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the ...
ETHproductions's user avatar
31 votes
7 answers
2k views

Three polyglots, two period-two quines, and one code-golf challenge

Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C. Program B, when run in language B produces Program A, and running ...
noɥʇʎԀʎzɐɹƆ's user avatar
23 votes
24 answers
2k views

Polyglot Anagrams Robbers' Thread

This is the robbers' thread of this challenge The cops will choose an OEIS sequence and write two full programs in two different languages that produces that nth item in the sequence when given an n ...
Wheat Wizard's user avatar
  • 96.6k
44 votes
32 answers
3k views

Polyglot Anagrams Cops' Thread

This challenge has two threads. This is the cops' thread. The robbers' thread is located here. Your challenge is to choose an OEIS sequence and write two full programs in two different languages that ...
Wheat Wizard's user avatar
  • 96.6k
18 votes
9 answers
931 views

The meta-polyglot quine

In my time on PPCG, I've noticed that quine problems and polyglot problems are quite popular. Also, meta-solutions to problems, that is, scripts which generate a program which is the solution to a ...
Pavel's user avatar
  • 9,369
15 votes
15 answers
2k views

Palindrome polyglot

Your task is to write a program that runs in two different languages, and does the following: In one language, it palindromizes a given string. Take the string. ...
Oliver Ni's user avatar
  • 10.6k
12 votes
5 answers
1k views

Add comments to a Python script and make it a bilingual Python/C++ “program”

Given the following Python 3 script: def greet(): print("Hello, world!") greet() Prepend some lines to this text file so that it can be both executed as a ...
Leon's user avatar
  • 317
165 votes
128 answers
33k views

Trick or Treat polyglot

Since Halloween is coming up I thought I might start a fun little code golf challenge! The challenge is quite simple. You have to write a program that outputs either ...
BrainStone's user avatar
  • 1,531
96 votes
19 answers
19k views

When was this language released?

Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that ...
DJMcMayhem's user avatar
  • 58.9k
26 votes
2 answers
3k views

Write a Palindrome-Polyglot-Quine

Write a "palipolyquine": a program that is a quine, a polyglot, and a palindrome. Rules: The number of polyglot languages is more preferable than code size. The shortest answer (in bytes) wins, in ...
Ivan Kochurkin's user avatar
10 votes
4 answers
526 views

Write a Semiquine

Suppose you have 2 languages, A and B. A string s is a semiquine in ...
user avatar
-1 votes
1 answer
490 views

"I know that language - that's Java. No? It's Perl?" [duplicate]

Introduction A known fact is that Jon Skeet can code Perl and make it look like Java. In this challenge you will try to do something similar. Challenge Write a piece of code of any length that can ...
palsch's user avatar
  • 123
3 votes
0 answers
348 views

Windows batch polyglot/hybrids challenge with any language possible [closed]

/* I hope such question is suitable for here*/ As the batch scripts are pretty limited, hybrid files that embed a code from another language into a batch file are used a lot lately. Though usually ...
npocmaka's user avatar
  • 131
18 votes
4 answers
1k views

An executable script file that runs on POSIX and Windows

Challenge: write a single script file foo.cmd which can be invoked from the vanilla Windows cmd.exe prompt (not PowerShell, not ...
jez's user avatar
  • 539
103 votes
41 answers
13k views

The Versatile Integer Printer

Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, ...
Stewie Griffin's user avatar
21 votes
4 answers
536 views

Multiple program Quinecatenate!

Your task is to give three different languages A, B, C, and write two different programs P and Q such that: P is a quine in language A, but not a quine in B nor C; Q is a quine in language B, but ...
Faraz Masroor's user avatar
12 votes
3 answers
1k views

Carrots. So. Many. Carrots

The Inspiration The Task You must create a program, that, in as many languages as possible, replaces every instance of ^ with a markdown formatted link (meaning ...
Addison Crump's user avatar
1 vote
1 answer
184 views

Palandrome-ish code [closed]

Create a program that does the same thing forwards and backwards, in different languages. “Different languages” does not include different versions of the same language. Challenge This program can ...
J F's user avatar
  • 281
42 votes
6 answers
1k views

Overcoming cluster size

Fed up with the reliability of flash storage, you decided to store all your programs on one of those good old 1,440 KiB floppies. However, after copying not even 3,000 programs, the disk was full. How'...
Dennis's user avatar
  • 210k
197 votes
120 answers
27k views

I'm not the language you're looking for!

Isn't it annoying when you find a piece of code and you don't know what language it was written in? This challenge attempts to somewhat solve this. Challenge You will have to write a program that ...
Blue's user avatar
  • 28.5k
11 votes
1 answer
598 views

Non-Palindromic Polyglot Boggle

Introduction The number 101 is a palindrome, since it reads the same backwards and forwards. The number 105 is not. However, 105 in base eight is written as 151, which is palindromic. On the other ...
Ypnypn's user avatar
  • 10.8k
1 vote
0 answers
741 views

The polyglot challenge! [duplicate]

A polyglot is a program which can be run by several different language's interpreters/compilers without failing. For example, the stackoverflow 404 page contains a polyglot which runs in Python, Perl,...
theonlygusti's user avatar
  • 1,279
11 votes
1 answer
399 views

Pseudo-quine polyglot language-detection counters

Quines are fun. Polyglots are fun, too. Polyglot Quines exist, but we can raise the bar even higher. Write a file that contains a valid program for languages α, β, and γ. When the ...
FUZxxl's user avatar
  • 10.1k
31 votes
7 answers
2k views

Write a C / C++ Polyglot [closed]

This challenge's concept is pretty simple. All you have to do is write a program that will compile as both valid C and valid C++! Well, there are some catches. The program must behave differently when ...
Mewy's user avatar
  • 429
22 votes
12 answers
2k views

Restricted Polyglot

Polyglots are programs that are valid in multiple programming languages simultaneously. Most such polyglots are written in such a way that certain constructs of one language are interpreted as ...
nneonneo's user avatar
  • 12.3k
36 votes
21 answers
4k views

Write a Polyquine

A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins. 1 I made that up. Or ...
Martin Ender's user avatar
107 votes
14 answers
20k views

Possibly quit your job with a polyglot

Despite your protest, you have been put to work by your boss on a program that takes a single unsigned integer as input and prints the string "prime" if that integer is prime and "not ...
overactor's user avatar
  • 3,580
43 votes
14 answers
10k views

99 Bottles of beer, 99 languages [closed]

The goal is to write a simple "99 Bottles of Beer" program .. that is valid in at least 2 distinct languages (e.g. not Python 2 and Python 3). It must be a complete file that will run or compile. ...
MadTux's user avatar
  • 697
24 votes
27 answers
5k views

Valid Through The Ages

Inspired by this question on SO, your task is to produce a program that is valid in (at least) two major versions of your chosen language that produce different output. Rules Any language that has ...
James Webster's user avatar
64 votes
43 answers
9k views

π Day puzzle for 3/14

Happy π Day. The goal of this question is to calculate the area for a circle of radius 3, where A = πr². The catch is that you have to use the constant π that is defined in a different language than ...
Kevin's user avatar
  • 3,131
13 votes
5 answers
1k views

Hide a Brainf*** greeting in other code

The goal is to write a program (anything except explicit brainfuck) which prints Barney Stinson's best rule: New is always better. when interpreted normally, but Legen... wait for it... dary! ...
Thomas Ayoub's user avatar
7 votes
4 answers
1k views

Turing-Complete polyglot [closed]

Write a polyglot (code that works in two or more languages) that has a "mid-section" that can be modified to do any computational task. This question is similar to https://stackoverflow.com/questions/...
Kevin Kostlan's user avatar
11 votes
5 answers
2k views

Just Another Polyglot Hacker! [duplicate]

Make a program which prints just another #{LANG} hacker where #{LANG} is the name of the language with which the program is ...
ike's user avatar
  • 1,875