Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
2 votes
0 answers
137 views

Popular polyglot producer [closed]

Choose a set S of languages from the top 50 languages by TIOBE Index score as of January 2024, and in one of the chosen languages, create a program that takes as ...
Vitphire's user avatar
-3 votes
1 answer
96 views

PHP+C polyglot solution to mixed types

Some built-in functions in PHP return mixed types, like file_get_contents that returns both string or ...
Olle Härstedt's user avatar
26 votes
14 answers
3k views

Reverse the polyglot, change the language

Task Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must also output the other language's name if the source code is ...
emirps's user avatar
  • 1,797
6 votes
1 answer
217 views

Need some feedback with PHP+C polyglot code and class/struct properties [closed]

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call: ...
Olle Härstedt's 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
  • 97.6k
21 votes
15 answers
3k 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
  • 97.6k
6 votes
2 answers
294 views

Case Conversion Polyglot

Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of ...
Dom Hastings's user avatar
  • 23.2k
-13 votes
5 answers
360 views

12 with no 1234567890, but polyglot

This is my 12th question, so I thought of this idea. Goal: Output 12, with any preceding or trailing whitespace permitted In as many languages as possible (where different versions or flags count as ...
Number Basher's user avatar
18 votes
3 answers
827 views

Universal Unicode Clock

Plot contrivance You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991. You check the computer ...
Wheat Wizard's user avatar
  • 97.6k
9 votes
10 answers
631 views

Two In One: Guess That Language - Robbers

Cops' 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
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
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
  • 37.1k
6 votes
1 answer
668 views

Irradiated Polyglots

Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original ...
Romanp's user avatar
  • 1,357
17 votes
5 answers
1k views

Are you a probabilist or a physicist?

Hermite polynomials refer to two sequences of polynomials: The "probabilist's Hermite polynomials", given by $${He}_n(x) = (-1)^n e ^ \frac {x^2} 2 \frac {d^n} {dx^n} e ^ {-\frac {x^2} 2}$$ ...
caird coinheringaahin g's user avatar
8 votes
3 answers
757 views

Polyglot Interpreters

Challenge Choose any number of languages. Call this set L. Write a program so that running it in any language in L produces an interpreter for a different language ...
KinuTheDragon's user avatar
18 votes
12 answers
3k views

Make a polyglot generator

A polyglot is a program that runs in several languages. Your challenge is to: Choose at least two languages (Different versions count as different languages) Create a program or function that takes ...
emanresu A's user avatar
  • 37.1k
19 votes
8 answers
2k views

(Error) quines, hello world, polyglots, oh my!

Introduction A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it ...
Makonede's user avatar
  • 6,465
16 votes
2 answers
756 views

Pristine Polyglots

As the title says, you are to create a pristine program in as many languages as possible. A pristine program, taken from here, is: Let's define a pristine program as a program that does not have any ...
caird coinheringaahin g's user avatar
26 votes
6 answers
2k views

Build an alphabetised polyglot

As TIO can show, every letter of the Latin alphabet is represented when it comes to languages. For every letter there is at least 1 programming language whose name begins with that letter. Your task ...
caird coinheringaahin g's user avatar
16 votes
7 answers
584 views

Inspired by HQ9+: 4-Behavior Polyglot

Create a program that can be run in 4 different languages such that: One language prints "Hello World!" One language outputs its own source code One language outputs 99 bottles of beer on ...
Beefster's user avatar
  • 9,901
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
27 votes
1 answer
2k views

Program that compiles into itself

We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a ...
ais523 - high effort answers's user avatar
1 vote
1 answer
294 views

Polyglot "Hello world" in Fortran and Lisp [duplicate]

Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible ...
CoffeeTableEspresso's user avatar
11 votes
6 answers
2k views

Polyglot self-interpreter time

Your task is to make a program which interprets the language it is run in, but also works in many languages. Let's say you make a Brainfuck-Underload self-interpreglot, as it will be called. Run in ...
AndrewTheCodegolfer's user avatar
0 votes
1 answer
610 views

Polyglot Iterative Quine

Introduction A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of ...
sugarfi's user avatar
  • 2,193
15 votes
15 answers
1k views

Restricted-source polyglot string

Your goal is to write a program that prints the string abc in two languages. However, while the full code will print abc in one ...
fle's user avatar
  • 151
20 votes
5 answers
3k views

Print your char count in words, in many languages

This challenge is inspired by my earlier challenge "Create a program that prints the amount of characters it has, in words". This challenge's rules are simple: make a program that prints its ...
AndrewTheCodegolfer's user avatar
-11 votes
1 answer
728 views

Don't get banned from stack exchange! [closed]

I'm sure this is going to spark some controversy, but let's do a practical demonstration. The objective of this is simple, using the new code of conduct and no input, print out my pronouns ( "he/him"...
tuskiomi's user avatar
  • 3,831
-3 votes
2 answers
356 views

Write a "hello world" program that can be compiled/interpreted as two different languages simultaneously [duplicate]

Rules: Your program must print "hello world" when executed Your program must be interpretable or compilable into 2 or more languages Your program must require no input or arguments Languages with ...
BLuFeNiX's user avatar
  • 103
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
3 votes
2 answers
783 views

A poly-moly-holy quine. (Well, it's not, but the title's cool.)

This is an answer chaining puzzle, where each answer must add on to the last. The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it. A ...
AndrewTheCodegolfer's user avatar
4 votes
3 answers
527 views

Polycops and Robbers (Robbers' Thread)

This is the robbers' thread, the cops' thread is here A polyglot is a program, that without modification, can run in multiple languages. Robbers' Challenge First, find a vulnerable cop's answer, ...
kepe's user avatar
  • 923
5 votes
9 answers
1k views

Polycops and Robbers (Cops' Thread)

This is the cops' thread, the robbers' thread is here A polyglot is a program, that without modification, can run in multiple languages. Allowed languages Any language that was made before the ...
kepe's user avatar
  • 923
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
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
11 votes
5 answers
709 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
  • 22.3k
29 votes
44 answers
6k 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): ...
Bubbler's user avatar
  • 74.9k
16 votes
3 answers
614 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 ...
RedClover's user avatar
  • 777
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
  • 97.6k
26 votes
11 answers
2k 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 ...
Adalynn's user avatar
  • 6,092
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
8 votes
5 answers
657 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 ...
Ian H.'s user avatar
  • 2,926
-4 votes
2 answers
319 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 ...
arodebaugh's user avatar
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
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,393
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
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,393
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
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
7 votes
1 answer
271 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. ...
Silvio Mayolo's user avatar