Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
5 votes
1 answer
233 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 ...
user avatar
  • 1,250
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}$$ ...
user avatar
8 votes
3 answers
368 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 ...
user avatar
18 votes
10 answers
2k 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 ...
user avatar
  • 27.1k
19 votes
8 answers
1k 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 ...
user avatar
  • 5,787
15 votes
2 answers
521 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 ...
user avatar
26 votes
6 answers
1k 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 ...
user avatar
16 votes
7 answers
556 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 ...
user avatar
  • 9,791
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 ...
user avatar
26 votes
1 answer
1k 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 ...
user avatar
1 vote
1 answer
234 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 ...
user avatar
11 votes
6 answers
1k 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 ...
user avatar
0 votes
1 answer
238 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 ...
user avatar
  • 2,035
15 votes
15 answers
747 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 ...
user avatar
  • 151
20 votes
5 answers
2k 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 ...
user avatar
-9 votes
1 answer
626 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"...
user avatar
  • 3,583
-2 votes
2 answers
295 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 ...
user avatar
  • 105
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 ...
user avatar
3 votes
2 answers
746 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 ...
user avatar
4 votes
3 answers
490 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, ...
user avatar
  • 887
4 votes
8 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 ...
user avatar
  • 887
39 votes
17 answers
3k 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 ...
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 ...
user avatar
11 votes
5 answers
687 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"...
user avatar
  • 12.7k
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): ...
user avatar
  • 62.1k
16 votes
3 answers
573 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 ...
user avatar
  • 749
46 votes
33 answers
15k 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: ...
user avatar
  • 84.8k
26 votes
10 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 ...
user avatar
  • 5,972
75 votes
16 answers
13k 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. ...
user avatar
  • 16.2k
8 votes
5 answers
653 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 ...
user avatar
  • 2,861
-4 votes
2 answers
302 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 ...
user avatar
62 votes
58 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 ...
user avatar
  • 13.2k
24 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 ...
user avatar
  • 3,253
35 votes
64 answers
6k 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 ...
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 ...
user avatar
  • 3,253
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 ...
user avatar
  • 42k
11 votes
1 answer
389 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. ...
user avatar
7 votes
1 answer
246 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. ...
user avatar
59 votes
18 answers
7k 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 ...
user avatar
  • 99.3k
17 votes
2 answers
610 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 ...
user avatar
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 ...
user avatar
  • 84.8k
20 votes
6 answers
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 ...
user avatar
  • 84.8k
9 votes
6 answers
790 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 ...
user avatar
17 votes
15 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
19 votes
6 answers
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 ...
user avatar
  • 41.4k
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
5 votes
3 answers
624 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 main ...
user avatar
70 votes
10 answers
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 ...
user avatar
58 votes
37 answers
8k 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
4 votes
1 answer
374 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 ...
user avatar