Questions tagged [polyglot]

For challenges involving code that runs in multiple programming languages.

Filter by
Sorted by
Tagged with
17
votes
8answers
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 ...
11
votes
1answer
254 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 ...
25
votes
6answers
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 ...
14
votes
7answers
459 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 ...
21
votes
19answers
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 ...
24
votes
1answer
894 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 ...
1
vote
1answer
190 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 ...
10
votes
6answers
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 ...
-1
votes
1answer
200 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 ...
15
votes
15answers
700 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 ...
19
votes
5answers
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 ...
-8
votes
1answer
531 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"...
-2
votes
2answers
259 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 ...
12
votes
21answers
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 ...
3
votes
2answers
715 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 ...
5
votes
2answers
619 views

A Multipurpose Quine

I personally love quines, but they all seem to be so... static. So why not create a quine that can do more. Challenge The challenge here is to create a quine that without any sort of input is a ...
4
votes
3answers
430 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, ...
4
votes
8answers
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 ...
37
votes
17answers
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 ...
17
votes
50answers
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 ...
11
votes
5answers
645 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"...
28
votes
39answers
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): ...
15
votes
3answers
525 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 ...
38
votes
30answers
14k 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: ...
26
votes
10answers
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 ...
72
votes
15answers
12k 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. ...
8
votes
5answers
646 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 ...
-4
votes
2answers
280 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 ...
57
votes
53answers
9k 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 ...
25
votes
6answers
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 ...
30
votes
59answers
5k 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 ...
41
votes
12answers
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 ...
23
votes
7answers
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 ...
11
votes
1answer
335 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. ...
7
votes
1answer
217 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. ...
59
votes
18answers
6k 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 ...
14
votes
2answers
550 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 ...
45
votes
3answers
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 ...
20
votes
6answers
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 ...
9
votes
6answers
772 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 ...
17
votes
15answers
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 ...
19
votes
6answers
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 ...
28
votes
10answers
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 ...
5
votes
3answers
613 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 ...
70
votes
10answers
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 ...
49
votes
29answers
7k 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 ...
4
votes
1answer
357 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 ...
22
votes
7answers
741 views

Print Polyglot Pieces

Typically, polyglots are constructed in such a manner that each language can ignore parts of the code that are present for other languages, by wrapping them in string literals, using comment syntax, ...
263
votes
300answers
110k 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 made. ...
18
votes
1answer
585 views

Make a regex polyglot

Write a regex that works in at least 2 regex flavors (or versions), and match a different string in each flavor (or version) it is running in. The strings to be matched in this challenge are the ...