Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

14
votes
50answers
2k views

Add a egaugnaL to a polyglot

This is an answer-chaining question, which means that all answers are affected by those before them. The task The n-th answer to this question must run in all languages that are present in answers ...
10
votes
5answers
518 views

Quine of orders

Write a program that, when run in different languages, outputs a different byte permutation of the code in each language. The exact source code is counted as one permutation. Here "different language"...
18
votes
26answers
5k views

This code errors on *this* and *that*, is it really written in them?

Inspired by I'm not the language you're looking for! Challenge Choose two different programming languages, and write a program that prints the following line to stdout (or equivalent): ...
15
votes
3answers
358 views

The Pyramid of Languages

Write a code that runs or compiles in as many programming languages as possible and prints a newline separated list of names of previous and current programming languages. Every used language must ...
32
votes
20answers
12k views

Wait, what language is this?

Recently I had the pleasure of writing a Haskell program that could detect if the NegativeLiterals extension was engaged. I came up with the following: ...
25
votes
10answers
1k views

404 - Unique 404 page not found

Inspired by a polyglot on the Stack Overflow 404 page: Goal Your goal is simple, to create a polyglot that outputs the number 404, and then terminate, in as many languages as possible. Restrictions ...
70
votes
13answers
8k views

Hello World in Multiple Languages

Task Create a program or a function that is valid in multiple programming languages, and when compiled/interpreted as a different language outputs "Hello, World!" in a different natural language. ...
8
votes
5answers
607 views

Life and Death of Trees

The Challenge Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10. The Stages of Life and Death ...
-4
votes
2answers
206 views

Polyglot the English Alphabet! [closed]

In this polyglot challenge, you will work together to figure out how to output all the 26 letters of the English alphabet! How does this work? For each answer, you must pick a new language (or a new ...
43
votes
42answers
7k views

Determine your language's version

Your challenge is to write a polyglot that works in different versions of your language. When run, it will always output the language version. Rules Your program should work in at least two versions ...
23
votes
6answers
1k views

Polyglot the (non constant) OEIS!

Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers. Introduction We all ...
27
votes
56answers
4k views

'abc' and 'cba'

Your task is simple, write a single code snippet that when executed in one language outputs only the string 'abc' and when executed in another language outputs ...
42
votes
12answers
3k views

Polyglot the OEIS! [duplicate]

Note: This challenge has been moved to Polyglot the (non constant) OEIS! to avoid closure. Introduction We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made ...
23
votes
7answers
1k views

Fake divisor sum polyglots

The task In this challenge, your task is to write a program in a programming language L that takes a positive integer n, and outputs the sum of the proper divisors of n (sequence A001065 on OEIS). It ...
11
votes
1answer
279 views

Cyclic Polyglot Challenge (Cops)

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. ...
7
votes
1answer
176 views

Cyclic Polyglot Challenge (Robbers)

Cyclic Polyglot Challenge This is the robbers thread. You can find the cops thread here. Cyclic Polyglot A N-element cyclic polyglot is a complete program that can be run in N different languages. ...
56
votes
18answers
6k views

Count like Chuck Norris

As is well known, Chuck Norris counted to infinity. Twice Besides, Chuck Norris can count to infinity backwards. Also, although perhaps less known, Chuck Norris can speak a little Spanish in ...
11
votes
2answers
332 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 ...
35
votes
2answers
1k 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. Here is a ...
19
votes
6answers
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 ...
8
votes
6answers
688 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 ...
14
votes
12answers
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 ...
19
votes
6answers
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 ...
26
votes
9answers
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 ...
6
votes
3answers
479 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 ...
69
votes
10answers
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 ...
48
votes
29answers
6k 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 ...
4
votes
1answer
300 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 ...
23
votes
7answers
691 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, ...
220
votes
228answers
69k 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 made. ...
19
votes
1answer
487 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 ...
12
votes
9answers
726 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 ...
48
votes
16answers
3k 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 ...
8
votes
1answer
370 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 ...
40
votes
15answers
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 ...
32
votes
7answers
1k 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 ...
22
votes
24answers
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 ...
44
votes
32answers
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 ...
18
votes
9answers
723 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 ...
15
votes
15answers
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. ...
13
votes
5answers
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 ...
157
votes
122answers
30k 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 ...
89
votes
18answers
15k 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 ...
24
votes
2answers
2k 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 ...
10
votes
4answers
451 views

Write a Semiquine

Suppose you have 2 languages, A and B. A string s is a semiquine in ...
-1
votes
1answer
441 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 ...
2
votes
0answers
171 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 ...
15
votes
4answers
934 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 ...
91
votes
36answers
10k 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, ...
22
votes
4answers
490 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 ...