Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
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 ...
dan04's user avatar
  • 6,581
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
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
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 ...
Joe Z.'s user avatar
  • 34.7k
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
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 ...
vsz's user avatar
  • 8,117
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
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
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
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: ...
Wheat Wizard's user avatar
  • 96.5k
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
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 ...
shamp00's user avatar
  • 1,251
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.5k
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.5k
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 ...
Esolanging Fruit's user avatar
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 ...
Chris_Rands'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
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
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
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. ...
Steadybox's user avatar
  • 16.5k
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 ...
MD XF's user avatar
  • 13.8k
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
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
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
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
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
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 ...
SEJPM's user avatar
  • 3,383
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 ...
emanresu A's user avatar
  • 35.6k
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
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
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 ...
SEJPM's user avatar
  • 3,383
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 ...
Zgarb's user avatar
  • 42.5k
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.5k
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
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 ...
Wheat Wizard's user avatar
  • 96.5k
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 ...
NoShady420's user avatar
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-...
Number Basher's user avatar
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 ...
FreezePhoenix's 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
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
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
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 ...
Kevin Cox's user avatar
  • 451
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 ...
AndrewTheCodegolfer'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
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
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. ...
Silvio Mayolo's user avatar
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"...
l4m2's user avatar
  • 20.7k
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
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 ...
Wheat Wizard's user avatar
  • 96.5k