title: It's Anagram Quine, not just Quine!

text:
# Question
Title: It's Anagram Quine, not just Quine!
# The Task

In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible.

Your score will be the number of anagrams of your program's source code that are valid quines divided by the total number of anagrams possible, i.e. the percentage of the anagrams that are valid quines.

Standard Loopholes and rules of standard quines apply.

**Note:** Your program must have at least 3 *characters* (not 3 bytes).

---

## Input

Each anagram (or permutation) of your program which is quine of itself (i.e. the anagrams which you are including in your score) must not take any input. If your language *requires* input as a necessity, then you can assume that your program will be given a String consisting of the lowercase letter A. However, you must not make any use of the input in any way.

---

## Output

`n` number of distinct anagrams of your program's source-code must be valid quines, where `n` represents the number of those anagrams that you are including in your score, i.e.

Those quine-anagarams can output in any way except writing the output to a variable. Writing to file, console, screen etc. is allowed. Function `return` is allowed as well.

---

## Scoring Example

Suppose your program's source code is `code`. And,

1. `code` outputs `code`.
2. `coed` outputs `coed`.
3. `cdoe` outputs `cdoe`.
4. `cdeo` outputs `cdeo`.
5. `cedo` outputs `cedo`.
6. `ceod` outputs `ceod`.
7. `ocde` outputs `ocde`.
8. `oced` outputs `oced`.
9. `odce` outputs `odce`.
10. `odec` does not output `odec` or produces error.
11. `oedc` does not output `oedc` or produces error.
12. `oecd` does not output `oecd` or produces error.
13. `doce` does not output `doce` or produces error.
14. `doec` does not output `doec` or produces error.
15. `dcoe` does not output `dcoe` or produces error.
16. `dceo` does not output `deco` or produces error.
17. `deco` does not output `deco` or produces error.
18. `deoc` does not output `deoc` or produces error.
19. `eodc` does not output `eodc` or produces error.
20. `eocd` does not output `eocd` or produces error.
21. `edoc` does not output `edoc` or produces error.
22. `edco` does not output `edco` or produces error.
23. `ecdo` does not output `ecdo` or produces error.
24. `ecod` does not output `ecod` or produces error.

The score of this solution will be

---

## Winning Criterion

The solution with the highest score wins! In case of a tie, the answer with higher char-count (not byte-count) wins (hence the )! If a tie still persists, then the solution which was posted earlier wins!

# Answer
> 7 votes
# Unary, 100%

This is essentially the same as the Lenguage answer because of how the two are related. I think it's worth noting, though. I scored it as 100% because every permutation of the code will result in a quine of itself and I see that as X/X * 100 = 100%.

5.71728886e+3431 zeroes. The full number can be found in this snippet:

```
571,728,886,299,524,079,667,110,831,585,172,705,903,242,988,869,730,233,666,941,239,930,957,383,634,990,884,017,758,011,673,661,456,375,420,014,789,453,910,279,412,516,365,039,911,616,569,776,194,653,994,845,706,814,330,810,597,741,840,830,026,333,447,578,878,492,702,908,613,882,908,168,867,637,282,596,648,914,407,902,821,648,635,054,942,485,156,519,086,239,517,305,702,705,783,520,430,327,882,724,649,323,623,993,252,952,774,346,675,694,385,891,810,563,667,798,834,846,369,950,692,136,274,353,903,969,878,343,229,031,870,459,050,270,140,433,402,333,183,995,076,273,934,316,316,041,923,055,208,568,854,697,194,015,046,079,301,420,468,901,769,118,098,230,767,460,924,846,552,476,679,293,134,684,448,847,449,288,151,944,932,525,087,248,192,275,095,934,337,598,653,981,534,386,220,451,824,875,829,915,842,538,357,082,913,137,430,485,883,178,947,004,702,124,084,633,123,544,060,730,650,995,512,745,030,590,989,195,409,454,379,726,020,068,090,543,485,377,485,846,396,271,958,108,709,617,635,354,477,293,970,464,272,097,575,501,779,386,668,756,938,340,200,794,894,015,824,708,091,428,944,573,831,257,244,094,409,870,775,301,993,104,432,870,895,478,408,037,450,837,230,273,086,589,639,225,269,690,034,191,664,788,952,560,282,035,550,980,217,998,364,096,267,637,012,870,557,015,775,372,943,770,232,826,937,792,678,659,741,977,391,285,036,126,978,266,614,181,473,074,907,458,591,514,305,961,253,806,814,023,933,864,985,407,267,169,604,856,107,931,116,888,268,748,039,451,683,353,551,414,447,462,928,850,923,445,503,652,021,793,168,648,510,513,597,305,336,955,173,718,471,931,736,313,986,020,652,567,023,366,257,316,037,210,037,318,158,858,503,724,736,280,981,391,398,280,363,850,853,361,932,459,586,164,155,418,666,917,331,478,035,204,211,067,642,357,524,068,995,687,396,230,593,421,768,310,516,964,395,591,974,018,305,173,396,770,508,740,001,527,520,092,344,197,005,623,355,537,596,657,473,766,544,801,370,212,627,256,410,732,664,011,822,421,191,103,127,619,073,582,845,123,484,719,578,718,376,300,070,162,355,969,718,786,766,544,705,666,866,547,241,576,008,751,585,319,953,584,072,266,931,915,765,118,041,170,749,844,694,686,800,072,822,536,450,477,293,767,227,280,278,303,598,479,313,816,303,539,184,630,996,668,979,230,004,925,749,414,158,627,159,671,600,379,023,203,894,575,932,729,998,748,035,419,783,450,180,418,397,923,824,642,227,478,374,530,825,875,117,414,862,969,170,359,605,774,864,660,165,183,532,258,493,867,754,625,154,388,052,741,695,648,070,594,472,531,159,793,952,847,078,816,841,601,345,611,759,202,959,380,748,999,978,577,549,942,317,774,738,570,775,404,426,481,919,733,186,968,468,431,270,431,605,972,498,637,946,956,126,022,229,614,797,087,117,225,823,565,342,748,501,153,741,450,722,494,697,466,495,557,622,414,355,168,111,360,033,562,039,346,636,733,121,121,610,857,454,876,606,487,443,794,811,222,591,756,267,144,914,006,412,918,432,311,781,300,777,103,610,374,114,091,997,695,742,108,877,002,082,862,282,098,075,681,749,979,978,446,425,489,037,395,541,763,956,873,201,738,020,809,689,085,082,333,652,677,837,122,632,903,083,224,964,125,736,624,491,672,540,404,024,051,399,430,701,347,505,739,704,581,760,444,853,708,889,328,730,053,965,944,499,104,791,856,210,999,740,898,398,825,918,657,619,888,095,865,548,102,735,913,913,094,386,735,714,696,418,726,741,576,678,447,905,375,266,819,534,780,270,705,492,733,528,843,064,273,668,310,355,948,806,085,914,998,909,078,430,123,434,842,644,353,766,593,108,209,757,731,578,915,664,389,676,321,477,765,937,156,616,387,196,395,610,946,243,206,146,663,560,610,797,140,874,906,254,178,018,061,181,083,047,209,661,789,909,286,724,851,898,477,573,800,702,633,601,175,620,396,600,949,134,122,178,276,685,812,142,120,568,127,180,096,273,903,971,758,009,993,201,718,908,993,673,764,199,386,800,398,143,178,502,530,082,660,500,014,722,964,981,864,977,851,706,298,981,882,062,478,994,083,243,364,559,882,663,594,491,418,634,537,443,259,947,411,981,605,363,306,172,530,522,346,606,185,828,881,879,282,631,498,937,150,281,652,951,729,913,616,393,089,658,674,346,663,853,707,461,126,940,124,422,764,766,614,384,500,640,200,165,833,857,590,144,741,546,981,402,879,612,572,412,230,319,659,934,882,344,598,744,566,237,876,680,653,747,327,784,600,034,796,624,136,727,679,072,247,471,775,907,417,517,609,655,422,229,860,544,695,004,718,249,668,190,489,544,232,936,202,367,307,609,329,582,839,156,431,588,444,789,676,252,562,273,585,535,627,566,417,124,298,941,319,814,273,113,830,010,077,536,882,402,273,792,934,052,604,658,425,046,299,684,558,311,449,368,519,016,440,435,219,777,519,127,752,414,574,327,366,464,226,160,312,027,143
```

The Brainf\*ck equivalent is in this snippet:

```
>+++++>++>++++++>+>+++++>+++++>+>++++++>+>+++++>+>++++++>+>+++++>+>++++++>+++>+++++>+++++>+>+++>++>+
+++>++++++>++>++++++>+++>+++++>++>++++++>++>+++++>++>++++++>+>+++++>+++++>+>++++++>+>+++++>+>++++++>
+>+++++>+>++++++>++>+++>+++++>+++++>+>+++>++>++++>++++++>++>++++++>+++>+++>+++>+++++>++>++++++>++>++
+++>++>++++++>+>++++>++++++>+>++++++>+>+++++>+>++++++>+>+++++>++++>+++++>++>+++>+>++++>++++++>+>++++
++>++>++>+++++>++>++++++>+>+++++>+++++>+++++>+>++++++>+>+++>++>++>+++++>++>++++++>+>++++>++++++>+>++
+++>+>++++++>+++>+>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>+++++>++++>++>++++>+>
+>+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+>+>+>+++>+++++>++>++>++>++++++>+>++++++>++>+++++>++++>+>+>
+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+++>+>+>+>+++>+++>+++++>++>++>++>++++++>++++++>+>++++++>++>++
+++>++++>+>+>+>+++++>+>+>+>++++++>+++>+++>+>+>+>+++>+++>+>+>+>+++>+++++>++>++>++>++++++>++++++>+>+++
+++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+++>+>+>+>+++>+++>+++++>++>++>++>++++++>+++
+++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+++>+>+>+>+++>+++++>++>++>++>+++++
+>++++++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+>+>+>+++>+++>+++++>++>++>++>
++++++>++++++>+>++++++>++>+++++>++++>+>+>+>+++++>+>+>+>++++++>+++>+>+>+>+++>+>+>+>+++>+++++>++>++>++
>++++++>++++++>++>+++++>++>++++++>+>++++++>+++>+++>++>+++>+++++>++>+++>+>+>+++++>+++++>+>+++>+>+++>+
+>++>++++>++++++>+>+++++>++>+++>+>++++>++++++>+>++++>+++++>++++>+++++>++++>+>+++++>+>+++>+>+++>++>++
>++++>++++++>+>+++++>++>+++>+>++++>++++++>+>+++++>++>+++>+>++++>+++++>++>++++>+>+++++>++++>++++++>++
++++>++++++>++>+++++>++++>++>++++>+>+>+>+++++>+>+>+>++++++>++>++>++>+++++>+++++>+>+>+>+++>++>++>++>+
+++>++++++>++>++>++>++++++>+>+>+>+++>+++>+++>++>++>++>+++>+++>+++>++>++>++>++++>++++>++++>++>++>++>+
++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+++>+++++>+>+>+>++++++>+>++++++>++>++>++++++>++++
++>+>++++++>++>++>++>+++++>++>++>++>++++++>+>+++++>++>++>+++>+>+++>+>++++>++++++>++>++>+++++>+>+>+++
>++>++>++++>++++++>+>+++++>++++>+>+>+>+++++>+++++>+>+++>+>+++>++>++>++++>++++++>+>+++++>++>+++>+>+++
+>++++++>+>++++>+++++>++>+++>+>++++>+++++>++>++++>+>++++>++++++>++>+++++>++++>++>++++>++++>+>+>+>+++
++>+>+>+>++++++>++>++>++>+++++>+++++>+>+>+>+++>++>++>++>++++>++++++>++>++>++>++++++>+>+>+>+++>+++>++
+>++>++>++>++>++>++>+++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+++>+++++>+>+>+>++++++>++>++
>++++++>+>++++++>+>++++++>++>++>++>+++++>++>++>++>++++++>++++++>+>+++++>++>++>+++>+>+++>+>++++>+++++
+>++>++>+++++>+>+>+++>++>++>++++>++++++>+>+++++>++++>+>+>+>+++++>+++++>+>+++>+>+++>++>++>++++>++++++
>+>+++++>++>+++>+>++++>++++++>+++>+>++++>+++++>++>++++>+>+++++>++++>++++++>++++++>++>+++++>++++>++>+
+++>++>++>++>+++++>++>++>++>++++++>+>++++>+>+>+++++>+>+>+>++++++>+>+>+>+++++>+++++>++>++>++>+++>+>+>
+>++++>++++++>+>+>+>++++++>++>++>++>++>++>++++++>+>+>++++++>++>++>++>+++++>++>++>++>++++++>++++++>+>
+++++>+>++++>++>++++>++++++>+>++++++>+>+++++>+++>+++>+++>+++++>+>+++>+++>+++>+++>+++>+++>+++>+++>++>
++++>++++++>+>+++++++>+>+>++++++[<]>[[>]>[>]>[>]+[[>+<-]<]+[<]<[<]>[[>]>[>]>[>]<+[[>+<-]<]+++[<]<[<]
>-]>]>[>]>[-[<+>-]>]<<[<]>[[[>]>+<<[<]>-]>[>]+>-[-[-[-[-[-[-<->>>[>>>]++>>>+>>>+[<<<]>]<[->>>[>>>]++
>>>++>>>++[<<<]]>]<[->>>[>>>]++>>>++>>>+[<<<]]>]<[->>>[>>>]+>>>++>>>++[<<<]]>]<[->>>[>>>]+>>>++>>>+[
<<<]]>]<[->>>[>>>]+>>>+>>>++[<<<]]>]<[->>>[>>>]+>>>+>>>+[<<<]]<[<]>]++
%
<+[<+>>[[>+>+<<-]>[<+>-]>-[-[->[>+>+<<-]>[<+>-]>[<+>-[<->[-]]]<[-<->>>[>>>]<<<[[>>>+<<<-]<<<]>>>+++<
<<+++<<<---<<<[<<<]>->>[>>>]+[>>>]>]<<]]>]<<<[<<<]>[<<+>+>-]<<[>>+<<-]>[->>>[[>+>+<<-]>[<+>-]>-[<+>-
[<->-]<[-<-->>>[>>>]<<<[[>>>+<<<-]<<<]>>>+++<<<<<<[<<<]>->>[>>>]+[>>>]<<]>]>]<<<[<<<]]>[<<+>+>-]<<[>
>+<<-]>[->>>[[>+>+<<-]>[<+>-]+>-[<->[-]]<[-<-<<<[<<<]>->>[>>>]>>>[[<<<+>>>-]>>>]<<<<<]>>]<<<[<<<]]>[
>-<-]>]>[+++[>++++++++<-]>.>>]
```

Source of source

# Answer
> 4 votes
# Lenguage, 100%

5.71728886e+3431 null bytes. The full number can be found in this snippet:

```
571728886299524079667110831585172705903242988869730233666941239930957383634990884017758011673661456375420014789453910279412516365039911616569776194653994845706814330810597741840830026333447578878492702908613882908168867637282596648914407902821648635054942485156519086239517305702705783520430327882724649323623993252952774346675694385891810563667798834846369950692136274353903969878343229031870459050270140433402333183995076273934316316041923055208568854697194015046079301420468901769118098230767460924846552476679293134684448847449288151944932525087248192275095934337598653981534386220451824875829915842538357082913137430485883178947004702124084633123544060730650995512745030590989195409454379726020068090543485377485846396271958108709617635354477293970464272097575501779386668756938340200794894015824708091428944573831257244094409870775301993104432870895478408037450837230273086589639225269690034191664788952560282035550980217998364096267637012870557015775372943770232826937792678659741977391285036126978266614181473074907458591514305961253806814023933864985407267169604856107931116888268748039451683353551414447462928850923445503652021793168648510513597305336955173718471931736313986020652567023366257316037210037318158858503724736280981391398280363850853361932459586164155418666917331478035204211067642357524068995687396230593421768310516964395591974018305173396770508740001527520092344197005623355537596657473766544801370212627256410732664011822421191103127619073582845123484719578718376300070162355969718786766544705666866547241576008751585319953584072266931915765118041170749844694686800072822536450477293767227280278303598479313816303539184630996668979230004925749414158627159671600379023203894575932729998748035419783450180418397923824642227478374530825875117414862969170359605774864660165183532258493867754625154388052741695648070594472531159793952847078816841601345611759202959380748999978577549942317774738570775404426481919733186968468431270431605972498637946956126022229614797087117225823565342748501153741450722494697466495557622414355168111360033562039346636733121121610857454876606487443794811222591756267144914006412918432311781300777103610374114091997695742108877002082862282098075681749979978446425489037395541763956873201738020809689085082333652677837122632903083224964125736624491672540404024051399430701347505739704581760444853708889328730053965944499104791856210999740898398825918657619888095865548102735913913094386735714696418726741576678447905375266819534780270705492733528843064273668310355948806085914998909078430123434842644353766593108209757731578915664389676321477765937156616387196395610946243206146663560610797140874906254178018061181083047209661789909286724851898477573800702633601175620396600949134122178276685812142120568127180096273903971758009993201718908993673764199386800398143178502530082660500014722964981864977851706298981882062478994083243364559882663594491418634537443259947411981605363306172530522346606185828881879282631498937150281652951729913616393089658674346663853707461126940124422764766614384500640200165833857590144741546981402879612572412230319659934882344598744566237876680653747327784600034796624136727679072247471775907417517609655422229860544695004718249668190489544232936202367307609329582839156431588444789676252562273585535627566417124298941319814273113830010077536882402273792934052604658425046299684558311449368519016440435219777519127752414574327366464226160312027143
```

# Answer
> 3 votes
# Jelly, 33.333...%

```
”ṘṘ

```

Try it online!

Community wiki because I did not write this. If you like this solution, or want an explanation, see Dennis's original post here.

# Answer
> 2 votes
# Microscript II, score 1/1814399=5.5e-7

```
"qp1h"qp1h

```

`"qph1"qph1` is also a quine.

# Microscript II, score 5/119750399=4.2e-8

```
"qp12h"qp12h

```

`"qp21h"qp21h`, `"qph12"qph12`, `"qph21"qph21`, `"qp1h2"qp1h2` and `"qp2h1"qp2h1` are also quines.

I'm sure someone can come up with a much higher score than either of these, but this is still the only answer with at least one quine that isn't the original program (which, IMO, shouldn't be counted).

# Answer
> 1 votes
# , 16.666...%

```
2i2i

```

Try it online!

There are 6 possible anagrams of this code:

```
2i2i
22ii
i22i
i2i2
ii22
2ii2

```

And one of them is a quine.

---
Tags: code-challenge, quine, source-layout, code-bowling, permutations
---


title: One 1, Two 1's, One 2 One 1

text:
# Question
Title: One 1, Two 1's, One 2 One 1
## Challenge:

Create a program that takes input of a positive non-zero integer and outputs the 4 next numbers in the sequence described below.

*Note: Checking if the input is actually a positive non-zero integer is not necessary*

## Sequence:

Every number in this sequence (apart from the first, which is the input) shall be composed of n digits, where n is an even number. If we split the number to n/2 pairs, for each pair, the first digit should be the amount of times the second digit appeared in the previous number

**Visual explanation**:
Consider this example "sequence starter" or input `6577`
The next number in the sequence should look like this `161527`
Because the input has 1 "6", 1 "5" and 2 "7"s.

If input has too many digits (more than 9 of a single digit) you wouldnt be able to get a correct output
Example: `111111111111` (12 1's)
Next number in sequence has to describe 12 1's. Thus we split it into 9 1's and 3 1's (sum 9+3 = 12)
Next number: `9131`

*You should iterate 4 times for the input, and output it (either return a list/array of 4 integers, or output it by seperating them with a space, newlines are also acceptable)*

**"The number can be written in a lot of ways, how do I write it?"**:
If you think about it, the example input `6577` can also be written as 271516 (two 7's, one 5, one six). However this is non-valid output. You should iterate the number left to right. Thus 161527. If it was `7657` you would iterate the amount of 7's, then amount of 6's then amount of 5's, thus valid output would be `271615`

## Example I/O:

Input:`75`
Output:`1715 211715 12311715 4112131715`

Input:`1`
Output:`11 21 1211 3112`

Input:`111111111111` (12 1's)
Output:`9131 192113 31191213 23411912`

---

This is unlike the "Say what you see" question, because the sequences are different: https://oeis.org/A005150 \<- This one returns numbers like this:
Input: 1211 Output: 111221
While the sequence I'm asking for would do
Input: 1211 Output: 3112

The two sequences are different and require different algorithms.
My asked sequence: https://oeis.org/A063850
"Possible duplicate" sequence: https://oeis.org/A005150

---

**Important specification:**

Since it wasnt clear enough for some people who tried to answer this question, the correct output for k chars where k \> 9 is not "kc" (where c is char) but 9c(k-9)c etc. Thus correct output for 12 1's isn't `121` (12 1) but `9131`(9 1's, (12-9) 1's and so on)

If in doubt, your code is wrong if it ever outputs a number with an odd amount of digits (like 121), it should have output of even digit numbers due to the nature of the sequence.

---

This is thus code with least bytes wins.

# Answer
> 6 votes
# PowerShell, ~~111~~ 104 bytes

```
$z=$args;1..4|%{($z=-join($z-split'\B'|group|%{for($c,$n=$_.Count,$_.Name;$c-gt9;$c-=9){"9$n"}"$c$n"}))}

```

Try it online!

# Answer
> 5 votes
# Python 2, 116 bytes

```
x=input()
exec"x=''.join(x.count(n)/9*(`9`+n)+`x.count(n)%9`+n for i,n in enumerate(x)if n not in x[:i]);print x;"*4

```

Try it online!

# Answer
> 4 votes
# 05AB1E, ~~30~~ ~~23~~ 21 bytes

```
4F©Ùv9y«®y¢9‰`U×XyJ}=

```

Try it online!

**Explanation**

```
4F                     # 4 times do:
  ©                    # store a copy of the current number in register
   Ùv                  # for each unique digit y in the number
     9y«               # concatenate 9 with y
        ®y¢            # count occurrences of y in current number
           9‰          # divmod by 9
             `U        # store the result of modulus in X
               ×       # repeat the number "9y" result_of_div times
                X      # push result of modulus
                 y     # push y
                  J    # join everything to one number
                   }   # end inner loop
                    =  # print the current number without popping

```

# Answer
> 1 votes
# Mathematica, 117 bytes

```
Grid@{Rest@NestList[FromDigits[Join@@(Reverse/@Tally@IntegerDigits@#//.{a_,b_}/;a>9->{9,b}~Sequence~{a-9,b})]&,#,4]}&

```

Seems like it shouldn't need to be this long.

# Answer
> 1 votes
# C# 246 bytes

```
namespace System{using Linq;using f=String;class p{static void Main(f[] s){f p=s[0];for(int i=0,n;i++<4;Console.Write(p+" "))p=f.Concat(p.GroupBy(c=>c).SelectMany(g=>new int[(n=g.Count())/9].Select(_ =>"9"+g.Key).Concat(new[]{n%9+""+g.Key})));}}}

```

Ungolfed:

```
namespace System
{
    using Linq;
    using f = String;
    class p
    {
        static void Main(f[] s)
        {
            f p = s[0];
            for (int i = 0, n; i++ < 4; Console.Write(p + " "))

                p = f.Concat(p.GroupBy(c => c).SelectMany(g =>
                    new int[(n = g.Count()) / 9].Select(_ => "9" + g.Key).Concat(new[] { n % 9 + "" + g.Key }
                )));
            Console.ReadKey();
        }
    }
}

```

Try it here (Type input into bottom frame once its compiled and hit ENTER)

# Answer
> 0 votes
# Jelly, 27 bytes

```
L,Ḣ
D©®i$ÞŒgs9$€Ç€€FḌµ4µÐ¡Ḋ

```

Try it online!

The successive s cannot be nested because chains cannot be nested.

Nesting with separate link: 27 bytes.

Print instead of cumulation: 27 bytes.

**Explanation**

```
L,Ḣ                     - helper function, does the look-and-say. Input is a list of digits
 ,                      - return 2-tuple of:
L                       -   length of input
  Ḣ                     -   first element of input

D©®i$ÞŒgs9$€Ç€€FḌµ4µÐ¡Ḋ - main link, takes input as integer
                 µ4µÐ¡  - repeat 4 times, saving the results of each iteration:
D                       -   convert integer to list of digits
 ©                      -   save into register, for later use
  ®i$Þ                  -   sort list's elements by first occurrence in list
      Œg                -   group runs of equal elements
        s9$€            -   split each run into sets which are at most 9 elements long
            Ç€€         -   do the look-and-say with helper function
               FḌ       -   flatten and convert back into integer for next iteration
                      Ḋ - remove the first element from the list since it includes the
                           initial element

```

# Answer
> 0 votes
# PHP, 141 Bytes

```
for($a=$argn;$i++<4;$a=$o,print$a._,$o="")foreach(array_count_values(str_split($a))as$n=>$c)$o.=str_repeat("9$n",$c/9^0).($c%9?($c%9).$n:"");

```

Try it online!

---
Tags: code-golf, number, number-theory
---


title: What will you bring for Thanksgiving?

text:
# Question
Title: 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 family members must coordinate who's going to bring each of the various dishes. In this challenge, the goal is to **write a polyglot that outputs a different dish in each language it's run in.**

## Menu

(Selected from Wikipedia. In case it's not obvious, each line is one item.)

```
turkey
stuffing
dressing
cranberry sauce
mashed potatoes
gravy
winter squash
sweet potatoes
corn
green beans
green bean casserole
mac and cheese
macaroni and cheese
salad
rolls
biscuits
corn bread
pumpkin pie
apple pie
mincemeat pie
sweet potato pie
pecan pie
apple cider
sweet tea

```

## Rules

* Each submission must run in **at least 3 languages**, each of which must output a **different** item from the menu. You may not use multiple versions of the same language (e.g. Python 2 and Python 3 cannot be used in the same answer).
* Each entry must have the same bytes in each language's encoding. For example, `ɱ` is byte `0x1D` in Jelly's encoding, which corresponds to `¢` in 05AB1E's encoding.
* Different languages may use different output methods, but **entries must be full programs in all languages**, and follow one of our default allowed IO methods.
* No programs may take input, but any of the programs may print to STDERR or throw runtime/compile time errors and warnings as long as the correct output is still printed to STDOUT or a file.
* **Case and whitespace do not matter.** For example, an output of `GreenbeAN S` would still count as `green beans`.
* As the central dish of every1 American Thanksgiving meal is turkey, **one language must output `turkey`** (ignoring case and whitespace).

## Scoring

**The submission that produces unique valid outputs in the most languages wins.** In case of a tie, the shortest of the tied entries in bytes wins.

1. Yes, turkey is not the only main dish, but we're going to pretend it is.

# Answer
> 32 votes
## Pyke, Pyth, Python 2, Foo, Brain\****, GolfScript, Actually, \<\>\<, Gol\<\>\<, Seriously, Befunge, Fission, Haystack, 13 languages, 546 bytes

When I saw the other ~~10~~ ~~11~~ 12 language answer, I had to add an extra ~~one~~ ~~two~~ 3. I'm also seriously considering dropping Pyth if only to save on bytes. (at the moment 162 of them)

```
#\ s[\g\r\a\v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'
print'corn'#))))))))))))))))))))))))]+[--------->++<]>+w.q++[->+++<]>++w.q+++++++++++w.q-----------w.q----------------;))!+f'!n'!i'!s'!s'!e'!r'!d'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))L
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))
#\25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c|000000
# ,,,,,,,,@0>00000000\#"biscuits"aetteews"

```

---

Pyke: Try it here! `rolls`

Relevent line of code:

```
#s[\g\r\a  \v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'

#s[\g\r\a  \v\y)w.q) - effectively a comment because # doesn't do anything with an empty stack
\r\o\l\l\ss - sum("r", "o", "l", "l", "s")
p - print(^)
00/ - raise a ZeroDivisionError to stop running code

```

---

Pyth: Try it here! `gravy`

Relevent line of code:

```
#s[\g\r\a  \v\y)w.q)\r\o\l\l\ssp00/;oooooooo'stuffing;oooooo~'`turkey'

#...) - while True:
s[\g\r\a  \v\y) - sum(["g", "r", "a", "v", "y"])
w - input()
.q - quit

```

All the `)`'s are for Pyth to make it compile without erroring on no input.

---

Python 2: `corn`

Line 1 is a whole comment

Line 2 prints "corn" and then has a comment

Line 3 has a string literal and then a comment

Line 4 onwards are comments

---

Foo: Try It Online! `biscuits`

Foo prints out anything enclosed in double quotes (`"`). In this case I was careful to only include languages that could cope with other forms of string input (Special case for Befunge). If there was any text after the final `"`, that would be printed too.

---

Brain\****: Try It Online! `salad`

I copied the output of constant string generator. I had to escape all `.` characters with `.q` so it would play with Pyth and `w.` so it would play with Pyke. I added some extra `-` characters so the cells would get to the right points before printing at another `.` character in the 3rd line

---

GolfScript: Try It Online! `cornbread`

In GolfScript, `#` is a comment until end of line.

What GolfScript interpreter sees:

```
#comment
print'corn'#comment
'bread'#comment

```

In GolfScript, for whatever reason, `print` takes a string and prints it without a newline. Just having `bread` is enough to print it as well.

---

Actually: Try It Online! `macandcheese`

Relevant line:

```
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))

é - clears the stack of whatever junk was on it before.
'i'n'o'r'a+++++ - create string "aroni"
) - rotate entire stack (effectively comments as stack is only 1 long)
♀1X - pop stack (now empty)
'c'a'm++++ - constructs the string "mac"
'e's'e'e'h'c'd'n'a++++++++ - constructs the string "andcheese"
) - rotate stack (reverse)
+ - "mac" + "andcheese"
� - quit

```

---

\<\>\<: Copy+Paste only `turkey`

---

Gol\<\>\<: Try It Online! `stuffing`

As \<\>\< except ``` skips the first `'` and only outputs enough characters to print `stuffing`

---

Seriously: Try It Online! `macaroniandcheese`

Relevant line:

```
'bread'#)))\é'i'n'o'r'a+++++))))))))))))))))))))))))))))))))))))))))))))))))\♀1X'c'a'm++++'e's'e'e'h'c'd'n'a++++++++)+.&\�0\ó))))))))))))))))))
é - clears the stack of whatever junk was on it before.
'i'n'o'r'a+++++ - create string "aroni"
) - rotate entire stack (effectively comments as stack is only 1 long)
♀1X - no-op
'c'a'm++++ - constructs the string "mac" + "aroni"
'e's'e'e'h'c'd'n'a++++++++ - constructs the string "andcheese"
) - rotate stack (reverse)
+ - "macaroni" + "andcheese"
. - print stack
0\ó - exit

```

---

Befunge: Try It Online! `sweettea`

Code that is looked at

```
#s[\g\r\a  \v - |
            ) - | - Directing the stack pointer to the correct place
            é - |
# ,,,,,,,,@0>00000000\#"biscuits"aetteews"

            >                              - change direction of travel
             00000000\#"biscuits           - a load of no-ops `#` skips the opening `"`
                                "aetteews" - add the chars to the stack in reverse order
  ,,,,,,,,@                                - output 8 chars from the stack and exit.

```

---

Fission: Try It Online! `dressing`

Code looked at:

```
;))!+f'!n'!i'!s'!s'!e'!r'!d'))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))L

```

Of which are used:

```
;!+f'!n'!i'!s'!s'!e'!r'!d'L
                          L - start an atom going left
                      !d'   - create the character `d` and print it
                              ...
;                           - exit

```

---

Haystack (2015): `PECANPIE` (with EXTRA newlines!)

```
#\
 r
 b
 \25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c

```

Of which do something functional:

```
  25*8*0+c25*6*9+c25*6*7+c25*6*5+c25*7*8+c25*8*0+c25*7*3+c25*6*9+c

```

I construct each upper case ascii codepoint for the letters in `PECANPIE` in uppercase because they're all below 100. I then print them all out as characters.

# Answer
> 10 votes
# CJam, 05AB1E, Dip, , 4 languages, ~~36~~ 34 bytes

*2 bytes saved thanks to @DrMcMoylex!*

```
"turkey"e#"corn"??"gravy"p&Ssalad

```

Original 36 byte code:

```
"turkey"e#"corn"??"gravy"p&ddisalad

```

After the `&` and before the `d` there is an `<ESC>`, which is 1 byte. So the code with the zero-width characters revealed looks like this:

```
"turkey"e#"corn"??"gravy"p&Ssalad

```

### CJam

(`<ESC>` is not shown)

```
"turkey"e#"corn"??"gravy"p&Ssalad
"turkey"                           e# push this string
        e#"corn"??"gravy"p&Ssalad  e# comment
                                   e# implicit output

```

Try it online! outputs `turkey`

### 05AB1E

(`<ESC>` is not shown)

```
"turkey"e#"corn"??"gravy"p&Ssalad
"turkey"                           # push this string
                                   # STACK: ["turkey"]
        e                          # calculates nPr for the last two values in the stack
                                   # since there is only one value, this evaluates to nothing
                                   # as a result, "turkey" is popped
                                   # STACK: []
         #                         # if true end, since this is false, the program doesn't end
          "corn"?                  # push this string and print it without newlines
                                   # STACK: []
                 ?                 # prints nothing, since there is nothing in stack
                  "gravy"p&Ssalad  # nothing happens here since the stack is already printed using a command and there is NO implicit print now, I think

```

Try it online! outputs: `corn`

### V

(`<ESC>` is shown)

```
"turkey"e#"corn"??"gravy"p&<ESC>Ssalad
"turkey"e#"corn"??"gravy"p&             Code that writes a newline followed by `rn"??"gravy"p&Ssalad`
                           <ESC>        Enters normal mode
                                S       Deletes line and enters insert mode
                                 salad  Writes salad

```

Try it online! outputs a newline followed by `salad`

### Dip

(`<ESC>` is not shown)

```
"turkey"e#"corn"??"gravy"p&Ssalad
"turkey"                           push this string
                                   STACK: ["turkey"]
        e                          not in the language's database
         #                         push str("turkey") --> "turkey"
                                   STACK: ["turkey"]
          "corn"                   push this string
                                   STACK: ["turkey","corn"]
                ?                  pop "corn", if it is the boolean True (which it isn't) execute the following,
                                   but since it is false, nothing until the next ? gets executed
                                   STACK: ["turkey"]
                 ?                 if-statement end
                                   STACK: ["turkey"]
                  "gravy"          push this string
                                   STACK: ["turkey","gravy"]
                         p&        print turkey and end program
                           Ssalad  irrelevant since program has ended

```

Outputs `gravy`

> Note: You cannot run `python3 dip.py` and then type in code for this due to the Escape character literal. It appears as `^[`, which makes the Dip interpreter get confused and it thinks that `[` is a command, and it results in an error.

The best way to run this is to edit the source file, change the last line in `dip.py`

```
main(input(">>> "), stack.Stack())

```

to

```
main("\"turkey\"e#\"corn\"??\"gravy\"p&Ssalad", stack.Stack())
exit()

```

Be sure to include the escape character literal!. Now the code as it is is passed into the interpreter so that it can understand it (`"` have to be escaped like `\"` so). Now if you run it from the command-line, it interprets the actual code and outputs `gravy`.

# Answer
> 9 votes
# MATL / Golfscript / 05AB1E / CJam: 4 languages, ~~34~~ 33 bytes

```
'TURKEY'%"rolls"#];"corn""bread"s

```

# Answer
> 7 votes
# ferNANDo / \>\<\> / Gol\>\<\> / 05AB1E / 2sable, 5 languages, 178 bytes

```
!v"`"v"!
     <;ooooo"salad"
"<;oooooooo"dressing
1 0
0 1 1 1 0 1 0 0
0 1 1 1 0 1 0 1
0 1 1 1 0 0 1 0
0 1 1 0 1 0 1 1
0 1 1 0 0 1 0 1
0 1 1 1 1 0 0 1
")\"corn""ab"û"aba"Qi"rolls"

```

# Answer
> 7 votes
# C, sh, Python 3, Nim, Julia, Brainf\**k -- 6 languages, ~~211~~ 209 bytes

```
#define println(x) main(){puts("turkey");}/*
#[
#=
a=''''
echo gravy
'''
println=lambda x:print("biscuits")
# ]#proc println[T](s:T)=echo"rolls"#--[----->+<]>---.++++++++++++.+++.----.
# =##*/
println("salad")

```

Languages to menu items:

* C outputs `turkey`
* sh outputs `gravy`
* Python 3 outputs `biscuits`
* Nim outputs `rolls`
* Julia outputs `salad`
* Brainf\**k outputs `corn`

*Added Julia thanks to @kvill!*

# Answer
> 7 votes
# Befunge-98, \>\<\>, , Python 2, 05AB1E, Gol\>\<\>, Foo, Haystack (the 2015 version), GolfScript, BF, Fission, Minkolang 0.15, Seriously, Axo: 14 languages, 381 bytes

### **This is a collaborative answer with BlueEyedBeast**

I decided to do a 2D approach to this question... Yes, there are **7** 2D esolangs!

I have taken inspiration for additional languages to add by BlueEyedBeast's answer (Foo, GolfScript)

`<ESC>` is the character literal for Escape.

```
#>!>\'n\'r\'o\'c\,,,,,@'s'a'l'a'dJ,é'g'n+'i+'s+'s+'e+'r+'d+.ó[-]+[----->+++<]>.+++++++++++.+++[->+++<]>++.+[--->+<]>.+++H'turkey'~;oooooooo'sweettea.0-5++++++++fffffffff''`'
#   >99*d1+c3-c89*4+dcc99*2+c!|$l9D3-O93++dOO8+O1+O1-O5+OO1+O95++O.
# >'p'()'u'()'m'()'p'()'k'()'i'()'n'()'p'()'i'()'e'()\
print'biscuits';'pecanpie'#"stuffing"R'c!'o!'r!'n!'b!'r!'e!'a!'d!*<ESC>ddddddSapplepie

```

### Befunge-98

```
#?!>                                nothing important
  'n                                push 'n'
                                    STACK: [110]
    \                               swap top two stack values (TBH, I'm not really sure what happens in this case)
                                    STACK: [110, 0]
     'r\'o\'c\                      repeat the same for other characters
                                    STACK: [110 114 111 99 0]
              ,,,,,                 output the next 5 top stack values, "corn"
                   @                end program
                                    rest of the code is irrelevant
                                    since program has already stopped

```

Try it online! outputs `corn`

### \>\<\>

Commands are shown in the order they appear

```
                                    enter from the left, direction = right
#                                   mirror, now the direction will change to left
                                    and it wraps around and comes to the right
                                    and reads code from the right to the left
'`'                                 push this
   ' ... 5-0.aetteews'              push this too
                      oooooooo      outputs the top 5 characters of the stack
                              ;     end program

```

Try it online! (Copy and Paste only) outputs `sweettea`

### V

```
             ...<ESC>                 writes stuff over three lines and enters normal mode
                     ddddddS          deletes 3 lines, delete another line and enter insert mode
                            applepie  writes "applepie"

```

Try it online! outputs `applepie` (it might take ˜20 seconds for it to run)

### Python 2

```
                                    # first two lines are comments
print"biscuits";                    # prints "biscuits" and ends statement
                'pecanpie'          # dangling (and ignored) string literal

```

Try it online! (Copy and Paste only) outputs `biscuits`

### 05AB1E

```
#>!>                                # does nothing important
\'n\                                # push 'n' and delete it
     'r\'o\'c\                      # repeat for other characters
              ,,,,,                 # prints 5 times (since there is nothing in stack,
                                    #                 prints nothing)
                   @                # push the index of the top of stack
                    's'a'l'a'd      # push these characters
                              J,    # join them and print them out
                                    # the rest of the code does not matter
                                    # since there is no implicit print
                                    # because we used the print statement

```

Try it online! outputs `salad`

### Gol\>\<\>

Commands are shown in the order they appear

```
                                    enter from the left, direction = right
#                                   mirror, now the direction changes to left
                                    and it wraps around and comes to the right
                                    and reads code from the right to the left
 '                                  starting parsing strings
  `                                 escape next character
   '                                gets escaped
    "                               stop string parsing
     fffffffff                      pushes 15, 8 times
           ++++++++                 adds up the numbers, resulting in 135
                 5-                 subtract 4 from it, 130
                   0                pushes 0
                    0               jumps to (130, 0)

#\'n\'r\'o\'c\,,,,,@'r'o'l'l'sJ, ... H'turkey'~;oooooooo"sweettea.0-5++++++++fffffffff""`"
                                              ^
                                       we are here now

                     ˜              removes value at top of stack, '"'
                      "yekrut"      push this string
                              H     Output stack as characters and halt program

```

Try it online! outputs `turkey`

### Foo

Foo outputs anything in double quotes, that is why I have been careful to not use any double quotes in the other languages. Since `"stuffing"` is in double quotes, it will be printed.

Try it online! outputs `stuffing` and then has an error

### Haystack (2015)

This uses Haystack's 2015 (not 2016) interpreter since the newer version is invalid. The interpreter for this is `haystack.py` and **not** `haystack_new.py`

Commands are shown in the order they appear

```
#                                 ignored
 \                                reflection (now it moves downwards)
  >                               set direction to right
   99*d1+c                        Output 'R'
          3-c                     Output 'O'
             89*4+dcc             Outputs 'L', newline, 'L'
                     99*2+c!|     Outputs 'S' and ends the program
                                  Note: '!' is ignored by the interpreter

```

This program outputs

```
R
O
L
L
S

```

and a newline after this output (hey, whitespace doesn't matter!)

### GolfScript

```
                                    first 2 lines are comments
print'biscuits';                    pushes "biscuits" to the stack and discards it
                'pecanpie'          push this
                          #...      comment
                                    implicit output

```

Try it online! outputs `pecanpie`

### BF

I used https://copy.sh/brainfuck/text.html to convert text into BF. Although there are a lot of `,` input statements, the BF code runs independent of it.

Try it online! outputs `gravy`

### Fission

For a Fission program to begin, an atom has to be spawned. We see this happening the the third line:

```
..."stuffing"                                Blah blah blah
             R                               Spawns an atom with direction right
              'c                             Gives the atom the mass of 'c''s ASCII value
                !                            Print the atom's mass
                 'o!'r!'n!'b!'r!'e!'a!'d!    Do the same for other characters
                                         *   Destroy atom, end program

```

Try it online! outputs `cornbread`

### Minkolang v0.15

```
#                                Doesn't really do anything
 \                               Reflect, moves downwards
  >                              Changes direction to right
    ... !|                       Does stuff in stack, '!' ignores the '|'
          $l9D3 ... ++O          Uses ASCII character codes to print "applecider"
                       .         Ends program

```

Try it online! outputs `applecider`

### Seriously

```
é                          - clear stack
 'g'n+'i+'s+'s+'e+'r+'d+   - load chars onto stack
                        .  - print stack
                         ó - exit

```

Try it online! outputs `dressing`

### Axo

(Commands are shown the order they are encountered)

```
#>                                          blah blah
  !                                         rotate direction 90 degrees clockwise

  >                                         go right
   'p'()                                    push char and output
        'u'() ... 'e'()                     repeat for other characters
                       \                    end program

```

Try it online! outputs `pumpkinpie`

# Answer
> 6 votes
# Pushy, Python and Brainfuck

This is my first polyglot, so don't go too hard on me... For those whining about byte count, it's 77 bytes, but that's only relevant for the tiebreaker.

```
"`turkey`"
print('gravy')
#++++++++++[>++++++++++<-]>-.++++++++++++.+++.----.

```

Pushy prints **'turkey'** with a leading newline (as well as a message to `STDERR`):

```
"        % Print current stack: just a newline as stack is empty
`turkey` % Push to stack
"        % Print the stack: 'turkey'
p        % Primality check on 'y' (121): pushes 0
r        % Integer root of 0: throws error and exits

```

Python prints **'gravy'**, as the first and last lines are treated as comments.

Brainfuck ignores all other characters and except for those on the final line, which create and print the word **'corn'**.

# Answer
> 4 votes
## Pip, BF, oOo CODE, \>\<\>, Befunge-93 (Quirkster implementation), Ouroboros, ///: 7 languages, 175 bytes

```
/'//bisCuItS/`f(>-[--[<]>+>-]<.++++++++++++.+++.----.O@,,,,,,"tuRkey"
"saLaD"1/ooooo;1(
>"YVaRg"^(OoooOoOOoooOoooOOoooOOoOooOooOooOOoOooOooOooOOoOOoOoOOoOOoOOoOOo`OO"sTUfFINg"

```

### Pip

Try it online

A bunch of expressions that get silently discarded (most of which generate warnings, if warnings are enabled), with the expression `"sTufFINg"` at the end which gets printed.

```
/ '/ / b      Invert the string "/" and divide it by nil
i s           Two different variables
Cu            Chr(nil)
It            If 10:
S / `...` OO   Invert a Pattern literal and swap it with undefined variable OO
"sTufFINg"    Autoprint this last expression

```

### BF

Try it online

Everything except `>-[--[<]>+>-]<.++++++++++++.+++.----.,,,,` is comments. This code generates `99` (the character code for `c`) via the shortest method listed on esolangs.org, then modifies it for `o`, `r`, and `n`. The `,,,,` tries to input four characters, but that doesn't affect anything.

### oOo CODE

Everything except letters is ignored. Grouping the letters into threes, the codes reads like this:

```
bis CuI tSf Otu Rke ysa LaD ooo ooY VaR gOo ... OsT UfF INg

```

and translates to this BF code (try it using Martin's Retina translator):

```
>+[-->+><+[<]>-]>.---.---..+++++++.

```

which outputs `rolls`. (And, interestingly enough, is shorter than the above BF for outputting `corn`, even with a `><` no-op added to make the capitalization line up correctly.)

### \>\<\>

Run \>\<\> code here

The important part of the code:

```
/
        /ooooo;
>"YVaRg"^

```

The IP gets reflected upward, wraps around, and gets sent rightward. `"YVaRg"` pushes the character codes of `gRaVY`. `ooooo` outputs five letters and `;` terminates the program.

### Befunge-93

The code depends on undefined behavior and probably only works in this implementation.

The important part of the code:

```
/'                        @,,,,,,"tuRkey"

```

`/` is division. The stack is empty, so the JavaScript implementation I'm using divides `0` by `0` and pushes `NaN`.

`'` is an unrecognized character. The implementation I'm using, conveniently, treats unrecognized characters as Reflect commands. (For a less implementation-dependent version, one possible replacement would be `1_`.) So the IP goes left again, divides `NaN` by `0` (getting `NaN`), and wraps to the other end of the line.

Now `"yekRut"` (moving RTL) pushes the character codes of `tuRkey` and `,,,,,,` outputs them. Finally, `@` terminates the program.

### Ouroboros

Try it here

Each line of the code is a "snake" that executes independently.

**Snake 1**

Since there are no output instructions, the only important part of the code is `f(`: `f` pushes `15` and `(` swallows that many characters from the end of the snake. The code is now considered to end after `.O`. Execution continues until the end of the snake and loops back to the beginning. Each time through, the snake gets shorter, until eventually the `(` is swallowed. Since the IP just got eaten, the snake halts execution.

**Snake 2**

`"saLaD"` pushes its character codes last-to-first; `1/` divides the charcode of `r` by `1`, leaving it unchanged, and `ooooo` outputs five characters. `;` drops an item (no-op because the stack is already empty). `1(` swallows the instruction pointer and halts.

**Snake 3**

`"YVaRg"` pushes some charcodes; then `(` swallows a number of characters equal to the top of the stack, which happens to be `89`, the character code of `Y`. Eating 89 characters is enough to swallow the IP and halt execution.

### ///

Try it online using my Pip implementation of ///

`/'//` deletes all single quotes from the rest of the program (which does nothing because there aren't any). Next, `bisCuItS` outputs as-is. Finally, the rest of the code is an incomplete substitution--there's only two of the three requisite slashes--so it does nothing.

# Answer
> 3 votes
# Cubix, Pushy, Brainfuck, V, Python 2 - 5 languages, ~~89~~ 85 bytes

My second ever polyglot - not very golfed, but it works:

```
"`turkey`";print'salad'#;"nroc"w!@o;"-[--";;;;{{->+<]>---.---.---..+++++++.␛ddgigravy

```

<sub>(note that  represents the literal escape byte, `x1B`)</sub>

* Cubix prints `corn`
* Pushy prints `turkey`
* Brainfuck prints `ROLLS`
* V prints `gravy`
* Python prints `salad`

---

## Cubix

**Test the program online!**

Cubix is a language by the challenge author, ETHproductions. The Cubix Interpreter reads the code like this:

```
        " ` t u
        r k e y
        ` " ; p
        r i n t
' s a l a d ' # ; " n r o c " w
! @ o ; " - [ - - " ; ; ; ; { {
- > + < ] > - - - . - - - . - -
- . . + + + + + + + . d d g i ␛
        g r a v
        y . . .
        . . . .
        . . . .

```

The code is executed like so:

* `'salad` \- does some irrelevant XOR operations on stack, results in `115, 0, 0`
* `'#;` \- push the charcode of `#`, then pop it again (no-op)
* `"nroc"` \- push the charcodes for "corn"
* `w` \- moves the IP to loop on the next line below:
    + `!@o;` \- print and pop last item (terminate if item is 0)
    + `"-[--";;;;` \- push these chars and delete them (no-op)
    + `{{` \- no-op

---

## Pushy

**Test the program online!**

Pushy is my own language, and it runs the code like this:

```
"          \ Print stack. Empty, so prints newline.
`turkey`   \ Push this string
"          \ Print this string
;          \ "End loop": Ignored as there is no loop in progress.
pr         \ Irrelevant stack operations
i          \ "interrupt": exit program.

```

---

## Brainfuck

**Test the program online!**

Brainfuck ignores all characters that are not in its list of instructions, resulting in:

```
-[--->+<]>---.---.---..+++++++.

```

Which prints `ROLLS`. Note that this requires an interpreter with wrapping cells, such as the one provided.

---

## V (Vim language)

**Test the program online!**

V was created by DJMcMayhem, one of our top code-golfers.

V is a program-based version of the text editor Vim. Most characters before the `ESC` get written into the "file", but `␛ddgigravy` deletes all of that and inserts "gravy" instead. The content of the file at the end of the program is printed.

---

## Python 2

**Test the program online!**

Python is one of my favorite practical languages. Because `#` is a comment in Python, most of the program is ignored. The code is read like this:

```
"`turkey`";            # Unused string literal
print'salad'           # Print statement
#...                   # Comment (everything else is ignored)

```

---

# Answer
> 2 votes
## Python/QBasic/Pip, 3 languages, 41 bytes

More languages possibly TBA.

```
1#print"corn":end
print("turkey");"salad"

```

**Python**

`1` is just an expression that gets discarded. `#` starts a comment. `print("turkey")` does what it says, and `"salad"` is another expression that gets discarded.

**QBasic**

`1#` is a (double-precision) line number. `print"corn"` does what it says. `end` terminates the program. The second line is syntactically valid but never executed.

**Pip**

Most everything is expressions that get discarded. `"corn":e` tries to assign to a literal string, which fails silently (unless warnings are enabled). `"salad"` is the last expression in the program and therefore is printed.

# Answer
> 1 votes
# PHP, JavaScript and BrainF\*ck, 178 Bytes

*First time I've ever tried a Polyglot - not going to lie, I'm in over my head here...*

Golfed:

```
<!DOCTYPE html><?php echo "turkey";?>

```

*(I didn't dare to write a Thanksgiving food in the HTML code and count that as another language...)*

**Explanation:**

The code needs to be saved into a .php file for the PHP and JavaScript parts.

**PHP:**

When ran on a PHP server, the PHP part of the code is read:

```
<?php echo "turkey";?>

```

This outputs:

**JavaScript:**

You can call the JavaScript `A()` function from the browser console:

```
function A(){alert("stuffing");}

```

This outputs:

**Brainf\*cK**

The Brainf\*ck part is nicely hidden in the comments in the JavaScript section, so it is ignored by the PHP and JavaScript parts:

```
--[----->+<]>-++.+++++++++++.-----------------.-----------.+++.

```

When the whole file pasted into an IDE, this outputs:

I couldn't have done the Brainf\*ck part without this text-to-BF website. I originally got it to generate code for "corn" and then in an attempt to learn something about this crazy language, I converted it to "gravy"...or rather "graVY"...

# Answer
> 1 votes
# Python, Clojure, Javascript, Ruby: 4 languages, 113 bytes

```
1;''''/*
#_(
puts("turkey")
__END__
);'''
1;1//2;'''
1;*/alert("gravy")/*
(print "salad");'''
#_
print "corn";#*/

```

Thanks to @Sp3000 for most of the code. Surprisingly, I didn't even have to do anything to his original, I just had to prepend the Ruby code.

# Answer
> 1 votes
## ///, SQL and JavaScript

```
/*//turkey/\*/select('corn')
--a;function select(){alert('salad')}

```

Same construction as with that other holiday-oriented polyglot:

**///**

```
/*//turkey/../..   Simply prints 'turkey', does no replaces, stops execution because the second /// block is incomplete

```

**SQL**

```
/*//turkey/\*/    //turkey/\ is seen as a block comment
                  That last \ was added to set apart the following */, completing the block
select('corn')    SQL Select statement, yielding 'corn'
--a;...           Seen by SQL as a comment, ignored

```

**Javascript**

```
/*//turkey/\*/    //turkey/\ is seen as a block comment
select('corn')    Function call to the function 'select', defined below
--a;              Decrement a, effectively a NOP
function select(){alert('salad')}
                  Defines the function select(), giving us 'salad'

```

# Answer
> 0 votes
# Clojure / Common Lisp / PicoLisp, 39 bytes

```
(print(if '()'turkey(if""'rolls'corn)))

```

Lisp family here. `'()` evaluates to true in Clojure so it proceeds to outputing a symbol `turkey`. PicoLisp and Common Lisp goes into false branch; `""` is true in Common Lisp and thus it prints symbol `rolls`, empty string is false in PicoLisp and so it goes to printing `corn` symbol.

Check it online:

https://ideone.com/OD65LB \- Clojure

https://ideone.com/M1H5gf – Common Lisp

https://ideone.com/B4x3ns – PicoLisp

# Answer
> 0 votes
## CJam, Underload, \>\<\>, 39 bytes

```
'v;"(Turkey)S";"Gravy""
 >'nroC'oooo;";

```

### What CJam sees

* `'v;`: A character literal that is immediately discarded
* `"(Turkey)S";`: A string literal that is immediately discarded
* `"Gravy"`: Pushes the string `Gravy` to the stack
* `"\n'nroC'oooo;";`: A string literal that is immediately discarded.

At the end of execution, the stack is output, which means that "Gravy" is printed.

### What Underload sees

* `'v;"`: Some invalid commands that are ignored
* `(Turkey)S`: Pushes the string "Turkey" and outputs it
* `";"Gr`: Some invalid commands that are ignored
* `a`: This causes a segfault on the TIO interpreter since the stack is empty. Execution is terminated.

### What \>\<\> sees

* `'v;"(Turkey)S";"Gravy""` pushes a bunch of characters to the stack (which are ignored). The IP then wraps back around.
* `v` sends the IP downwards.
* `>'nroC'oooo` pushes the characters in the string "Corn" and outputs them.
* `;` terminates execution. All other characters are ignored.

---
Tags: code-challenge, kolmogorov-complexity, polyglot
---


title: Simulate Rocket League Quick Chat

text:
# Question
Title: Simulate Rocket League Quick Chat
In Rocket League, there are controls assigned to quick chat. For PC, they are `1`, `2`, `3`, and `4`. To use a quick chat, you must press two controls. For example, the first option would be `1`, `1`.

You will be simulating the Rocket League client. You will be given a non-empty list composed only of four characters of your choosing. The length of the list will always be even and `<= 8`. I will be using `1, 2, 3, 4` for the examples. If you modify the input domain, you must specify how your input maps to `1, 2, 3, 4`.

The first character in each couplet specifies the section, the second the item in the section. Below are all sections, with their default chat:

```
1
 1 I got it!
 2 Need boost!
 3 Take the shot!
 4 Defending...

2
 1 Nice shot!
 2 Great pass!
 3 Thanks!
 4 What a save!

3
 1 OMG!
 2 Noooo!
 3 Wow!
 4 Close one!

4
 1 $#@%!
 2 No problem.
 3 Whoops...
 4 Sorry!

```

The above are case sensitive. So, `1 1` would be `I got it!`, and `3 3` would be `Wow!`.

In addition, after three quick chats come through rapidly, the game shots you down. You get a message back: `Chat disabled for 2 seconds.`. If you continue trying, you get one more chance, and then `Chat disabled for 4 seconds.`. Our challenge will not deal with time, or any further chats.

However, after three chats (6 input characters), you must output `Chat disabled for 2 seconds.`. After four chats (8 input characters), you must output `Chat disabled for 4 seconds.`. Since 8 is the maximum input length, that would be your final output, if they are 8 input characters.

# Input

First, chose your four characters, and map them to `1, 2, 3, 4`.

Your input will be non-empty, contain an even number of items, and only contain up to eight items.

# Output

You will output the matching quick chats in order, plus any `chat disabled` warnings (in the correct location). Output is case sensitive. It must be delimited - suggested delimiters are `\n` (pretty delimiter) or `,`, and you cannot use any delimiters in any of the possible outputs.

# Test Cases

In these, input is in the form of a JSON list and can be `1, 2, 3, 4`, and the output delimiter is `,`.

```
[1, 1, 1, 1] => I got it!,I got it!
[2, 4, 4, 4] => What a save!,Sorry!
[3, 3] => Wow!
[1, 4, 2, 3, 4, 1, 4, 4] => Defending...,Thanks!,$#@%!,Chat disabled for 2 seconds.,Sorry!,Chat disabled for 4 seconds.

```

Invalid (out of scope) inputs:

```
[] //empty
[1, 3, 1] //odd length
[5, 4] //character out of input domain
[1, 2, 3, 4, 1, 2, 3, 4, 1] //length > 8

```

To ensure the point is made: you are not taking these in real time, like in the game. You are just receiving a (short) list of numbers.

# Answer
# Jelly, ~~153~~ 150 bytes

```
⁶;j@“Kẋ3ŒK!D“¿ṁxṁị»Wḣ
J_2ḤÇ€
s2ḅ4ị“w eɲEƓṫ:⁾ṆƙḅƙḣḊṗṠ,`ė)®=Œf°Ẇŀ#ḍḤḌCṭ8v⁻$ʠṄṾŻYtṫʠßR>ĊḷḊc8Þ@Zq8-@⁻⁺ ḃḊĿ`ÆYƒðḤ|3ƓULẇẇŻịỵ1²ṄE'Cṣ\{ṣ{ḃ⁵ḳpẸz.4<»Ỵ¤µżÇ;/ȦÐfY

```

Input is a list of integers, where `0`, `1`, `2`, and `3` represent `1`, `2`, `3`, and `4` respectively.
Output is a newline separated print out.

**Try it online!**

### How?

There is a compressed string taking up 105 bytes:

```
“w eɲEƓṫ:⁾ṆƙḅƙḣḊṗṠ,`ė)®=Œf°Ẇŀ#ḍḤḌCṭ8v⁻$ʠṄṾŻYtṫʠßR>ĊḷḊc8Þ@Zq8-@⁻⁺ ḃḊĿ`ÆYƒðḤ|3ƓULẇẇŻịỵ1²ṄE'Cṣ\{ṣ{ḃ⁵ḳpẸz.4<»
= "Need boost!\nTake the shot!\nDefending...\nNice shot!\nGreat pass!\nThanks!\nWhat a save!\nOMG!\nNoooo!\nWow!\nClose one!\n$#@%!\nNo problem.\nWhoops...\nSorry!\nI got it!"

```

(Somewhat shockingly 1 byte was saved by including all the `!` rather than inserting them via code.)

The program then works as follows

```
⁶;j@“Kẋ3ŒK!D“¿ṁxṁị»Wḣ - Link 1, get a disabled string: number, seconds
⁶                     - space character
 ;                    - concatenate with seconds (e.g. " 4")
    “Kẋ3ŒK!D“¿ṁxṁị»   - compressed list of strings ["Chat disabled for"," seconds"]
  j@                  - join (swap @arguments)  (e.g. "Chat disabled for 4 seconds"
                   W  - wrap in a list
                    ḣ - head to seconds (for -2 and 0 gives an empty list, for 2 and 4 give the string wrapped in a list)

J_2ḤÇ€ - Link 2, get disabled strings: list of chat strings
J      - range of length (e.g. for 4 chat strings [1,2,3,4])
 _2    - subtract 2      (...[-1,0,1,2])
   Ḥ   - double          (...[-2,0,2,4])
    Ç€ - call last link (1) as a monad for €ach

s2ḅ4ị“...»Ỵ¤µżÇ;/ȦÐfY - Main link: list of characters
s2                    - split into twos
  ḅ4                  - convert from base four (vectorises)
           ¤          - nilad followed by link(s) as a nilad:
     “...»            -   compressed string described in code-block above
          Ỵ           -   split on newlines
    ị                 - index into (use the base four representation to get the chat strings)
            µ         - monadic chain separation (call that x)
              Ç       - call last link (2) as a monad
             ż        - zip
               ;/     - flatten list by one level
                  Ðf  - filter keep if:
                 Ȧ    -   any and all (false for empty results, i.e. the empty results from link 2)
                    Y - join with newlines
                      - implicit print

```
> 1 votes

# Answer
# JavaScript, 264 bytes

```
f=([x,y,...z],n=.5)=>"I got it!,Need boost!,Take the shot!,Defending...,Nice shot!,Great pass!,Thanks!,What a save!,OMG!,Noooo!,Wow!,Close one!,$#@%!,No problem.,Whoops...,Sorry!".split`,`[x*4+y-5]+(n>1?`,Chat disabled for ${n} seconds.`:'')+(z[0]?','+f(z,n*2):'')

```
> 1 votes

---
Tags: code-golf
---


title: Convert phrases to reverse style

text:
# Question
Title: Convert phrases to reverse style
### The Challenge

Convert a phrase of two words to reverse style: `candy bar -> bar le candy`.

### Specifications

* There will be one word (only `a-zA-Z0-9` \+ `-`), a space (), and then another word.
* For equal length, score is used to determine winner.

### Test cases:

```
candy bar -> bar le candy
code golf -> golf le code
programming puzzles -> puzzles le programming

```

# Answer
# CJam, 9 bytes

```
rr" le "@

```

Try it online!

Pushes first 2 tokens and then the " le " literal to stack, and then rotates the stack, moving the first word to the end of the stack. Output of the resulting stack is implied.
> 8 votes

# Answer
# Reng v.3.3, 55 bytes

Try it here!

```
1#zaií1ø
):Weq!vz1+#z
br[zÀz/]; !o
le"Wro/ !ob"
    ~;/

```

I can probably golf it by taking input until a space is found, as this approach takes all input at once.

## Explanation

### Input & init

```
1#zaií1ø

```

`1#z` stores `1` to `z`. `a` is a one-sided mirror from the left side, meaning you can pass through it from left-to-right, but not otherwise. `i` takes a char of input, and `í` mirrors iff there is input on the input stack. Otherwise, it proceeds.  goes to the next line.

### Print first word

```
):Weq!vz1+#z

```

`)` rotates the stack left one, `:` duplicates it, `We` checks for the equality with a space, and `!v` goes down iff it is a space and goes to the next phase. `z1+#z` increments `z` otherwise.

(more to come)

---

Here's a GIF:
> 11 votes

# Answer
# Vim 9 keystrokes

```
dwA le <esc>p

```

I'm so close to beating pyth and Cjam! Unfortunately, I can't figure out how to take any more off, so I'll have to be satisfied with tying. =)

Explanation:

```
dw             'Delete a word
  A le <esc>   'Enter " le " at the end of the current line
            p  'Paste the previously deleted text

```
> 9 votes

# Answer
# Pyth - 9 bytes

```
j" le "_c

```

Test Suite.
> 7 votes

# Answer
# MATL, 12 bytes

```
Yb'le'h7L)Zc

```

**Try it online!**

```
Yb       % Take input implicitly. Split by spaces. Gives a cell array
'le'     % Push this string
h        % Concatenate horizontally into cell array
7L       % Push [2 3 1]
)        % Apply as index, to change order
Zc       % Join with spaces. Gives a string. Display implicitly

```
> 4 votes

# Answer
## Python 3, 41 bytes

```
print(' le '.join(input().split()[::-1]))

```
> 4 votes

# Answer
# R, 30 bytes

```
cat(rev(scan(,"")),sep=" le ")

```

This is a full program that accepts reads a string from STDIN and prints to STDOUT. The `scan` function implicitly separates space-delimited input into elements of an array. We then just `rev`erse the array and print it, using `le` as a separator between elements in the output.
> 3 votes

# Answer
# GS2, 9 bytes

```
, ♦ le ♣2

```

Try it online!
> 3 votes

# Answer
# IPOS, 13 bytes

```
rS!r%S" le "R

```

Could \< 10 bytes if I had implemented all the builtins that I have planned...

### Explanation

```
r         # Reverse the input
S!r%      # Reverse every word -> Word order is now swapped
S" le "R  # insert a " le " between the two words by replacing the space

```

### Non-competing 9-byte version

This only works with the version I pushed just now (implemented `C`).

```
SC"le"@Sj

```

This works by splitting the input on spaces to obtain the two words (`SC`), pushing the literal `le`, rotating the stack (`@`) so the words are swapped and the `le` is between them and finally joining the stack on spaces (`SJ`).

Again, could be shorter since I also plan to add commands for joining and splitting on spaces which would make this 7 bytes. But since those are probably gonna be non-ASCII characters and I haven't fully figured out the codepage I am gonna use, those have to wait a bit.
> 2 votes

# Answer
# JavaScript (ES6), ~~34~~ 32 bytes

```
s=>(a=s.split` `)[1]+" le "+a[0]

```

*Saved 2 bytes thanks to @jrich!*
> 2 votes

# Answer
# Jelly, 9 bytes

```
ṣ⁶Ṛj“ le

```

Try it online!
> 2 votes

# Answer
# \>\<\>, 35 bytes

```
i:" "=?v
ov?(0:i<
"\~~r" el
o>l?!;

```

The first line reads a character of the first word and put it on the stack, then goes to the second line if it encounters " " or otherwise loops.
The second line reads a character of the second word and prints it right away, then goes to the third line when if encounters EOF or otherwise loops.
The third line removes the space and the EOF from the stack, reverts it and pushes " le " backward, then goes to the fourth line.
The fourth line stops execution if the stack is empty, otherwise it prints a character of the stack (poping it) and loops.
> 2 votes

# Answer
## Pyke, 10 bytes

```
dcX"le"RdJ

```

Try it here!

Or 9 bytes (noncompeting, add insert)

```
Dd@" le":

```

Try it here!
> 2 votes

# Answer
# Python, 37 bytes

```
lambda s:" le ".join(s.split()[::-1])

```
> 1 votes

# Answer
## Python 2, 34 bytes

```
a,b=input().split();print b,"le",a

```

Expects input in quotes.

```
>> "code golf"
golf le code

```
> 1 votes

# Answer
# Jolf, 10 bytes

Try it here!

```
R_pti" le
  pti      input split by spaces
 _         reversed
R    " le  joined by that string

```
> 1 votes

# Answer
# BATCH file, 14 bytes

```
@ECHO %2 le %1

```

Save to a file and invoke as `notFrench word1 word2`.

```
C:\Users\Conor O'Brien\Documents\Programming\PPCG>notFrench code golf
golf le code

C:\Users\Conor O'Brien\Documents\Programming\PPCG>

```
> 1 votes

# Answer
# Go, 81 bytes

```
import."strings"
func f(s string)string{h:=Split(s," ")
return h[1]+" le "+h[0]}

```
> 1 votes

# Answer
# Perl, 18 bytes

```
/ /;$_="$' le $`"

```

This program is **17 bytes** long and requires the `-p` switch (**+1 byte**).
> 1 votes

# Answer
## Lua, 46 Bytes

```
a=(...):gsub("(%w+) (%w+)","%2 le %1")print(a)

```

I save the result of `gsub` to a variable because it returns 2 values, and would therefore print a `1` which is the number of changes made to the string. The other work around is about disallowing `gsub`'s return to unpack. Also, it is actually longer by 1 byte:

```
print((...):gsub("(%w+) (%w+)","%2 le %1")..'')

```
> 1 votes

# Answer
## Retina, 14 bytes

Byte count assumes ISO 8859-1 encoding.

```
M!r`\S+
¶
 le

```

Try it online! (Slightly modified to process all test cases at once.)

The first stage reverses the two words and separates them by a linefeed (this is done by matching them with `r`ight-to-left mode and printing all matches).

The second stage replaces the linefeed () with  `le` .
> 1 votes

# Answer
# Mathematica, 30 bytes

```
#2<>" le "<>#&@@StringSplit@#&

```

Not very complicated...
> 1 votes

# Answer
## Seriously, 13 bytes

```
"le"' ,so/' j

```

Try it online

Explanation:

```
"le"' ,so/' j
    ' ,s       split input on space
"le"    o/     stick "le" between words
          ' j  join on space

```
> 1 votes

# Answer
# Gawk, ~~17~~ 16 bytes

*1 byte off thanks to muru*

```
{$0=$2" le "$1}1

```

### Old

```
{print$2" le "$1}

```
> 1 votes

# Answer
# Java 8, ~~41~~ 39 bytes

A simple lambda, for a simple challenge

```
s->s.replaceAll("(.+) (.+)","$2 le $1")

```

---

**Update**

* **-3** \[17-02-23\] Thanks to *@Kevin*
> 1 votes

# Answer
# Japt, ~~9~~ 8 bytes

Note the trailing space.

```
¸w q` ¤

```
* Saved a byte thanks to a reminder from obarakon.

Try it online

---

## Explanation

```
        :Implicit input of string U
¸       :Split to array on space
w       :Reverse
q.      :Join to string...
` ¤     : with the compressed string " le "

```
> 1 votes

# Answer
# **C# - 43 bytes**

```
string.Join(" le ",x.Split(' ').Reverse());

```
> 0 votes

# Answer
# Ruby, 24 bytes

```
->s{s=~/ /;"#$' le #$`"}

```

Try it online!
> 0 votes

# Answer
# PHP, 47 Bytes

```
<?=preg_filter("#(.+) (.+)#","$2 le $1",$argn);

```

Try it online!
> 0 votes

---
Tags: code-golf, string, natural-language, conversion
---


title: Give me some questions to answer!

text:
# Question
Title: Give me some questions to answer!
## Introduction

Sometimes I get bored and there are no new questions on PPCG, so I want you to dig a random question from PPCG's past.

## Challenge

Given a user's PPCG ID as input (e.g. my ID is *30525*), output the URL of a randomly chosen PPCG question. If the question does not meet the following criteria, you must choose another question until it does meet the criteria:

* The question asker must not be the user whose ID was inputted to the question
* The question must not have already been answered by the user whose ID was inputted to the question
* The question must not be unanswered: it's probably too hard
* The question must not have over 10 answers: it's probably too easy
* The question must be tagged

## Rules

URL shorteners are disallowed.

You may use the Stack Exchange API and the Stack Exchange Data Explorer.

You will only ever be given a real PPCG user's ID.

In the unlikely event that there are no suitable questions, you do not have to output anything (undefined behaviour is fine).

## Side Challenge

Although you won't be awarded extra points, it would be appreciated if someone designed a ***usable*** bookmarklet which, when run, opened the browser window to a random PPCG question that follows the above criteria. The user ID should be hardcoded into program (for the bookmarklet *only*).

## Challenge

The shortest code in bytes wins.

# Answer
# PowerShell, 261 Bytes

```
param($i)$q=irm (($u="api.stackexchange.com/questions/")+($s="?tagged=code-golf&site=codegolf"))
do{$t=$q.items|?{$c=$_|% an*;$_.owner.user_id-ne$i-and$c-gt0-and$c-lt10}|random}while((irm($u+$t.question_id+'/answers'+$s)).items.owner.user_id-contains$i)
$t.link

```

Explanation:

```
param($i)
$q=irm (($u="api.stackexchange.com/questions/")+($s="?tagged=code-golf&site=codegolf")) #run this query
do{ #until we find a valid question, get a random one that fits the basic specs
    $t=$q.items|?{$c=$_|% an*;$_.owner.user_id-ne$i-and$c-gt0-and$c-lt10}|random
}while( #Get all of the answers, and their owners into an array, check it doens't contain the provided id
(irm($u+$t.question_id+'/answers'+$s)).items.owner.user_id-contains$i
)
$t.link #output the question link

```

add 4 bytes for a version which opens it in webbrowser

```
param($i)$q=irm (($u="api.stackexchange.com/questions/")+($s="?tagged=code-golf&site=codegolf"))
do{$t=$q.items|?{$c=$_|% an*;$_.owner.user_id-ne$i-and$c-gt0-and$c-lt10}|random}while((irm($u+$t.question_id+'/answers'+$s)).items.owner.user_id-contains$i)
saps $t.link

```
> 4 votes

# Answer
# JavaScript (ES6), ~~333~~ ~~329~~ ~~327~~ ~~323~~ 283 bytes

Needs to be run from within the `api.stackexchange.com` domain (relevant meta). Returns a `Promise` containing the URL (relevant meta).

```
f=async i=>await(u="/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link

```

---

## Try it

```
f=async i=>await(u="//api.stackexchange.com/questions/",s="?tagged=code-golf&site=codegolf",q=await(await(await fetch(u+s)).json()).items.filter(x=>x.owner.user_id!=i&x.answer_count<11).sort(_=>.5-Math.random())[0],await(await fetch(u+q.question_id+s)).json()).items.some(x=>x.owner.user_id==i)?f(i):q.link
k.previousSibling.value=58974 // me
k.onclick=_=>f(+k.previousSibling.value).then(p=>k.nextSibling.innerText=p)
```

```
<input type=number><button id=k>Fetch</button><pre>
```

---

## Bookmarklet

And here it is as a customisable bookmarklet, which will load a random question you've yet to answer. To use it, simply add a new bookmark to your browser's toolbar and drop the full code into the URL field.

Unlike the above solution, this works with all questions on a site therefore it may be slow to run (depending on the site and tags) and could also be expensive in the number of queries it needs to make to the API, as the API can only return 100 questions at a time.

To customise, change the following variables

* `k`: Your API key - you can register for one here.
* `s`: The Stack Exchange site you want to grab a question for.
* `i`: Your user ID on that site.
* `t`: The tags you want to filter by. There are 4 options available for this one:
    1. `""`: An empty string; if you don't want to filter by any tags,
    2. `"code-golf;string"`: A semi-colon separated list of tags you want to filter by,
    3. `prompt("Tags:")`: You will be prompted to enter the tags you want to filter by, or,
    4. `prompt("Tags:","code-golf;string")`: You will be prompted to enter the tags you want to filter by, with a default list provided.

```
javascript:(f=(

/* See https://codegolf.stackexchange.com/a/122400/58974 for documenation */
k="",
s="codegolf",
i=58974,
t="code-golf",

p=1,q=[],r=1)=>fetch((u="//api.stackexchange.com/questions/")+(d=`?key=${k}&tagged=${t}&site=`+s)+`&page=${p}&pagesize=100`).then(r=>r.json()).then(j=>r&&(q=[...q,...j.items.filter(x=>x.owner.user_id!=i&(a=x.answer_count)&a<11)])^j.has_more?f(i,k,s,t,p+1,q,1):q.sort(_=>.5-Math.random())[0]).then(y=>fetch(u+y.question_id+"/answers"+d).then(r=>r.json()).then(j=>j.items.some(x=>x.owner.user_id==i)?f(i,k,s,t,q,0):window.location=y.link)))()

```
> 5 votes

---
Tags: code-golf, random, internet, stack-exchange-api
---


title: Check if a given string is valid romaji

text:
# Question
Title: Check if a given string is valid romaji
Your program is given a string consisting entirely of lowercase letters at STDIN (or closest alternative). The program must then output a truthy or falsey value, depending on whether the input is valid romaji.

## Rules:

* It must be possible to divide the entire string into a sequence of kana without any leftover characters.
* Each kana can be a single vowel (`aeiou`)
* Each kana can also be a consonant p, g, z, b, d, k, s, t, n, h, m, or r followed by a vowel. For example, ka and te are valid kana, but qa is not.
* The exceptions to the above rule are that zi, di, du, si, ti, and tu are not valid kana.
* The following are also valid kana: n, wa, wo, ya, yu, yo, ji, vu, fu, chi, shi, tsu.
* If a particular consonant is valid before an i (i.e ki, pi), the i can be replaced by a ya, yu, or yo and still be valid (i.e kya, kyu, kyo)
* Exceptions to the above rule are chi and shi, for which the y has to be dropped too (i.e cha, chu, cho, sha, shu, sho)
* It is also valid to double consonants if they are the first character of a kana (kka is valid but chhi is not)
* Shortest answer wins. All regular loopholes are disallowed.

## List of all valid kana:

```
Can have double consonant:

ba, bu, be, bo, bi
ga, gu, ge, go, gi
ha, hu, he, ho, hi
ka, ku, ke, ko, ki
ma, mu, me, mo, mi
na, nu, ne, no, ni
pa, pu, pe, po, pi
ra, ru, re, ro, ri
sa, su, se, so,
za, zu, ze, zo,
da,     de, do,
ta,     te, to,
wa,         wo,
ya, yu,     yo,
    fu,
    vu
                ji

Can not have double consonant:

a, i, u, e, o,
    tsu,
chi, cha, cho, chu,
shi, sha, sho, shu,
n

```

## Test cases

Pass:

```
kyoto
watashi
tsunami
bunpu
yappari

```

Fail:

```
yi
chhi
zhi
kyi

```

# Answer
> 2 votes
# Ruby, ~~96~~ 149 bytes

Regex solution to match all the valid kana. Interestingly, "ecchi" is not valid according to the current rules, but perhaps it's for the best.

```
->s{s.gsub(/(?![dt]u)(sh|ch|([gbknhmrp])\2?y?|([zdst])\3?)?[auo]|(\g<2>)?\4?[ie]|(\g<3>)\5?e|ww?[ao]|n|tsu|([fv])\6?u|jj?i|j?y?[aou]|yy[aou]/){}==""}

```

Try it online! feat. Cruel Angel's Thesis

# Answer
> 1 votes
## Python 2, 166 bytes

Long regex solution
Try it online

I think that f-strings from 3.\[something\] python can help to shorten it by replacing repeated `[auo` and `{1,2}`.
Unfortunatetly I can't check it by myself now :c

```
import re
lambda x:re.sub('[bghkmnpr]~([auoei]|y[auo])|[sz]~[auoe]|[dt]~[aeo]|w~[ao]|([fv]~|ts)u|(j~|[cs]h)(i|y[auo])|y~[auo]|[auoien]'.replace('~','{1,2}'),'',x)==''

```

---
Tags: code-golf, string, natural-language
---


title: Make me a bad fade animation... please

text:
# Question
Title: Make me a bad fade animation... please
Your task is to, as the title discreetly suggests, make a bad fade animation of one word turning into a second word for yours truly.

**What exactly *is* this "fade animation" you may ask?**

To make a spectacular(ly bad) fade animation, you take two strings which will contain only printable ASCII characters. You start by printing your starting string (the first of the two). Then, you **randomly pick** a character in the original word and change it to the corresponding character in the word you want to animate to. When the words are of unequal length, *you* must pad them with spaces.

You keep on doing this until all of the characters have been changed, but **you will not change the character at a certain index more than once**. Here is an example i/o:

```
Hey -> Peeps
Hey    # original string
Hey s  # replace char at index 4
Hey s  # replace char at index 1
Pey s  # replace char at index 0
Pee s  # replace char at index 2
Peeps  # replace char at index 3

```

You must write a function or full program that changes a letter and then prints the new string at increments of one second. The input format is loose, but the output format is strict.

**This is , so shortest code in bytes wins.**

Some test cases (Form: `init -> final`):

```
Stringy -> Blingy
Banana -> Republic
United -> States
Make America -> Tissue box
I like walls -> I have small hands
Hello, -> world!

```

**Reference implementation in Python 2:**

```
import random
import time
def F(c,f):
    print c                                      # before we do stuff
    if len(c)>len(f):f+=" "*(len(c)-len(f))      # add padding part 1
    if len(f)>len(c):c+=" "*(len(f)-len(c))      # add padding part 2
    c, f = list(c), list(f)
    ai = [i for i in range(len(c))]              # a list for keeping track
    while len(ai) > 0:                           #  of available indices
        time.sleep(1)                            # 1 second pause...
        i = ai.pop(random.randint(0,len(ai)-1))  # get a random index and remove
        c[i] = f[i]                              #   it from the list
        print ''.join(c)                         # print the new string

```

# Answer
# Pyth - ~~25~~ 24 bytes

Will refactor.

```
AC.tQdV.SU
G
=XGN@HN.d_1

```

Try it online here.
> 6 votes

# Answer
# MATL, 33 bytes

```
cn2/XKZ@!Oyhg*XR"GcK:@mK:Eq+)D1Y.

```

Try it at MATL Online. You may need to refresh the page and press "Run" again if it doesn't work.

Alternatively, this version (**35 bytes**) deletes the screen before each new string is displayed, which results in the output being "modified in place":
> 5 votes

# Answer
# Python 2, ~~171 169 168~~ 163 bytes

```
import time,random as r
def f(a,b):
 d=len(a)-len(b);a+=' '*-d;b+=' '*d;o=range(len(a));r.shuffle(o);print a
 for i in o:time.sleep(1);a=a[:i]+b[i]+a[i+1:];print a

```

Test cases are on **ideone**
> 2 votes

# Answer
## Perl, 131 + 4 (`-F -l`) = 135 bytes

```
@T=@F if!$i++}$T[$_]||=$",$F[$_]||=$"for 0..$#F,0..$#T;say@T;{$==rand@T;redo if$h{$=}++;$T[$=]=$F[$=];sleep 1;say@T;redo if++$v!=@T

```

Needs `-F` and `-l` flags to run, as well as `-M5.010` (or `-E`). Note that if your version of perl is a bit old, you'll need to add `-an` on your command line (which I'll add too bellow to show it, but it's not needed). For instance :

```
$ cat fade.pl
@T=@F if!$i++}$T[$_]||=$",$F[$_]||=$"for 0..$#F,0..$#T;say@T;{$==rand@T;redo if$h{$=}++;$T[$=]=$F[$=];sleep 1;say@T;redo if++$v!=@T
$ perl -F -anl -M5.010 fade.pl <<< "Hey
Peeps"
Hey
Pey
Pee
Pee s
Pee s
Peeps

```

I'm pretty sure this could be shorter, but I couldn't find out how... yet! Still, I don't think this is a bad answer, and hopefully someone will be inspired to make it shorter (or have a totally different idea!).
> 2 votes

# Answer
# C# 299 Bytes

```
void f(string a,string b){var m=Math.Max(a.Length,b.Length);var t=new Collections.Generic.HashSet<int>();while(t.Count<m)t.Add(new Random().Next()%m);var s=a.PadRight(m).ToCharArray();Console.WriteLine(s);foreach(var x in t){Threading.Thread.Sleep(1000);s[x]=b.PadRight(m)[x];Console.WriteLine(s);}}

```

**Ungolfed**

```
void f(string a, string b)
{
    var m = Math.Max(a.Length, b.Length);
    var t = new Collections.Generic.HashSet<int>();
    while(t.Count < m) t.Add(new Random().Next()%m);
    var s=a.PadRight(m).ToCharArray();

    Console.WriteLine(s);
    foreach (var x in t)
    {
        Threading.Thread.Sleep(1000);
        s[x] = b.PadRight(m)[x];
        Console.WriteLine(s);
    }
}

```
> 2 votes

# Answer
# Perl, ~~109~~ ~~108~~ 99 bytes

Includes +3 for `-n`

Give strings on STDIN ***without final newline***

```
echo -n "Make -> Tissue box" | perl -M5.010 fade.pl

```

`fade.pl`:

```
#!/usr/bin/perl -n
/ -> /;$_=$`^$`^$'^$';{$==rand(y/\x00//)+sleep say+($`&~$_|$'&$_)=~y/\x00/ /r;s%(.*?\K\x00){$=}%\xff%&&redo}

```

Works as shown, but replace `\xhh` by the literal characters to get the claimed score.

This way of using `\K` is new I think...
> 2 votes

# Answer
# Python 3, 214 bytes

```
import time,random
o,f=list(input()),list(input())
F=len(f);O=len(o);o+=[" "]*(F-O);f+=[" "]*(O-F);p=-1;l=[p]
while o!=f:
 while p in l:p=random.randrange(max(F,O))
 l+=[p];o[p]=f[p];print(''.join(o));time.sleep(1)

```

**Ideone it!**
> 1 votes

# Answer
**Java, ~~456~~ ~~454~~ ~~437~~ 428 bytes**

```
import java.util.*;public class c{public static void main(String[]s)throws Exception{char[]a=s[0].toCharArray(),b=s[1].toCharArray();int l,j=0;if(a.length<b.length){l=b.length;a=Arrays.copyOf(a,l);}else{l=a.length;b=Arrays.copyOf(b,l);}Vector i=new Vector();for(;j<l;i.add(j++));System.out.println(s[0]);while(l>0){Thread.sleep(1000);j=(int)i.remove(new Random().nextInt(l--));a[j]=b[j];System.out.println(String.valueOf(a));}}}

```

Ungolfed:

```
import java.util.*;

public class c
{

public static void main(String[] s) throws Exception
{
    char[] a = s[0].toCharArray(), b = s[1].toCharArray();
    int l, j = 0;
    if (a.length < b.length)
    {
        l = b.length;
        a = Arrays.copyOf(a, l);
    }
    else
    {
        l = a.length;
        b = Arrays.copyOf(b, l);
    }

    Vector i = new Vector();

    for (; j < l; i.add(j++));

    System.out.println(s[0]);

    while (l > 0)
    {
        Thread.sleep(1000);
        j = (int) i.remove(new Random().nextInt(l--));
        a[j] = b[j];
        System.out.println(String.valueOf(a));
    }
}
}

```

**Edit:** minus 2 byte by CAD97

**Edit:** minus 17 byte by Kevin Cruijssen (I slightly altered the suggestion by reusing `j` instead of creating a new variable `x` to hold the size)

**Edit:** minus 9 byte
> 0 votes

# Answer
# PHP, ~~123~~ 121 bytes

```
<?=$a=$argv[1];for($b=str_split(str_pad($argv[2],strlen($a)));$b;print"
$a"){$a[$i=array_rand($b)]=$b[$i];unset($b[$i]);}

```

save as file, execute with `php <filename> <string1> <string2>` (or `php-cgi`)

**breakdown**

```
<?=$a=$argv[1];                         // 0. print original
for(
    $b=str_split(                       // 2. split to array of single characers
        str_pad($argv[2],strlen($a))    // 1. pad 2nd argument to length of 1st argument
    );
    $b;                                 // 3. while $b has characters left
    print"\n$a"                         // 6. print altered string
){
    $a[$i=array_rand($b)]=$b[$i];       // 4. pick random index from $b, copy character to $a
    unset($b[$i]);                      // 5. remove character from $b
}

```
> 0 votes

# Answer
# CJam, 44 bytes

```
q~{_,@\Se]s}2*1$peemr{es{_es-zA3#<}g;~t_p}/;

```

Explanation:

```
q~                                            get input
  {_,@\Se]s}2*                                pad each string to the length of the other
              1$p                             print starting string
                 eemr{                   }/   for each randomly shuffled enum of target string
                      es{_es-zA3#<}g;         1 second waiting loop
                                     ~t_p     replace one character and print new string
                                           ;  clear stack

```

The delay only works using the Java interpreter, not in the online interpreter.

```
 java -jar cjam.jar badfade.cjam <<< '"banana" "republic"'

```

Try it online (delay set to 1 ms)
> 0 votes

# Answer
# JavaScript (ES6) + HTML, 210 bytes

```
s=>e=>{s=[...s],e=[...e],d=e[k="length"]-s[k],(d>0?s:e).push(..." ".repeat(d>0?d:-d)),a=[...e.keys()],u=_=>{O.value=s.join``,s[i=a.splice(Math.random()*a[k]|0,1)[0]]=e[i],i+1&&setTimeout(u,1e3)},u()}

```

```
<input id=O

```

Called using curry syntax: `f("from this")("to this")`.

## Cleaned up JS

```
s => e => {
    s = [...s],
    e = [...e],
    d = e[ k="length" ] - s[k],
    (d>0 ? s : e).push(..." ".repeat(d>0 ? d : -d)),
    a = [...e.keys()],
    u = _ => {
        O.value = s.join``,
        s[ i = a.splice(Math.random()*a[k]|0, 1)[0] ] = e[i],
        i+1 && setTimeout(u, 1e3)
    },
    u()
}

```

## Test Snippet

Requires closing brace on the `input` to work here.

```
f=
s=>e=>{s=[...s],e=[...e],d=e[k="length"]-s[k],(d>0?s:e).push(..." ".repeat(d>0?d:-d)),a=[...e.keys()],u=_=>{O.value=s.join``,s[i=a.splice(Math.random()*a[k]|0,1)[0]]=e[i],i+1&&setTimeout(u,1e3)},u()}
```

```
<style>*{font-family:Consolas;}</style>
Starting String: <input id="A" type="text"><br>
Ending String: <input id="B" type="text">
<button onclick="f(A.value)(B.value)">Run</button>
<br><br>

<input id=O>
```
> 0 votes

# Answer
# Ruby, 106 bytes

```
->a,b{puts a=a.ljust(l=[a.size,b.size].max);b=b.ljust l
[*0...l].shuffle.map{|i|sleep 1;a[i]=b[i];puts a}}

```

Try it online!

Oh, all right. No more rick rolling in the Try It Online link, if that's what's causing the downvotes. If not, please let me know what I'm doing wrong
> -1 votes

---
Tags: code-golf, string
---


title: Dump stack to array

text:
# Question
Title: Dump stack to array
I'm new to this code-golfing thing and I'm very interested in CJam.

Is there a way to get all the current stack as an array? I think I can do it with something like `[1$ 2$...n$]` but I would have to get the stack's length and use some kind of iterator (or use a fixed length stack... useless). But is there a way to achieve this with a single operator? The thing is I want to iterate over all the stack's elements.

Sorry if the question is obvious or seems stupid, but I'm new to this and I couldn't find anything...

# Answer
An unmatched `]` command will make the entire stack into an array.

```
1 2 3 4 ] -> [1 2 3 4]

```
> 4 votes

---
Tags: tips, cjam
---