Skip to main content

Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
1 vote
2 answers
191 views

Many polyglots fill in the blanks between languages by either making code that is ignored in one language or loading code dynamically. This time, let's write a polyglot that works without that. This ...
user31248584's user avatar
1 vote
0 answers
90 views

Write a piece of code that is compatible with both C and Python compilers/interpreters, which can output its own source code. Quine is quite easy, but how about this double language version? Hint: To ...
NoNormalCreeper's user avatar
-2 votes
1 answer
148 views

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

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,857
6 votes
1 answer
263 views

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
10 votes
9 answers
2k views

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
  • 103k
22 votes
15 answers
3k views

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
  • 103k
6 votes
2 answers
331 views

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
  • 24.7k
-14 votes
5 answers
481 views

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 ...
Sunny's user avatar
  • 2,004
19 votes
3 answers
977 views

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
  • 103k
9 votes
10 answers
830 views

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-...
Sunny's user avatar
  • 2,004
20 votes
15 answers
2k views

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-...
Sunny's user avatar
  • 2,004
29 votes
21 answers
5k views

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
  • 46.2k
6 votes
1 answer
727 views

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,377
17 votes
5 answers
1k views

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 coinheringaahing's user avatar
8 votes
3 answers
833 views

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

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
  • 46.2k
20 votes
8 answers
2k views

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,799
16 votes
4 answers
975 views

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 coinheringaahing's user avatar
26 votes
6 answers
2k views

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 coinheringaahing's user avatar
16 votes
7 answers
672 views

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
  • 10k
20 votes
19 answers
6k views

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

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
375 views

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
12 votes
6 answers
2k views

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
669 views

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,231
15 votes
15 answers
1k views

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
22 votes
5 answers
3k views

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
816 views

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,871
-3 votes
2 answers
467 views

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
2k views

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
822 views

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
5 votes
3 answers
584 views

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
  • 941
6 votes
9 answers
1k views

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
  • 941
41 votes
18 answers
4k views

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
3k views

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
779 views

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
  • 32.6k
29 votes
44 answers
7k views

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
  • 79.3k
16 votes
3 answers
676 views

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
  • 797
46 votes
34 answers
16k views

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
  • 103k
26 votes
11 answers
2k views

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,212
79 votes
16 answers
15k views

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.6k
8 votes
5 answers
702 views

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,986
-4 votes
2 answers
374 views

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
68 votes
60 answers
12k views

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
  • 14.3k
25 votes
6 answers
1k views

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,463
35 votes
64 answers
7k views

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

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,463
24 votes
7 answers
1k views

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
  • 43.2k
11 votes
1 answer
448 views

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