Questions tagged [polyglot]
For challenges involving code that runs in multiple programming languages.
57
questions
40
votes
17
answers
4k
views
Golf a mutual quine
Using two languages of your choice, write the smallest “mutual quine” you can.
That is, write a program P in language A that outputs the source code for a program Q in language B, such ...
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 ...
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 ...
14
votes
9
answers
3k
views
Build a polyglot for Hello World
Produce a text file that prints "Hello World!" in as many programming languages as possible when compiled/interpreted, while also being as short as possible.
The score for your submission is ...
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, ...
71
votes
17
answers
6k
views
Write a polyglot that prints the language's name
Your task is to write a program that executes in as many languages as possible, with as few characters as you can. To avoid trivial solutions, the program must print the name of the language it was ...
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 ...
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 ...
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 ...
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 ...
46
votes
34
answers
16k
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:
...
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 ...
30
votes
2
answers
5k
views
What code compiles in the most number of languages? [closed]
Excluding trivial programs, what code compiles in the most number of languages?
(By "trivial" I mean to exclude answers such as the empty program or text that will be echoed directly.)
The following ...
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 ...
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 ...
41
votes
18
answers
4k
views
Overlapping Polyglots
Unlike many C&R challenges, this does not require a separate robbers post; the goal of the robbers is to crack the previous answer and then post a new one as a cop.
As answerers, you will write a ...
35
votes
64
answers
7k
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 ...
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 ...
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 ...
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 ...
76
votes
16
answers
14k
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.
...
66
votes
60
answers
11k
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 ...
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 ...
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 ...
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 ...
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.
...
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'...
41
votes
12
answers
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 ...
29
votes
21
answers
4k
views
Add a hidden language to a polyglot
Inspired/mostly copied but I don't think it's a dupe. Also Inspired.
In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't ...
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 ...
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 ...
25
votes
6
answers
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
...
24
votes
7
answers
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 ...
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 ...
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 ...
21
votes
15
answers
2k
views
Polyglot Quiz (Cops' thread)
This is the cops' thread of a cops-and-robbers challenge. The robbers' thread can be found here
In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty ...
21
votes
19
answers
5k
views
The Return of FizzBuzz
Intro
Beauty lies in the eye of the beholder. Output lies in the choice of the compiler. There are some codes that give different outputs based on what language they are executed in. Take for ...
19
votes
15
answers
2k
views
Two In One: Guess That Language - Cops
Robber's challenge
This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-...
18
votes
50
answers
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 ...
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 ...
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 ...
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. ...
14
votes
13
answers
2k
views
Write a Program in Disguise [closed]
The challenge is to create a program that solves any one of the HQ9+ problems while looking like another language.
Note: This is not a golf challenge.
Rules:
The program must perform one of the ...
12
votes
21
answers
1k
views
An OEIS polyglot
This is an answer-chaining challenge relating to the OEIS.
Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every ...
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 ...
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 ...
11
votes
1
answer
411
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. ...
11
votes
5
answers
704
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"...
10
votes
4
answers
526
views
Write a Semiquine
Suppose you have 2 languages, A and B. A string s is a semiquine in ...
9
votes
9
answers
2k
views
Polyglot Quiz (Robbers' thread)
This is the robbers' thread. For the main rules to this challenge see the cops' thread
In this challenge, robbers will choose a cop's vulnerable or safe post and try to figure out a pair of languages ...