# Question
Title: War is peace. Freedom is slavery. Ignorance is strength
As George Orwell wrote in *1984*:

> War is peace
> Freedom is slavery
> Ignorance is strength

Write a program or function that takes in one of the six main words from the Orwell quote and outputs its counterpart.

Specifically:

```
[input] -> [output]
war -> peace
peace -> war
freedom -> slavery
slavery -> freedom
ignorance -> strength
strength -> ignorance

```

No other input/output pairs are required.

You should assume the words are always fully lowercase, as above. Alternatively, you may assume the words are always fully uppercase: `WAR -> PEACE`, `PEACE -> WAR`, etc.

The shortest code in bytes wins.

# Answer
> 61 votes
# 05AB1E, 30 bytes

**05AB1E** uses CP-1252.

```
“ignorance¤í‡î—™šÔÃÒry“#DIk1^è

```

Try it online! or as a Test suite

**Explanation**

The straight forward approach

* Push the string `ignorance strength war peace freedom slavery`
* Split on spaces
* Get the index of the input in the list
* XOR the index with 1
* Get the element in the list at that index

# Answer
> 50 votes
## JavaScript (ES6), 80 bytes

```
s=>'freedom,,war,,strength,,slavery,peace,ignorance'.split`,`[s.charCodeAt(1)%9]

```

### How it works

We use a small lookup table based on the ASCII code of the 2nd character of each word, returning the index of its counterpart.

```
Word      | 2nd char. | ASCII code | MOD 9
----------+-----------+------------+------
war       | a         | 97         | 7
peace     | e         | 101        | 2
freedom   | r         | 114        | 6
slavery   | l         | 108        | 0
ignorance | g         | 103        | 4
strength  | t         | 116        | 8

```

As a side note, if mixed case was allowed, using `war PEACE FREEDOM slavery IGNORANCE strength` with modulo 6 would lead to a perfect hash.

### Test

```
let f =

s=>'freedom,,war,,strength,,slavery,peace,ignorance'.split`,`[s.charCodeAt(1)%9]

console.log('war', '->', f('war'))
console.log('peace', '->', f('peace'))
console.log('freedom', '->', f('freedom'))
console.log('slavery', '->', f('slavery'))
console.log('ignorance', '->', f('ignorance'))
console.log('strength', '->', f('strength'))
```

# Answer
> 32 votes
# Jelly, 24 bytes

```
“Ñ=ƘḊ¹ƥ¹Ƙ⁷ṅ8cøGị»Ḳµiɠ^1ị

```

Try it online!

### How it works

First, the token

```
“Ñ=ƘḊ¹ƥ¹Ƙ⁷ṅ8cøGị»

```

indexes into Jelly's dictionary to create the string

```
strength war peace freedom slavery ignorance

```

which  splits at spaces to yield the string array

```
["strength", "war", "peace", "freedom", "slavery", "ignorance"]

```

`µ` begins a new, monadic chain, with that string array as its argument, which is also the current return value.

`ɠ` reads one line of input from STDIN, and `i` finds its index of the previous return value, i.e., the generated string array.

Now, `^1` takes the bitwise XOR of that index and **1**. For even indices – remember that Jelly indexes are **1**-based and modular, so **strength** has index **1** and **ignorance** has index **6**/**0** – this increments the index; for odd indices, it decrements them.

Finally,  retrieves the string at that index from the chain's argument.

# Answer
> 18 votes
## Mathematica, 84 bytes

```
(x="war""peace")(y="freedom""slavery")(z="ignorance""strength")/#/.x->1/.y->1/.z->1&

```

### Explanation

More "arithmetic" with strings! As in the linked answer, this is based on the fact that you can "multiply" strings in Mathematica which will leave them unevaluated (similar to multiplying two unassigned variables `x*y`), but that Mathematica will apply basic simplifications, like cancelling factors in a division.

So we start by storing the three pairs as products in `x`, `y`, `z`, respectively and multiply them all together:

```
(x="war""peace")(y="freedom""slavery")(z="ignorance""strength")

```

This evaluates to

```
"freedom" "ignorance" "peace" "slavery" "strength" "war"

```

(Mathematica automatically sorts the factors, but we don't care about the order.)

We divide this by the input to remove the word we *don't* want with `.../#`, since Mathematica cancels the factors. E.g. if the input was `"peace"` we'd end up with:

```
"freedom" "ignorance" "slavery" "strength" "war"

```

Finally, we get rid of the pairs we're not interested in, by substituting each of `x`, `y` and `z` with `1`. Again, Mathematica's simplification kicks in that `1*a` is always `a`. This part is done with:

```
/.x->1/.y->1/.z->1

```

The nice thing is that Mathematica knows that multiplication is `Orderless` so this will find the two factors regardless of whether they're adjacent in the product or not. Only the word that is opposite to the input is no longer paired in the product, so that one won't be removed and remains as the sole output.

# Answer
> 13 votes
# Vim, 60 bytes

```
D3iwar freedom ignorance peace slavery strength <esc>2?<C-r>"
3wdwVp

```

Try it online! in the backwards compatible V interpreter.

Of course, if we were to switch to V we could save one byte by using a more convenient input method. But since this is such a small difference I'd prefer using the non-golfing version.

Explanation:

```
D                       " Delete this whole line
 3i...<esc>             " Insert the text three times
           2?           " Search backwards twice
             <C-r>"     " For the words we deleted
3w                      " Move three words forward
  dw                    " Delete a word
    V                   " Select this whole line
     p                  " And paste the word we deleted over it

```

# Answer
> 10 votes
# C (gcc), ~~120~~ 107 bytes

```
f(long*s){long r[2]={0};strcpy(r,s);s=*r>>40?*r>>56?"\n":"":"CE";*r^=*s;r[1]^=69;puts(r);}

```

Maximum pointer abuse! Requires a little-endian machine and 64-bit longs.

The code contains a few unprintables, but copy-pasting should still work.

Try it online!

# Answer
> 9 votes
## Python, 81 bytes

```
l='war peace freedom slavery ignorance strength'.split()
lambda s:l[l.index(s)^1]

```

Or, same length:

```
l='war slavery ignorance strength freedom peace'.split()
dict(zip(l,l[::-1])).get

```

# Answer
> 8 votes
# TI-Basic, ~~103~~ ~~84~~ 77 bytes

~~Reducing to a one-liner saved lots of bytes!~~ Haha, how ironic that statement was...

```
inString("EALRGT",sub(Ans,2,1
sub("WAR  PEACE FREEDOMSLAVERY STRENGTH IGNORANCE ",9Ans+1,4+Ans

```

# Answer
> 8 votes
# Bash, ~~100~~ ~~87~~ ~~86~~ 78 bytes

```
a=peace;e=war;r=slavery;l=freedom;g=strength;t=ignorance;x=${1:1:1};echo ${!x}

```

Try it online!

The 2nd letter of each word uniquely identifies that word, so I use that character as a variable name; the value of that variable is the corresponding other word.

For instance, the 2nd letter of `peace` is `e`, and the word corresponding to `peace` is `war`, so I set `e=war`.

Given an input string, the 2nd character of that string is used as a variable name to pull up the desired corresponding word, using bash's indirect parameter expansion.

# Answer
> 7 votes
# Perl, 63 bytes

62 bytes + `-p` flag.

```
$_=(slavery,freedom,ignorance,strength,war,peace)[(ord)%6+/h/]

```

Try it online!

`ord` returns the char code of the first character of the input word.
After the `%6`, we have :

```
- freedom   => ord = 102 => %6 = 0
- slavery   => ord = 115 => %6 = 1
- ignorance => ord = 105 => %6 = 3
- strength  => ord = 115 => %6 = 1
- war       => ord = 119 => %6 = 5
- peace     => ord = 112 => %6 = 4

```

So we have `slavery` and `strength` both returning 1 (since they both start with the same letter), and none returning 2. Hence, we add `1` for `strength` (it's the only word that will match `/h/`), and we have each word mapped to an index from 0 to 5.

# Answer
> 7 votes
# Perl 6, 61 bytes

With unprintable characters shown as � (because StackExchange strips them otherwise):

```
{first {s/^\w+<(\0*$//},["���ce","�������","���
����e"X~^$_]}

```

Here's an `xxd` hex dump:

```
00000000: 7b66 6972 7374 207b 732f 5e5c 772b 3c28  {first {s/^\w+<(
00000010: 5c30 2a24 2f2f 7d2c 5b22 0704 1363 6522  \0*$//},["...ce"
00000020: 2c22 151e 0413 011d 1422 2c22 1a13 1c0a  ,".......","....
00000030: 1c06 1a0b 6522 587e 5e24 5f5d 7d0a       ....e"X~^$_]}.

```

Expanded version (unprintable characters replaced with escape sequences, and whitespace & comments added):

```
{    # A Lambda.
    first {                   # Return first element which:
        s/ ^ \w+ <( \0* $ //  #   after stripping \0 has only word characters left.
    },
    [                                                  # The array to search:
        "\x[7]\x[4]\x[13]ce",                          #   "war" xor "peace"
        "\x[15]\x[1e]\x[4]\x[13]\x[1]\x[1d]\x[14]",    #   "freedom" xor "slavery"
        "\x[1a]\x[13]\x[1c]\n\x[1c]\x[6]\x[1a]\x[b]e"  #   "ignorance" xor "strength"
        X~^ $_                                         #   each xor'ed with the input.
    ]
}

```

# Answer
> 6 votes
# R, 86 ~~87~~ ~~92~~ Bytes

Changed to an unnamed function and `gsub` to `sub` for a few bytes. The `grep` determines which of the 3 strings is used and the input is removed from that string with `sub`.

```
function(v)sub(v,'',(l=c("warpeace","freedomslavery","ignorancestrength"))[grep(v,l)])

```

# Answer
> 5 votes
# Befunge, ~~89~~ 88 bytes

```
<>_00g1v2+%7~%2~"slavery"0"war"0"freedom"0"ignorance"0"strength"0"peace"
 |p00:-<
@>:#,_

```

Try it online!

**Explanation**

We start by pushing all the possible output strings onto the stack, null terminated. This sequence is executed right to left so the values are pushed in reverse, since that's the order the characters will be needed when they're eventually output.
We then read the first two characters from stdin, which is all we need to identify the input string. If we take the ASCII value of the first letter mod 2, plus the second letter mod 7, we get a unique number in the range 2 to 7.

```
Input         ASCII      %2 %7   Sum
[fr]eedom     102 114    0  2    2
[pe]ace       112 101    0  3    3
[sl]avery     115 108    1  3    4
[st]rength    115 116    1  4    5
[ig]norance   105 103    1  5    6
[wa]r         119 97     1  6    7

```

This number can then be used as a kind of index into the string list on the stack. We iteratively decrement the index (the first time by 2), and for each iteration we clear one string from the stack with the sequence `>_`.
Once the index reaches zero, we're left with the correct output string at the top of the stack, so we use a simple string output sequence to write the result to stdout.

# Answer
> 5 votes
# PHP, 70 bytes

```
<?=[ignorance,peace,slavery,strength,freedom,war][md5("^$argv[1]")%7];

```

# Answer
> 5 votes
# C, 93

@Arnauld's answer ported to C

```
#define F(w)(char*[]){"freedom",0,"war",0,"strength",0,"slavery","peace","ignorance"}[w[1]%9]

```

# Answer
> 5 votes
## Pyke, 29 bytes

```
.d⻌૽ɦڷࠛ⯤dci@1.^iR@

```

Try it here!

```
.d⻌૽ɦڷࠛ⯤           -     "war peace freedom slavery ignorance strength"
         dc         -     ^.split(" ")
           i        -    i=^
            @       -   ^.find(input)
             1.^    -  ^ xor 1
                iR@ - input[^]

```

# Answer
> 4 votes
# C (gcc), ~~113~~ 108 bytes

```
f(char*s){char*t="5WAR\0+PEACE\09FREEDOM\0'SLAVERY\0;IGNORANCE\0%STRENGTH";while(strcmp(s,++t));puts(t+*--t-47);}

```

All instances of `\0` can be replaced with actual NUL bytes for scoring purposes.

`t+*--t-47` is undefined behavior; this may/will not work with other compilers.

Try it online!

# Answer
> 4 votes
# JavaScript (ES6), 71 ~~78~~

So much boring than Arnauld's answer, but shorter too.

Now I added the encoding with `btoa`. In the encoded string there are 4 bytes that I can not post to this site, even if they are valid characters in a javascript string. So I used an hex escape in the form `\xHH`. Each one of these escapes is counted as 1 byte.

The encoded string is `strength0ignorance0peace0war0slavery0freedom`

```
x=>(w=btoa`²ÚÞ\x9e\x0baÒ('¢¶§qí)y§\x1eÓ\x06«ÒÉZ½êòÑúÞyÚ&`.split(0))[w.indexOf(x)^1]

```

This one is 82 and case insensitive

```
x=>',,strength,,slavery,war,,,ignorance,peace,freedom'.split`,`[parseInt(x,36)%15]

```

*Test*

```
F=
x=>(w=btoa`²ÚÞ\x9e\x0baÒ('¢¶§qí)y§\x1eÓ\x06«ÒÉZ½êòÑúÞyÚ&`.split(0))[w.indexOf(x)^1]

;['freedom','slavery','war','peace','ignorance','strength']
.forEach(w=>console.log(w + ' -> ' + F(w)))
```

# Answer
> 3 votes
# Pari/GP , 86 Byte

Pari/GP is an interactive interpreter, we do not need a "print"-cmd for output; however, the Try-It\_Online-utility needs a "print"-cmd so I separated this to the "footer".
We define an "object-function" (the letter O reminds me lovely of the Orwell-function... ;-) ) :

```
x.O=s=[war,freedom,ignorance,strength,slavery,peace];for(k=1,6,if(x==s[k],i=7-k));s[i]

```

After that, call

```
print(war.O)   \\ input to Pari/GP with the O-rwell-member of "war"
       peace   \\ output by Pari/GP

```

Try it online!

(Note, that in Pari/GP the tokens given here are not strings but legal variable-names! That variables should never have any value assigned to)

# Answer
> 3 votes
# CJam, 52 (ASCII only)

```
"/.|Mv
DO'y    EK{ {:nBct'Pt}d4sE"144b26b'af+'j/_ra#1^=

```

Try it online

Note: the space-looking things are tab characters (one before and one after "EK{")

**Explanation:**

The part up to "+" is decompressing the "slaveryjfreedomjwarjpeacejignorancejstrength" string, using base conversion:
string (treated as array of character codes) → (base 144) number → (base 26) array of numbers → (adding 'a' to each number) string

```
'j/    split around 'j' characters
_      duplicate the resulting word array
ra     read the input and wrap in array
#      find the index of the input in the word array
1^     XOR with 1
=      get the word at the new index

```

# Answer
> 3 votes
# \>\<\> (Fish), ~~84~~ 78 bytes

```
0i~ia%.
v'raw'
>ol?!;
^'htgnerts'
^'yrevals'

^'ecnarongi'
^'ecaep'
^'modeerf'

```

Try it online!

We start swimming from the upper left, heading right. First we load the stack with a 0. Then we read the first letter of input (`i`), discard it (`~`), read the second letter (`i`), and reduce its ASCII value modulo 10 (`a%`). This maps a, e, r, l, g, and t to 7, 1, 4, 8, 3, and 6, respectively—let's call this number N. `.` pops two values from the stack—N and 0—and jumps to line N, character 0.

After a jump, the fish proceeds one tick before executing instructions, so it ignores the first character and swims across line N, which loads the corresponding word onto the stack. Finally we go to line 2, which outputs the whole stack and exits.

* Saved six bytes by using a jump, instead of the cool code self-modification I used before. Oh well.

# Answer
> 3 votes
# Python, 80 bytes

Somehow outgolfed xnor!

This is an unnamed lambda function, which returns the result.

```
lambda w,a="war slavery ignorance strength freedom peace".split():a[~a.index(w)]

```

**Try it online!**

The list of words is arranged such that it each is in the opposite position to its counterpart. Given the word `w`, we find its index in the word list, and then bitwise NOT (`~`) it. This flips all the bits, which is computes `n => -n-1`. Due to Python's negative indexing, gets the opposite index in the list.

As a kind of unintentional bonus, you can pass any word list of opposites to this function as the second argument.

# Answer
> 3 votes
# JavaScript, 78 bytes

```
w=>(a="war slavery ignorance strength freedom peace".split` `)[5-a.indexOf(w)]

```

This is a kind-of port of my Python answer. We store the words in a string where each is in the opposite position to its counterpart. We find the index of the given word `w`, and get that index from the end, to return the result.

Test snippet:

```
f = w=>(a="war slavery ignorance strength freedom peace".split` `)[5-a.indexOf(w)]

console.log(f("peace"))
console.log(f("ignorance"))
console.log(f("war"))
```

# Answer
> 2 votes
# Dyalog APL, 66 bytes

Either one of these:

`'slavery' 'freedom' 'ignorance' 'strength' 'war' 'peace'⊃⍨6|⎕UCS⊃⍞` uses this method (requires `⎕IO←0` which is default on many systems).

`'strength' 'freedom' 'war' 'peace' 'slavery' 'ignorance'(⍳⊃(⌽⊣))⊂⍞` does a lookup, then picks the corresponding element from the reversed list.

# Answer
> 2 votes
# Stacked, 70 bytes

```
@x'war
strength
freedom
slavery
ignorance
peace'LF split:x index\rev\#

```

Try it here! Takes input on stack and leaves output on stack. For example:

```
'war'

@x'war
strength
freedom
slavery
ignorance
peace'LF split:x index\rev\#

out

```

This code is fairly self-explanatory. Slightly modified to run all test cases:

```
('war' 'slavery' 'ignorance')
{x:'war
strength
freedom
slavery
ignorance
peace'LF split:x index\rev\#x\,}"!
disp

```

# Answer
> 2 votes
# Jolf, 35 bytes

```
.γG"ΞΠΞ¦ΞpΞsΞΈΞ3I"-5 iγ

```

There are many unprintables. Here's a hexdump, though it won't do much good:

```
00000000: 2ece b347 22ce 9e07 cea0 c28e ce9e 07c2  ...G"...........
00000010: 8ac2 a6ce 9e06 c28e 70ce 9e07 73c2 8fce  ........p...s...
00000020: 9e06 ce88 c280 ce9e 0133 4922 052d 3520  .........3I".-5
00000030: 69ce b3                                  i..

```

Here's an online link.

Basically, the code looks like:

```
.γG"..."♣-5 iγ
  G"..."♣        split uncompressed string on spaces
 γ               set gamma to this
            iγ   index of the input in gamma
.γ       -5      and get 5 - this from gamma

```

# Answer
> 2 votes
# Actually, 56 bytes

```
' "war peace freedom slavery ignorance strength"s;)í1^@E

```

Try it online!

Unfortunately, without any compression builtins, it's shorter to not compress the string and manually decompress it.

Explanation:

```
' "war peace freedom slavery ignorance strength"s;)í1^@E
' "war peace freedom slavery ignorance strength"s         split the string on spaces
                                                 ;)       make a copy, push it to the bottom of the stack
                                                   í      index of input in list
                                                    1^    XOR with 1
                                                      @E  that element in the list

```

# Answer
> 2 votes
# Haskell, 104 ~~111~~ bytes

```
data O=WAR|FREEDOM|IGNORANCE|PEACE|SLAVERY|STRENGTH deriving(Show,Enum)
f s=toEnum$mod(3+fromEnum s)6::O

```

Idea:

* Enumerate the keywords such that their counterpart is 3 positions away
* Take the keyword, get its position by `fromEnum`, move 3 steps to right (modulus 6) and convert back to the keyword
* The `::O` is needed because type inference has some problems. Giving `f` a signature `f :: O -> O` would have the same effect but is not that short.

Edit:

Replaced

```
f s=toEnum$mod(3+fromEnum s)6

```

by

```
f=toEnum.(`mod`6).(+3).fromEnum

```

thanks to @Laikoni.

# Answer
> 2 votes
# Qbasic, ~~138~~ 99 bytes

```
D$="ignorancefreedom  peace    strength slavery  war      ":INPUT A$:?MID$(D$+D$,INSTR(D$,A$)+27,9)

```

`D$` stores all the words from the left side of the mantra, then all those of the right side. Each word is padded with spaces to exactly 9 letters per word. `D$` then gets appended to itself.

Then `instr` is used to find the index of the word entered by the user. The other part of the mantra is always stored exactly 9\*3 positions further in the string, so we print a substring starting at that position, taking 9 characters.

# Answer
> 2 votes
# SmileBASIC, 92 bytes

```
A$="PEACE
E$="WAR
R$="SLAVERY
L$="FREEDOM
G$="STRENGTH
T$="IGNORANCE
INPUT I$?VAR(I$[1]+"$")

```

# Answer
> 2 votes
# Python3, 204 bytes

```
def O(W):
 A="cenayhglmodrtvifspw";R="";X=A.find(W[1]);F=round(131440+(X-3)*(63697-(X-1)*(2024847403.324*X-177731638.24852*X**2+4768471.50996*X**3-7117316292.214)))
  while(F>0):R+=A[F%19];F//=19;
  return R

```

A bit longer than I hoped, but hopefully interesting enough.

Try it online! (all testcases included)

### Ungolfed:

```
Alphabet = "cenayhglmodrtvifspw" #Alphabet to convert strings to numbers and vice versa

def StringToNumber (s): #Identify the word by the second letter
  return Alphabet.find(s[1])

def NumberToString (O):
  res=""
  while (O>0):
    res+=Alphabet[O%19]
    O//=19
  return res

def F(x): # the 'magic' function. Note that we can use floats with fewer decimals due to rounding
 return 177638 + (172739/3 + (1074106505/264 + (-(32699060621/7392) + (1986769150133/22176 - (2050733259611*(-7 + x))/332640)*(-8 + x))*(-12 + x))* (-1 + x))*(-4 + x)

def Orwell(s):
 return NumberToString(round(F(StringToNumber(s))))

```

Since most answers seem to be literally writing the words or looking them up in a dictionary to output them, I was interested in **not** doing that, as that could be an improvement for most non-golfing languages.

The basic idea is simple: change the input into a number x, calculate F(x) and change that back into a word.

Of course, F(x) is chosen such that the number corresponding to "war" maps to the number for "peace", etc. This is done using Lagrange interpolation, which gives the unique minimum degree polynomial such that F(x\_1)=y\_1, F(x\_2)=y\_2, etc. To reduce the constants in the formula a bit, the characters in the alphabet are placed such that characters in the end of the longer words come first. The first character in the alphabet cannot be at the end of a word, since this means we have to distinguish trialing zeros, which we cannot (int("0039")==int("39")).

Still, the formula is quite big. This approach would probably work better if the strings were over a smaller alphabet, as that reduces the constants in F.

# Answer
> 2 votes
# Ruby, 70 bytes

`->s{a=%w(war freedom ignorance strength slavery peace);a[~a.index(s)]}`

1. Assign an array of strings `war, freedom`, etc. to `a`: `a=%w(...)`
2. Find the index of the passed in parameter inside of `a`: `a.index(s)`
3. Find the complement of the index. `~a.index(s)` ex) `~0 == -1; ~1 == -2; ~-3 == 2`
4. Get the element at the complement: `a[~a.index(s)]`

# Answer
> 2 votes
# ///, ~~107 bytes~~ ~~105~~ 104 bytes

```
/peace/wa*//slavery/f*eedom//strength/igno*ance//war/p\eace//freedom/s\lavery//ignorance/s\trength//*/r/

```

Try it online!

Test Cases

# Answer
> 1 votes
# Pyth, 54 bytes

```
@Jc"war peace freedom slavery ignorance strength"dx1xJ

```

Try it here.

*Thanks to Leaky Nun for -2.*

# Answer
> 1 votes
# SOGL, 23 bytes

```
7"ņVυr11<╝⅔`▒τ¶‘@Θ,Wh-w

```

Explanation:

```
7                        push 7
 "ņVυr11<╝⅔`▒τ¶‘         push "ignorance strength war peace freedom slavery"
                @Θ       split on spaces
                  ,W     get the index of input in the array (e.g. war)
                         stack: [7, [ignorance,strength,war,peace,freedom slaver], 3]
                    h    swap the 7 and array
                         stack: [[ignorance,strength,war,peace,freedom slaver], 7, 3]
                     -   subtract
                         stack: [[ignorance,strength,war,peace,freedom slaver], 4]
                      w  get the nth item from the array (e.g. peace)

```

I didn't have a split on function. Dunno how that happened.

Would be 22 bytes with a split on space command but this is a more realistic score.

# Answer
> 1 votes
# Axiom, 155 bytes

```
t:Table(String,String):=table();a:=["war","peace","freedom","slavery","ignorance","strenght"];for i in 1..#a-1 by 2 repeat(t(a.i):=a.(i+1);t(a.(i+1)):=a.i)

```

test and result

```
(3) -> for i in a repeat output [i,t(i)]
   ["war","peace"]
   ["peace","war"]
   ["freedom","slavery"]
   ["slavery","freedom"]
   ["ignorance","strenght"]
   ["strenght","ignorance"]

```

# Answer
> 1 votes
# , 61 bytes

```
-&.((cut': war freedom ignorance strength slavery peace')i.<)

```

`:` fills the 0th position, so the first element corresponds to negative 1st (last), and so on. Lookup the word and negate the index.

Try it online!

# Answer
> 1 votes
# Stax, 31 bytes<sup>CP437</sup>

```
é≡[pZÉz>╨=üX«Θv¥5║6◙%▌ëQù&ü╢╟FP

```

37 bytes when unpacked,

```
`j<r:8GGme*6k{"TQH>C;q)Jc4%&`jc,]INv@

```

Run and debug online!

## Explanation

```
`j<r:8GGme*6k{"TQH>C;q)Jc4%&`            Compressed string literal for
                                             war freedom ignorance strength slavery peace
                             j           Split on spaces
                              c,]I       Find index of input
                                  Nv     Negate it and minus one
                                    @    Get the element at index
                                         Implicit output

```

# Answer
> 1 votes
# Clojure, 98 (?) bytes

```
(def m '("war""peace""freedom""slavery""ignorance""strength"))(apply hash-map(concat(reverse m)m))

```

The second expression is a hash-map which can be called as though it were a function to obtain the desired result, but I'm not sure this exact line of code counts when you have to go in there and add a parenthesis in the middle to actually use it. Anyhow this manages to be marginally shorter than just writing the whole map out manually by taking advantage of how `hash-map` reads items in a sequence as alternately keys and values by reversing the sequence and concatenating it to itself to provide both forward and backward mappings.

# Answer
> 1 votes
# ink, 111 bytes

```
=n(w)
LIST d=war,freedom,ignorance,peace,slavery,strength
~d=d(1)
-(i){"{d}"==w:{d+3:{d+3}|{d-3}}->->}
~d++
->i

```

Try it online!

Called as `->n("war")->`.

If taking one of the list values rather than a string as input is acceptable (I feel like it probably shouldn't be), there's a 79-byte solution:

```
=n(w)
LIST D=war,freedom,ignorance,peace,slavery,strength
{w+3:{w+3}|{w-3}}->->

```

Try it online!

# Answer
> 1 votes
# Subleq (8-bit words), 95 bytes

```
-1 100 -1
-1 101 -1
30 101 18
36 18 -1
0 6 -1
12 12 6
37 12 -1
12 -1 24
0 18 -1
12 12 18
97 4 2 5 6 2 -10
-112 -101 -97 -99 -101 0 0 0 0 0
-119 -97 -114 0 0 0 0 0 0 0
-115 -116 -114 -101 -110 -103 -116 -104 0 0
-102 -114 -101 -101 -100 -111 -109 0 0 0
-115 -108 -97 -118 -101 -114 -121 0 0 0
-105 -103 -110 -111 -114 -97 -110 -99 -101

```

Subleq emulator

## Explanation

```
-1 100 -1 ' 0: Input first letter to 100:
-1 101 -1 ' 3: Input second letter to 101:
30 101 18 ' 6: if 101: <= "a" (later loops "e","g","l","r","t") goto 18:
36 18 -1  ' 9: 18: = 18: + 10 (move to next word)
0 6 -1    '12: 6: = 6: + 1 (move to next second letter comparison)
12 12 6   '15: 12: = 0 goto 6:
37 12 -1  '18: put -37: into 12 (this address is incremented in the code) if 12: <= 0 exit
12 -1 24  '21: output 12:
0 18 -1   '24: 18: = 18: + 1
12 12 18  '27: 12: = 0 goto 18
97 4 2 5 6 2 -10 '30: to 36: data for loop starting at 6:
-112 -101 -97 -99 -101 0 0 0 0 0            '37:-"peace"
-119 -97 -114 0 0 0 0 0 0 0                 '47:-'war"
-115 -116 -114 -101 -110 -103 -116 -104 0 0 '57:-"strength"
-102 -114 -101 -101 -100 -111 -109 0 0 0    '67:-"freedom"
-115 -108 -97 -118 -101 -114 -121 0 0 0     '77:-"slavery"
-105 -103 -110 -111 -114 -97 -110 -99 -101  '87:-"ignorance"

```

# Answer
> 1 votes
# AWK, 79 bytes

```
$0=/w/?"peace":/f/?"slavery":/p/?"war":/v/?"freedom":/t/?"ignorance":"strength"

```

Try it online!

This is a straightforward nested ternary using string searches for a character unique to each input string. The `else` and the end assigned the value which is associated with `ignorance`, so the code assumes only value input strings will be used.

It's essentially equivalent to this code...

```
if(index($0,"w") $0 = "peace"
else if(index($0,"f") $0 = "slavery"
..etc..
else $0 = "strength"

```

The value of the ternary becomes the value of `$0`, which is always truthy, to the code prints that value.

# Answer
> 1 votes
# Vyxal, 31 bytes

```
`⋏ż⋎₈Ǐḋ ∴» ⟇ǒ ¢¨ ʁż ∪Ǒƛ²`⌈~ḟ1꘍i

```

Try it Online!

# Answer
> 0 votes
# Clojure, 98 bytes

Direct port of @Arnauld's JavaScript answer.

```
#((clojure.string/split"freedom,,war,,strength,,slavery,peace,ignorance"#",")(rem(int(nth % 1))9))

```

Pregolfed:

```
(defn war [word]
  ; Create a list of strings by splitting on commas, and "get" from the resulting list
  ((clojure.string/split "freedom,,war,,strength,,slavery,peace,ignorance" #","
     ; Calculate the index to get (see the original answer for details)
    (rem (int (nth word 1)) 9))))

```

# Answer
> 0 votes
# Pip, ~~57~~ 55 bytes

```
(aN_FI"warpeace freedomslavery ignorancestrength"^s)Rax

```

Saved 2 bytes by adapting MickyT's clever R answer. Try it online or verify all test cases.

### Explanation

```
                   a is cmdline arg; s is space (implicit)
      "..."^s      Split string on spaces to create three-item lookup table
    FI             Filter on this function:
 aN_                 a is a substring?
(            )Rax  In matching lookup entry, replace a with empty string and autoprint

```

# Answer
> 0 votes
## C 211 bytes

```
#define S !strcmp void f(char *s){*a[]="WAR","PEACE","FREEDOM","SLAVERY","IGNORANCE","STRENGTH"};printf("%s",S(s,a[0])?a[1]:S(s,a[1])?a[0]:S(s,a[2])?a[3]:S(s,a[3])?a[2]:S(s,a[4])?a[5]:S(s,a[5])?a[4]:"\0");

```

Assuming inputs in caps only.

Ungolfed version:

```
#define S !strcmp

void f(char *);

int main(int argc, char *argv[])
{
   system("clear");
   f(argv[1]);
}
void f(char *s)
{
  char *a[]={"WAR","PEACE","FREEDOM","SLAVERY","IGNORANCE","STRENGTH"};
  printf("%s",S(s,a[0])?a[1]:S(s,a[1])?a[0]:S(s,a[2])?a[3]:S(s,a[3])?a[2]:S(s,a[4])?a[5]:S(s,a[5])?a[4]:"\0");
}

```

Can definitely be shortened in someway!

# Answer
> 0 votes
# SpecBAS - 123

```
1 DIM a$="war","peace","freedom","slavery","ignorance","strength"
2 INPUT b$: n=SEARCH(a$() FOR b$): ?a$(IIF(ODD n,n+1,n-1))

```

Finds the index of the input string.

Inline IF checks if that is odd to print either the string after or before that position.

# Answer
> 0 votes
# Java 8, 183 bytes

Golfed:

```
s->java.util.Arrays.stream(new String[]{"pewar","wapeace","slfreedom","frslavery","stignorance","igstrength"}).filter(t->t.startsWith(s.substring(0,2))).findFirst().get().substring(2)

```

Ungolfed with test program:

```
public class WarIsPeaceFreedomIsSlaveryIgnoranceIsStrength {

  public static void main(String[] args) {
    for (String str : new String[] { "war", "peace", "freedom", "slavery", "ignorance", "strength" }) {
      System.out.print(str);
      System.out.print(" = ");
      System.out.println(f(s -> java.util.Arrays.stream(
        new String[] { "pewar", "wapeace", "slfreedom", "frslavery", "stignorance", "igstrength" }).filter(
          t -> t.startsWith(s.substring(0, 2))).findFirst().get().substring(2),
        str));
    }
  }

  private static String f(java.util.function.Function<String, String> function, String input) {
    return function.apply(input);
  }
}

```

This function is nested lambdas with streams. It takes an array of strings where the first two characters of the string acts as a map key, matching the input, while the remainder of each string is the map value, the output. It finds the string matching the given input and returns the string that matches it.

Program output:

```
war = peace
peace = war
freedom = slavery
slavery = freedom
ignorance = strength
strength = ignorance

```

# Answer
> 0 votes
# JavaScript, 80 bytes

Somewhat similar to this JavaScript answer (but developed totally independently), this program reads the input as a base-30 number, takes the parsed value modulo 7, and uses that result as an index to fetch the corresponding value from an array. `war` cannot be parsed as a base-30 number, so it produces `NaN`, which falls back to `peace` outside the array.

```
s=>"slavery00war0freedom0strength0ignorance".split(0)[parseInt(s,30)%7]||"peace"

```

# Answer
> 0 votes
# Tcl, 114 bytes

```
set L {war peace freedom slavery ignorance strength}
puts [lindex $L [expr [set i [lsearch $L war]]%2?$i-1:($i+1)%7]]

                                         ^
                                         Not accounting "war" word as it is input parameter

```

Try it online!

# Answer
> 0 votes
# QBIC, 82 bytes

```
;?mid$(@ignorancefreedom  peace    strength slavery  war      `+B,instr(B,A)+27,9)

```

This is a quite literal translation of my QBasic answer. It's a bit shorter because QBIC handles (some of) the QBasic boilerplate.

# Answer
> 0 votes
# 8th, 96 bytes

```
: f ["ignorance","strength","war","peace","freedom","slavery"] swap ' s:= a:indexof 1 bxor a:@ ;

```

**Usage and output**

```
ok> "war" f . drop
peace

```

**Ungolfed version** (with comments)

```
: f \ s -- a s
  ["ignorance","strength","war","peace","freedom","slavery"] \ Push the array on the stack
  swap            \ Put input string on TOS
  ' s:= a:indexof \ Get the index of the input string in the array
  1 bxor          \ XOR the index with 1
  a:@             \ Push on the stack the element in the array at that index
;

```

# Answer
> 0 votes
# ///, 106 bytes

```
/war/p@eace//peace/wa@r//freedom/slav@ery//slavery/fr@eedom//ignorance/str@ength//stregnth/ignoranc@e//@//

```

Try it online!

Since /// has no other way of taking input, it can be hard-coded. The input goes at the very end of the program.

Pretty simple, it takes one word, and replaces it with another, but the replacement has an `@` sign in it. That is because if there was no `@` sign, the program would get stuck replacing one word with the same word. The `@`s are removed at the end of the program.

# Answer
> 0 votes
# C(bcc 32 bit int), 124 bytes

```
g(int*a){int*b[]={"war","peace","freedom","slavery","ignorance","strenght"},i=0;for(;i<6&&*b[i++]-*a;);return b[i%2?i:i-2];}

```

g:Strings-\>Strings would return the next b\[i+1\] or the precedent b\[i-1\] pointer value based on i%2

# Answer
> 0 votes
# Japt, ~~38~~ 37 bytes

```
`°ãïêæ¡È7ea«lavyåMLL`qu
g3+UbNg

```

Try it

# Answer
> 0 votes
# q/kdb+, ~~65~~ 61 bytes

**Solution:**

```
{(x,y)!y,x}[`war`freedom`ignorance;`peace`slavery`strength]`$

```

**Examples:**

```
q){(x,y)!y,x}[`war`freedom`ignorance;`peace`slavery`strength]`$"war"
`peace
q){(x,y)!y,x}[`war`freedom`ignorance;`peace`slavery`strength]`$"slavery"
`freedom

```

**Explanation:**

Built a dictionary of keys-\>values, lookup user input in the merged dictionary:

```
{(x,y)!y,x}[`war`freedom`ignorance;`peace`slavery`strength]`$ / solution
{         }[                      ;                       ]   / lambda with implicit x and y
            `war`freedom`ignorance                            / the x
                                   `peace`slavery`strength    / the y
       y,x                                                    / append x to y
 (x,y)                                                        / append y to x
      !                                                       / create dictionary keys!values
                                                           `$ / cast input from a string into a symbol

```

# Answer
> 0 votes
# 05AB1E, 29 bytes

```
“‡î—™ÃÒryšÔ¤í¸ï“¨'–›¦«#DIk1^è

```

Try it online!

# Answer
> 0 votes
# Factor \+ `qw`, 73 bytes

```
[ qw{ war freedom ignorance strength slavery peace } dup reverse zip at ]

```

Try it online!

### How?

```
                                                     ! "freedom"
qw{ war freedom ignorance strength slavery peace }   ! "freedom" { "war" "freedom" "ignorance" "strength" "slavery" "peace" }
dup                                                  ! "freedom" { "war" "freedom" "ignorance" "strength" "slavery" "peace" } { "war" "freedom" "ignorance" "strength" "slavery" "peace" }
reverse                                              ! "freedom" { "war" "freedom" "ignorance" "strength" "slavery" "peace" } { "peace" "slavery" "strength" "ignorance" "freedom" "war" }
zip                                                  ! "freedom" {
                                                           { "war" "peace" }
                                                           { "freedom" "slavery" }
                                                           { "ignorance" "strength" }
                                                           { "strength" "ignorance" }
                                                           { "slavery" "freedom" }
                                                           { "peace" "war" }
                                                       }
at                                                   ! "slavery"

```

# Answer
> -1 votes
# C, 137 101 98 132 characters

counted with escaped characters as 1

```
void i(char*i){char*s="\7\4\23c\25e\25\36\4\23\1\35\24\0\32\23\34\12\34\6\32\13e";for(s+=i[3]&4?i[4]&2?14:6:0;putchar(*i++^*s++););}

```

Try it online

---
Tags: code-golf, string, kolmogorov-complexity
---


title: What calculator is this datafile for?

text:
# Question
Title: What calculator is this datafile for?
The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made.

The datafiles always start with a string `**TI`, the version (described below), and other data you can ignore.

Now, the versions you need to recognize are:

```
95* => TI-95
92P => TI-92+
92* => TI-92
89* => TI-89
86* => TI-86
85* => TI-85
84P => TI-84+
84* => TI-84
83* => TI-83
83P => TI-83+
82* => TI-82
81* => TI-81
74* => TI-74
73P => TI-73+

```

## Examples

```
**TI95*   => TI-95
**TI83P   => TI-83+
**TI73P   => TI-73+
**TI85*   => TI-85
**TI83PGG => TI-83+
**TI86*asdf*9**TI92Pasd => TI-86

```

## Rules

You can assume the input is always correct, is at least 7 characters long, and has been crafted for one of the TI calculators listed above.

This is code golf, so the shortest answer wins.

I/O rules and loopholes apply.

# Answer
# TI-BASIC (TI-83), ~~40~~ 39 bytes

*Saved a byte thanks to @iPhoenix.*

```
Ans→Str1
sub(Ans,5,2
If sub(Str1,7,1)="P
Ans+"+
"TI-"+Ans

```

Takes input as a string via `Ans` (allowed by default). The character count differs from the byte count because TI-BASIC is tokenised: `Str1` and `sub(` are 2-byte tokens; `Ans`, , `If` , and all other characters used (including newlines) are 1-byte tokens.

### Sample output

Uses this emulator.

### Explanation

```
Ans→Str1             # store input in Str1
sub(Ans,5,2          # overwrite Ans with 2-digit calculator ID (5th and 6th input characters)
If sub(Str1,7,1)="P  # if the 7th input character is 'P'...
Ans+"+               # then add '+' to Ans
"TI-"+Ans            # full calculator name (printed implicitly)

```
> 18 votes

# Answer
# brainfuck, 39 38 35 bytes

Saved 3 bytes thanks to @Dorian.

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

```

Try it online!

This abuses the fact that the characters `*`,`+`, and `-` are very close to each other in ASCII.

Ungolfed:

```
,+++>  create a minus from the first asterisk
,>      store the second asterisk for comparison later
,.      display T
,.      display I
<<.-->> display the minus from line 1 and turn it into a plus
,.      display first number
,.      display second number

,[-<->]<[  if the last char is not an asterisk from line 2
  <.<      display the plus from line 5
]

```

Original 38 byte solution:

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

```

Original 39 byte solution:

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

```
> 17 votes

# Answer
# Python 3, ~~52, 43~~ 36 bytes

```
lambda x:"TI-"+x[4:6]+"+"*(x[6]>"*")

```

Try it online!
> 8 votes

# Answer
# perl -pl, 24 bytes

```
s;(\d..).*;-$1;;y;P*;+;d

```

Try it online!

Keep the first digit and the next two characters, removes anything after that, and inserts a `-` before the first digit. Replaces any `P` with a `+`. Removes any `*`.

Reads lines from `STDIN`, writes versions to `STDOUT`.

Editted to deal with trailing garbage.
> 6 votes

# Answer
# TI-Basic (TI-84 Plus CE), 54 bytes (50 tokens) ~~61 bytes (56 tokens)~~

```
"TI-"+sub(Ans,5,3
If sub(Ans,6,1)="P
Then
sub(Ans,1,5)+"+
Else
sub(Ans,1,5
End
Ans
```

Usage: `"**TI89*":prgmNAME` if the program is named `NAME`.

TI-Basic is a tokenized language, the `sub(` token is two bytes and all the other tokens used here are one byte (e.g. digits, punctiation, newline, `Ans`, `If`, `Then`, `Else`, `End`).

Takes the input in `Ans` and implicitly prints the result stored in `Ans`.

Encodes the `-` with the subtraction `-` (0x71), not the negative `<sup>-</sup>` (0xB0)

Explanation:

```
"TI-"+sub(Ans,5,3  # 19 tokens, 21b: "**TIXX?..." -> "TI-XX?"
If sub(Ans,6,1)="P # 12 tokens, 13b: If the "?" above is "P"
Then               #  2 tokens,  2b: Then
sub(Ans,1,5)+"+    # 11 tokens, 12b:   Replace "P" with "+"
Else               #  2 tokens,  2b: Else
sub(Ans,1,5        #  7 tokens,  8b:   Remove the last character
End                #  2 tokens,  2b: End If
Ans                #  1 tokens,  1b: Last line's Ans is implicitly printed

```
> 6 votes

# Answer
# JavaScript (ES6), 34 bytes

```
s=>'TI-'+s[4]+s[5]+[{P:'+'}[s[6]]]

```

Try it online!

### Commented

```
s =>         // s = input string: **TIddp[…]
             //                   0123456
  'TI-' +    // append the prefix
  s[4] +     // append the first digit (5th character)
  s[5] +     // append the second digit (6th character)
  [          // wrapper to make sure that undefined is turned into an empty string
    {P: '+'} //   define an object with a single key 'P' mapped to the value '+'
    [s[6]]   //   and attempt to retrieve this '+', using the 7th character
             //   (which is either 'P' or '*')
  ]          // end of wrapper

```
> 5 votes

# Answer
# 05AB1E, 16 bytes

Sorry, didn't understand the comment...

```
7£¦¦…*PI„ +„I-ª‡

```

Try it online!

## Explanation

```
7£               Take a 7-char prefix.
  ¦¦             Remove the first 2 characters.
    …*PI         "*PI"
        „ +„I-ª  With: [" ", "+", "I-"] respectively
               ‡ Transliterate

```
> 5 votes

# Answer
# Keg, `-ir`, 15 bytes

```
__,,\-,,,P=[\+,

```

Try it online!

Huh, who'da thunk a simple stack approach would beat everyone else?

## Explained

```
__,,\-,,,P=[\+,
__              # Pop the two asterisks at the start
  ,,            # Print the "TI"
    \-,         # Followed by a dash
       ,,       # Then the number embedded in the input
         P=     # See if the last character is P
           [\+, # If it is, print a "+", otherwise, do nothing and end execution

```
> 5 votes

# Answer
# Hexagony, 28 bytes

```
,,..34{<{__5|..,;,;#@$_#_.@;

```

Try it online! Accepts input on `stdin` and prints to `stdout`.

# Explanation

I'll use the test case `**TI83P` for illustration. Execution starts at the top left corner and follows instruction pointer 0 (IP0) along the red path.

* `,,` reads and discards the first two asterisks from `stdin`.
* `,;` reads the `T` from `stdin` and prints it to `stdout`.
* `,;` does the same but for the letter `I`.

At this point, the current memory edge holds the integer 73 (the ASCII character `I`).

* `#` takes the current memory edge modulo 6 (1 in this case) and transfers control to the corresponding instruction pointer.

This pauses IP0 at the `@` command and picks up execution in the top right corner, following IP1 along the blue path.

* `{` moves the memory pointer to its left neighbor. Memory edges are 0 by default, so this is easier than trying to zero the previous edge.
* `45;` prints `-` to `stdout`.
* `,;,;` reads the two digits of the model number and prints them. The zigzag pattern allows reuse of the same instructions that printed the letters `TI`.
* `{` moves the memory pointer again. This instruction is superfluous, however, because
* `,` overwrites the current memory edge with the next character read from `stdin`.

This character is either `*` (ASCII 42) or `P` (ASCII 80).

* If it is `*`,
    + `#` transfers control back to IP0 (because 42 mod 6 = 0). IP0 picks up at the `@` instruction, which finally terminates the program.
* If it is `P`,
    + `#` transfers control to IP2 (because 80 mod 6 = 2), which starts in the right corner and follows the grey path.
    + `$` skips the `;` instruction to avoid printing `P` to `stdout` instead of `+`.
    + `{43;` prints `+` to `stdout`.
    + `@` terminates the program.

---

I had a lot of fun (ab)using the `#` instruction with this solution.

*Image courtesy of Timwi's HexagonyColorer.*
> 4 votes

# Answer
# QuadR, 21 bytes

```
I
^\*.|\*.*
P.*
I-

+

```

Try it online!
> 3 votes

# Answer
# str, 21 bytes

```
2G2G'-:2G:g'P='+x:O;q

```

Explanation:

```
2G                     Read the `**` at the beginning (this stays on the stack for the entire program, but does nothing)
  2G                   Read the string `TI`
    '-:                Concatenate a - to it, to get `TI-`
       2G:             Read the next two characters (the version number) and concatenate them to the assembled string
          g            Read the next character (either `P` to signify I need to add a plus sign, or garbage)
           'P=         Check if it's equal to `P`, producing a zero or one
              '+x:     Repeat the string `+` a number of times equal to the number on top of the stack (zero or one in this case), and concatenate it to the assembled string
                   O;q Output the result, then tell the interpreter to ignore the rest of the input

```

Try it online!
> 3 votes

# Answer
# Retina 0.8.2, 19 bytes

```
1M!`TI..P?
P
+
I
I-

```

Try it online! Link includes test cases. Explanation:

```
1M!`TI..P?

```

Extract the `TI`, 2 digits, and a possible trailing `P`.

```
P
+

```

If there was a `P` then change it to a `+`.

```
I
I-

```

Add a `-` after the `I`.

Retina 1 saves a byte because it uses `0L` instead of `1M!`.
> 3 votes

# Answer
# , 24 bytes

```
'TI-',4 5&{,'+'#~'P'=6&{

```

Try it online!

### How it works

```
'TI-',4 5&{,'+'#~'P'=6&{
                 'P'=6&{ 6th position = 'P'?
            '+'#~        either take 0 or 1 '+' and
      4 5&{,             append it to the 4th and 5th char
'TI-',                   prepend 'TI-'

```
> 3 votes

# Answer
# Charcoal, 16 bytes

```
TI-§θ⁴§θ⁵×+⁼P§θ⁶

```

Try it online! Link is to verbose version of code. Explanation:

```
TI-

```

Print the initial `TI-`.

```
§θ⁴§θ⁵

```

Print the 4th and 5th characters of the input (0-indexed).

```
×+⁼P§θ⁶

```

Print as many `+`s as there are `P`s equal to the 6th character of the input.
> 3 votes

# Answer
# Vyxal, 20 bytes

Port of @Daniel H.'s answer.

```
`TI-`?46fiJ?6i×≠\+*J

```

Try it online!

### Explained

```
`TI-`?46fiJ?6i×≠\+*J
`TI-`                 # Stack "TI-"
     ?46fi            # Stack input[4:6]
          J           # Join
           ?6i×≠\+*J  # Stack "+" and join if input[6] is equal to "*"

```

Basically my first vyxal answer, thanks so much to all who helped me, including @lyxal.

## 13 bytes @lyxal

```
7Ẏ‛P+*×P\-2Ṁ

```

Try it online!
> 3 votes

# Answer
# Befunge-93, 27 bytes

```
~~~,~,"-",~,~,~"P"-#@_"+",@

```

Try it online!

Read two characters (and ignore them). Read a char (`T`) and print it. Read another char (`I`) and print it. Print a `-`. Read a char (a digit) and print it. Read another char (a digit) and print it. Read a char, end the program if it's not a `P`, else print a `+` and end the program.

We cannot just read a number and print a number, as that will be printed with an additional trailing space.
> 2 votes

# Answer
# Haskell, 35 bytes

```
f s="TI-"++s!!4:s!!5:['+'|s!!6>'*']

```

Try it online!
> 2 votes

# Answer
# MathGolf, 16 bytes

```
7<2/╞├'-⌐~'P='+*

```

Try it online.

**Explanation:**

```
7<                 # Leave the first 7 characters of the (implicit) input-string
  2/               # Split it into parts of size 2
    ╞              # Discard the first part (the "**")
     ├             # Remove and push the first part to the stack (the "TI")
      '-          '# Push "-"
        ⌐          # Rotate the stack once towards the left (so the remaining pair is at
                   # the top again)
         ~         # Pop and dump its contents onto the stack (the number and "*"/"P")
          'P=     '# Check if the top of the stack equal "P" (1 if truthy; 0 if falsey)
             '+*  '# Repeat "+" that many times ("+" if it was "P"; "" if not)
                   # (output the entire stack joined together implicitly as result)

```
> 2 votes

# Answer
# Rust macro, 135 bytes

```
macro_rules!f{(* * T I$($n:literal)*P$($x:tt)*)=>{[84,73,45,$($n+48,)*43]};(* * T I$($n:literal)**$($x:tt)*)=>{[84,73,45,$($n+48),*]};}

```

Defines a macro `f` that takes a list of tokens and returns an array of integers (ASCII chars).

try it online

## Explanation

```
macro_rules! f {
    (                  // if the input has the following tokens:
        * * T I        //  * * T I
        $($n:literal)* //  zero or more literals (called n)
        P              //  P
        $($x:tt)*      //  anything
    ) => {             // expand to this:
        [              //  an array
           84, 73, 45, //   with the ASCII codes for TI-
           $($n+48,)*  //   add 48 to each n and append a comma
           43          // the ASCII code for +
        ]
    };
    (                  // if the input has the following tokens:
        * * T I        //  * * T I
        $($n:literal)* //  zero or more literals (called n)
        *              //  *
        $($x:tt)*      //  anything
     ) => {            // expand to this:
        [              //  an array
           84, 73, 45, //   with the ASCII codes for TI-
           $($n+48),*  //   add 48 to each n and join with commas
        ]
    };
}

```
> 2 votes

# Answer
# PHP, ~~39~~ ~~38~~ 36 bytes

```
fn($s)=>"TI-$s[4]$s[5]".'+'[$s[6]<P]

```

Try it online!

Basically a port of Arnauld's answer with a bit of inspiration from Sqepia's one for the "+".. Let's say that's what I would have done anyway ;)

EDIT: saved 1 byte using `<` instead of `!=`

EDIT2: Thanks to Ismael Miguel for saving another 2 bytes using vars in double quotes!
> 2 votes

# Answer
# C (gcc), 50 48 47 bytes

Thanks to Arnauld for the initial suggestion.

Not much to say here except that I conditionally print a plus sign at the end of the string if a `P` is in the seventh position.

```
f(char*s){printf("TI-%.2s%s",s+4,"+"+s[6]%80);}

```

Try it online!
> 1 votes

# Answer
# Java 8, 35 bytes

```
a->"TI-"+a[4]+a[5]+(a[6]>79?"+":"")

```

Try it online.

**Explanation:**

```
a->           // Method with character-array parameter and String return-type
  "TI-"       //  Return "TI-"
  +a[4]+a[5]  //  Appended with the (0-based) 4th and 5th characters of the input
  +(a[6]>79?  //  And if the (0-based) 6th character is larger than 'O' (thus 'P'):
     "+"      //   Append a "+"
    :         //  Else:
     "")      //   Append nothing more

```

---

# C# .NET, 35 bytes

```
s=>"TI-"+s[4]+s[5]+(s[6]>79?"+":"")

```

Only difference is the `=>` instead of `->`, and the input parameter is a string instead of character-array. Apart from that it's the same as the Java lambda above.

Try it online.
> 1 votes

# Answer
# Whitespace, 150 bytes

```
[S S S N
_Push_0][S N
S _Dupe_0][S N
S _Dupe_0][S N
S _Dupe_0][T    N
T   S _Read_as_character_(*1)][T    N
T   S _Read_as_character_(*2)][T    N
T   S _Read_as_character_(T)][T T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(I)][T T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_chartacer][S S S T    S T T   S T N
_Push_45_-][T   N
S S _Print_as_character][T  N
T   S _Read_as_character_(digit1)][T    T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(digit2)][T    T   T   _Retrieve][S N
S _Dupe][S N
S _Dupe][T  N
S S _Print_as_character][T  N
T   S _Read_as_character_(*/P)][T   T   T   _Retrieve][S S S T  S T S S S S N
_Push_80][T S S T   _Subtract][N
T   S N
_If_0_Jump_to_Label_P][N
N
N
_Exit][N
S S N
_Create_Label_P][S S S T    S T S T T   N
_Push_43_+][T   N
S S _Print_as_character]

```

Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.
`[..._some_action]` added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

**Explanation in pseudo-code:**

```
Character c = STDIN as character   (the first leading "*")
c = STDIN as character             (the second leading "*")
c = STDIN as character             (the "T")
Print c as character to STDOUT
c = STDIN as character             (the "I")
Print c as character to STDOUT
Print '-' as character to STDOUT
c = STDINT as character            (the first digit)
Print c as character to STDOUT
c = STDIN as character             (the second digit)
Print c as character to STDOUT
c = STDIN as character             (the '*'/'P')
If(c == 'P'):
  Print '+' as character to STDOUT

```
> 1 votes

# Answer
# SimpleTemplate, 52 bytes

So far, it is the 2nd longest answer, but works...

```
{@setA argv.0}TI-{@echoA.4,A.5}{@ifA.6 is equal"P"}+

```

Just naively grabs the characterss from the string, at a predefined position. Nothing fancy...

---

**Ungolfed:**

Both codes behave exactly the same:

```
{@set argument argv.0}
{@echo "TI-", argument.4, argument.5}
{@if argument.6 is equal to "P"}
    {@echo "+"}
{@/}

```

Everything outside the code is just printed out.
Basically, `TI-` and `{@echo "TI-"}` do the same exact thing.

---

You can try this on http://sandbox.onlinephpfunctions.com/code/1a2faee21e43109e148b057df65d2f119780ca45

I've implemented this version, and an aditional version as a function, to compare outputs.
> 1 votes

# Answer
# Bash, 51 bytes

```
read a
b=${a:6:1}
b=${b%\*}
echo TI-${a:4:2}${b:++}

```

Try it online!

Uses standard input and output.

a holds the first line, any other input is ignored.

b holds the * or P after the number, and then the * is removed.

data is assumed to be correct.

The echo outputs the three pieces, adding the + only if b is non-blank.
> 1 votes

# Answer
# Ruby, 33 bytes

Port of Daniel H.‘s Python answer.

```
->s{"TI-"+s[4,2]+(s[6]>?*??+:"")}

```

Attempt This Online!
> 0 votes

# Answer
# Pyth, 21 bytes

```
++"TI-":z4 6*\+q@z6\P

```

Test suite
> 0 votes

# Answer
# Knight, 29 bytes

```
O+"TI-"+G=sP4 2*"+">Gs 6 1'*'

```

Try it online!
> 0 votes

# Answer
# Go, 95 bytes

```
import."strings"
func f(s string)string{R:=Replace
return"TI-"+R(R(s[4:7],"P","+",1),"*","",1)}

```

Attempt This Online!
> 0 votes

---
Tags: code-golf
---


# Question
Title: Can You Spell This Word With These Dice?
Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea.

# Challenge

Given a list of dice which each have at least 1 face and a word, your task is to determine if it is possible to spell that word using the given dice (in which case, it should return a truthy result). Only one letter from each die can be used and a die can be used only once. You do not need to use all of the given dice.

# Examples

In a trivial example, with the dice \[\[A\], \[C\], \[T\]\] and the string CAT, the result is true. BAT would, of course, return false since there are no dice with B on them

If given \[\[A, E, I, O, U\], \[A, B, C, T\], \[N, P, R\]\] as the set of dice, you would return true for ART, TON, and CUR, but false for CAT, EAT, and PAN because those strings require reusing dice. It should also be fairly obvious that CRAB cannot be spelled with these dice since there are not enough dice.

If given \[\[A, B, C\], \[A, E, I\], \[E, O, U\], \[L, N, R, S, T\]\] as the set of dice, you would be able to spell CAT, BEE, BEAN, TEA, BEET, and BAN, but you would not be able to spell LONE, CAB, BAIL, TAIL, BAA, or TON

There may be multiples of the same die. If given \[\[A, B, C\], \[A, B, C\], \[A, B, C\]\], you would be able to spell CAB, BAA, AAA, etc... but obviously nothing without A, B, or C in it.

# Rules

* No exploiting standard loopholes
* This is , so the shortest code wins.
* You may assume that both words and dice will only be made up of capital letters.
* You may assume that the word will always be at least 1 letter long and that there will always be at least 1 die.
* You may assume that a die will never have more than one of the same letter.
* Input and output may be in any convenient format.

# Answer
# Brachylog, 5 bytes

```
∋ᵐ⊇pc

```

Try it online!

We use the input variable for the dice and the output variable for the word. It outputs `true.` when it's possible to spell the word and `false.` otherwise.

### Explanation

```
∋ᵐ        Map element: Take one side from each die
  ⊇       Subset
   p      Permute
    c     Concatenate into a string: will only succeed if it results in the output word

```
> 12 votes

# Answer
# Haskell, ~~48~~ 44 bytes

```
import Data.List
(.mapM id).any.(null.).(\\)

```

This is an anonymous function. Bound to some identifier `f` it can be used as `f "ART" ["AEIOU", "ABCT", "NPR"]`, which yields `True`. Try it online!

The non-point-free equivalent is

```
f word dice = any(\s -> null $ word\\s) $ mapM id dice

```

`mapM id` over a list of lists uses the `Monad` instance of list and can be seen as non-deterministic choice. Thus e.g. `mapM id ["AB","123"]` yields `["A1","A2","A3","B1","B2","B3"]`.

For each of those dice combinations, we check if the list difference `(\\)` of the given word and the combination yields an empty list.
> 8 votes

# Answer
# Python 2, 82 bytes

```
f=lambda d,w:w==''or any(w[0]in x>0<f(d[:i]+d[i+1:],w[1:])for i,x in enumerate(d))

```

Try it online!

```
f=lambda d,w:w==''                                                                 # Base case: we can spell '' with any dice.
                  or any(                                 for i,x in enumerate(d)) # Otherwise, we check if there is some die x such that...
                         w[0]in x                                                  # the first letter is on this die,
                                 >0<                                               # and
                                    f(d[:i]+d[i+1:],w[1:])                         # we can spell the rest of the word with the rest of the dice.

```

The comparison chain `w[0]in x>0<f(...)` is equivalent to: `w[0]in x` **and** `x>0` **and** `0<f(...)`.

The second of those is always true (`str` \> `int`) and the third of those is equivalent to `f(...)`, so that the whole thing is a shorter way to write `w[0]in x and f(...)`
> 6 votes

# Answer
## JavaScript (ES6), 68 bytes

```
f=([c,...w],a)=>!c||a.some((d,i)=>d.match(c)&&f(w,a.filter(_=>i--)))
```

```
<div oninput=o.textContent=f(i.value,d.value.split`\n`)>
<textarea id=d rows=9>
ABC
AEI
EOU
LNRST
</textarea>
<br>
<input id=i value=BEAN>
<pre id=o>true
```
> 6 votes

# Answer
# JavaScript (ES6), 74 bytes

Takes input in currying syntax `(w)(a)`, where **w** is the word we're looking for and **a** is a list of strings describing the dice. Returns **0** or **1**.

```
w=>P=(a,m='')=>w.match(m)==w|a.some((w,i)=>P(a.filter(_=>i--),m+`[${w}]`))

```

Try it online!

### Commented

We turn each subset-permutation of the dice into a regular expression pattern and test them against the target word.

```
w =>                        // w = target word
  P =                       // P = recursive function taking:
    (a,                     //   a[] = list of dice
        m = '') =>          //   m   = search pattern
    w.match(m) == w |       // force a truthy result if w matches m
    a.some((w, i) =>        // for each word w at position i in a[]:
      P(                    //   do a recursive call:
        a.filter(_ => i--), //     using a copy of a[] without the current element
        m + `[${w}]`        //     and adding '[w]' to the search pattern
      )                     //   end of recursive call
    )                       // end of some()

```
> 5 votes

# Answer
# Husk, 5 bytes

```
~V`¦Π

```

Try it online!

Returns a non-zero value if it's possible to spell the word, zero otherwise.

### Explanation

```
~V`¦Π  Arguments: word [Char], dice [[Char]]
 V     Checks if any element of a list (2) satisfies a predicate (1)
~      Composes both arguments of the above function
  `¦     (1) Is the word a subset of the element?
    Π    (2) Cartesian product of the dice list

```
> 3 votes

# Answer
# Perl 5 `-plF`, ~~48~~ 46 bytes

*@DomHastings saved 2 bytes*

```
$_=grep/@{[sort@F]}/,map"@{[sort/./g]}",glob<>

```

Try it online!

### Input:

```
word               # The word to validate
{A,B,C}{D,E,F}     # Each die is surrounded by braces, commas between the letters

```

### Output:

`0` for a word that is not validated. Any positive integer for a word that is validated

### How?

This explanation looks at the code in the order of execution, effectively right-to-left for this one-liner.

```
-F             # The first line of input is automatically split by the -F command option into the @F array.
glob<>         # Read the rest of the input and enumerate all of the permutations of it
map"@{[sort/./g]}",  # Split the permutation into separate letters, sort them and put them back together
/@{[sort@F]}/, # use the sorted letters of the target to match against
$_=grep        # check all of those permutations to see if the desired word is in them
-p             # Command line option to output the contents of $_ at the end

```
> 3 votes

# Answer
# JavaScript (Node.js), 98 bytes

```
f=(s,d,u=[])=>d<1?s.every(t=>u.pop().match(t)):d.some((x,i)=>f(s,e=[...d],[...u,x],e.splice(i,1)))

```

Try it online!

Assuming there's enough dice

# JavaScript (Node.js), 100 bytes

```
f=(s,d,u=[''])=>d<1?s.every(t=>u.pop().match(t)):d.some((x,i)=>f(s,e=[...d],[...u,x],e.splice(i,1)))

```

Try it online!

# JavaScript (Node.js), 99 bytes

```
s=>f=(d,u=[''])=>d<1?s.every(t=>u.pop().match(t)):d.some((x,i)=>f(e=[...d],[...u,x],e.splice(i,1)))

```

Try it online!
> 1 votes

# Answer
# Jelly,  ~~10~~  9 bytes

-1 thanks to Erik the Outgolfer (use `w` rather than `ẇ@` \>.\<)

```
Œ!Œp€Ẏw€Ṁ

```

A dyadic link accepting a list of lists of characters on the left (the dice) and a list of characters on the right (the word) which returns 1 if possible and 0 if not.

**Try it online!** Or see the test-suite.

### How?

```
Œ!Œp€Ẏw€Ẹ - Link: list of lists of characters Dice, list of characters Word
Œ!        - all permutations of the dice (i.e. all ways to order the dice)
  Œp€     - Cartesian product of €ach (i.e. all ways to roll each ordering)
     Ẏ    - tighten (i.e. all ordered ways to roll the dice)
       €  - for each:
      w   -   first index (of sublist W) in the result (positive if there, 0 otherwise)
        Ẹ - any truthy? (1 if it is possible to roll the word, 0 otherwise)

```

---

### Faster algorithm (also 9 bytes):

A dyadic link with the same input format which returns positive integer (truthy) when possible and 0 (falsey) otherwise.

```
Œpf€Ṣ€ċṢ} - Link: list of lists of characters Dice, list of characters Word
Œp        - Cartesian product of the dice (all rolls of the dice)
  f€      - filter keep for €ach (keep the rolled letters if they are in the word)
    Ṣ€    - sort €ach result
       Ṣ} - sort Word
      ċ   - count occurrences

```
> 1 votes

# Answer
# , ~~192 185 135 117 111~~ 109 bytes

```
function(x,...)s(x)%in%apply(expand.grid(lapply(list(...),c,"")),1,s)
s=function(x)paste(sort(x),collapse="")

```

Try it online!

-2 chars thanks to Giuseppe.
> 1 votes

# Answer
# Vyxal, 8 bytes

```
ṖvÞ*Þf$c

```

Try it Online!

Returns 1 for valid, 0 for invalid.

```
Ṗv  Þf   # over all permutations
  Þ*     # Reduce by cartesian product
      $c # Check if the input contains that

```
> 1 votes

# Answer
# Pyth, 21 bytes

```
.Em}eQdsm.ps.nd.U*bZh

```

**Test suite**

Explanation:
```
.Em}eQdsm.ps.nd.U*bZhQ # Code with implicit variables
.E                     # Print whether any of
       sm.ps  d        # all positive length permutations of each element in
        m   .nd.U*bZhQ # the Cartesian product of the list of dice
  m}eQd                # contain the target word

```
> 0 votes

# Answer
# Ruby, 54 bytes

```
->w,a{a.permutation.any?{/#{w.chars*".*,.*"}/=~_1*?,}}

```

Attempt This Online!
> 0 votes

---
Tags: code-golf, string, decision-problem, boggle
---


title: Output the PPCG Prime

text:
# Question
Title: Output the PPCG Prime
# This is the PPCG Prime

**624 digits long**

```
777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777111111111111111111111111111111111111111111111111111111111111111111111111111111188888888118888888811188888811188888811188111118818811111881881111881881111881188111118818811111881881111111881111111188888888118888888811881111111881118888188111111118811111111881111111881111881188111111118811111111881111881881111881188111111118811111111188888811188888811111111111111111111111111111111111111111111111111111111111111111111111111111111333333333333333333333333333333333333333

```

If we split every 39 digits we get
```
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
111111111111111111111111111111111111111
111111111111111111111111111111111111111
188888888118888888811188888811188888811
188111118818811111881881111881881111881
188111118818811111881881111111881111111
188888888118888888811881111111881118888
188111111118811111111881111111881111881
188111111118811111111881111881881111881
188111111118811111111188888811188888811
111111111111111111111111111111111111111
111111111111111111111111111111111111111
333333333333333333333333333333333333333

```

**Your task is to output the PPCG-Prime**

This is . The shortest code in bytes wins.

If you input the PPCG-Prime in the Mathematica function below, you get this result

```
ArrayPlot@Partition[IntegerDigits@#,39]&

```

# Answer
> 25 votes
# Jelly, ~~55~~ ~~54~~ ~~52~~ ~~47~~ 46 bytes

```
“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’“¿mŻ“p’Dx39jBo88V

```

There are more convoluted approaches in the revision history, but this simple one beats them all.

Try it online!

### How it works

```
“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’

```

This is a numeric literal, encoded in bijective base 250, where the digits are taken from Jelly's code page. The chain's (left) argument and the return value are set to the encoded integer,
**n := 0x21871c77d7d7af6fafafeff0c37f72ff7fbfbdbfdfef5edfeff8e3**.

```
“¿mŻ“p’

```

A similar literal to the above one, but the second  separates two encoded integers. The return value is replaced with the encoded array, **\[777711, 113\]**.

```
Dx39

```

`D` converts the return value to decimal (**\[\[7, 7, 7, 7, 1, 1\], \[1, 1, 3\]\]**), then `x39` repeats each individual integer/digit in the result **39** times. This yields a pair of arrays, which contains the digits before and after the 7-character high text, respectively. Let's call this array **A**.

```
jB

```

First, `B` converts the (left) argument **n** to binary. This yields the digits that form the 7-character high text, where each **88** has been replaced by **0**.

Then, `j` joins the array **A**, using the binary array as separator.

```
o88

```

This performs logical OR with **88**, replacing each **0** with **88**.

```
V

```

We have the correct digits now, but in an array of **7**'s, **1**'s, **88**'s, and **3**'s. `V` implicitly turns this array into a string and then evals it, yielding a single integer.

# Answer
> 6 votes
# Bubblegum, 51 bytes

```
00000000: 331f c4c0 90ba c002 0a90 5986 d818 50d5  3.........Y...P.
00000010: 282c 3406 6e65 5036 1e4b 9195 8109 649d  (,4.neP6.K....d.
00000020: 5858 1896 4279 68b2 f895 61fa 94ca c098  XX..Byh...a.....
00000030: 3800 00                                  8..

```

Try it online!

# Answer
> 6 votes
# SOGL V0.12, ~~52~~ 51 bytes

```
≡=vā⁷H↕↕jΥ_Ν↑∆∫▲pΖo	‘θδžΟwd╬2n?q[‘²Κ7n⌡"α¼■╤ģ⅞¹‘¹H∑
```

ties bubblegum!
note that this answer contains a tab

Try it Here!

Tries to save bytes by reusing the same string for both of the `P`s.

Explanation:

```
...‘...‘²Κ7n⌡"..‘¹H∑  compressed strings replaced with ellipses to shorten the width
...‘                  pushes "1111111188888188888888111118811111881111188111118881118818111811111111188888188888888111118811111881111188118118888818818881811118111" - CG
    ...‘              pushes "1111111888888888888881118118111811811181181118118111811811188881111881" - P
        ²             join with itself - double the P
         Κ            reverse add - prepend the PP to CG
          7n          split to line lengths of 7
            ⌡         for each
             "..‘       push "311ŗ117777" with ŗ replaced with the ToS - current item looping over
                 ¹    wrap the results tn an array
                  H   rotate it counter-clockwise
                   ∑  join to a single string

```

The numbers there are saved as from the original starting at the bottom left, going up, then 1 right & down, then up, ect.

A 52 byte plain compression version:

```
#⅓→9E■Ν►1&⅝θ⅞%øøμ←N═]y)u⅝↓$A○░(ZF16Φ⅓Mč▓d⅛Hι‼∑υnη▲Z‘

```

Try it Here!

# Answer
> 5 votes
# CJam, ASCII, 61

```
Hs78f*~_@"'hfv;HH`>O4RU(_o^.U)9q&-1iadr`4tk"90b2b88fe|1$'339*

```

Try it online

Append `]s39/N*` for nice wrapping.

**Explanation:**

```
Hs         generate "17" (H=17)
78f*       repeat each character 78 times, getting an array of 2 strings
~_         dump the 2 strings on the stack, and duplicate the '7's
@          move the '1's to the top of the stack (first 6 lines done so far)
"…"90b     convert that string from base 90 (treating characters as numbers)
2b         convert the resulting number to base 2,
            obtaining a bit map for the "PPCG" part, with 1 for "1" and 0 for "88"
88fe|      replace (boolean OR) all the zeros with 88
1$         copy the string of 78 '1's
'339*      repeat '3' 39 times

```

# Answer
> 4 votes
# Mathematica, 107 bytes

```
Uncompress@"1:eJxTTMoP8ixgYmAwH8TAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEpFmXY3IaiDItPqQqMiQMA+yaAoA=="

```

Try it online!

# Answer
> 4 votes
# Java (OpenJDK 8), 165 bytes

```
n->{for(int i=0;++i<566;)System.out.print(i<157?7:i>526?3:i<236|i>446||new java.math.BigInteger("vnku5g6l0zenpa1kydel5rxw162k4fk4xapa154o",36).testBit(446-i)?1:88);}

```

Try it online!

## Credits

* -10 bytes thanks to aditsu!

# Answer
> 4 votes
# C, ~~519~~ ~~427~~ ~~414~~ ~~396~~ 377 bytes

Thanks to Tas, Felix Palmen and Lynn.

```
#define p(n,l)for(i=40*l;i;)putchar(--i%40?n+48:10);
f(i){p(7,4)p(1,2)puts("188888888118888888811188888811188888811\n188111118818811111881881111881881111881\n188111118818811111881881111111881111111\n188888888118888888811881111111881118888\n188111111118811111111881111111881111881\n188111111118811111111881111881881111881\n188111111118811111111188888811188888811");p(1,2)p(3,1)}

```

For your interest, here is a longer, easier-to-read version:

```
#define p(n,l) for(i=40*l;i;) putchar(--i%40?n+48:10);
f(i) {
    p(7,4)
    p(1,2)
    puts("188888888118888888811188888811188888811\n\
       188111118818811111881881111881881111881\n\
       188111118818811111881881111111881111111\n\
       188888888118888888811881111111881118888\n\
       188111111118811111111881111111881111881\n\
       188111111118811111111881111881881111881\n\
       188111111118811111111188888811188888811");
    p(1,2)
    p(3,1)
}

```

# Answer
> 3 votes
# Javascript (ES6), ~~187~~ 181 bytes

-6 bytes thanks to @JustinMariner

```
r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)

```

Super simple approach; it could probably be golfed some more.

**Explanation**

```
r=s=>s[0].repeat(39),                               // helper function to repeat character
a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",// Set the variables (a-k) to different
e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`               // parts of the prime

_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk" // Replace all letters in the string
    .replace(/./g,eval)                             // with the value of the variable

```

**Example code snippet** (with some helper code to add line breaks in the output)

```
r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)
o.innerText=z().replace(/.{39}/g,"$&\n")
```

```
<pre id=o>
```

# Answer
> 2 votes
# Retina, 129 bytes

```

h155b78i7b1i7b2i5b2i5b2!4!!4!""1!4!!4!!6#i7b1i7b1!6!2i3b##!6"1##""1#!8i5b2i5b79d38
#
!7
"
!3!
!
i1b
\d+
$*
+`(\D)1
$1$1
1

T`l`d

```

Try it online!

# Answer
> 2 votes
# Batch, ~~364~~ ~~335~~ 333 bytes

```
@set a=888888&set b=1111111111111&set e=1881111&set d=1%e%&set f=333333333&for /L %%x in (1,1,156) do @cd|set/p=7
@echo %b%%b%%b%%b%%b%%b%1%a%8811%a%88111%a%111%a%1%d%188%e%188%e%88%e%88%d%188%e%188%e%1%d%1111%a%8811%a%88%d%111881118888%e%11%d%11%d%1%d%88%d%11%d%11%d%88%e%88%d%11%d%11111%a%111%a%%b%%b%%b%%b%%b%%b%11%f%%f%%f%%f%333

```

# Answer
> 2 votes
# C (gcc), 269 267 bytes

function, uses simple RLE.

```
x[]={39,79,80,156};k;f(i){for(char*c="d7b1882188316831683128512811285128112841281128412821285128112851281128712881882188212871283148112881288128712841282128812881284128112841282128812891683168c1a3";i=*c++;++c)for(i=i<97?i-48:x[i-97];i--;++k%39||puts(""))putchar(*c);}

```

Try it online!

# Answer
> 2 votes
# Ruby, 109 bytes

The script calls `Zlib.inflate` to decompress the number. It needs at least Ruby 1.9.3. It contains unprintable bytes, so I can't paste it here.

I paste the output of `vis prime-inflate.rb`:

```
require'zlib'
puts Zlib.inflate DATA.read
__END__
x\M-Z37\^_\M-<\M-@\M^P\M-:\M-@\^B
\M^PY\M^F\M-X\^XP\M-U\^X,d\^F\^^e\^H3pX\M^J\M-*\^L,\M^F\M-,\^A\M^C\M^Ea)\^Ve\M-X\M-\\M^F\M-"\^L\M^KO\M-)
\M^L\M^I\^C\^@\^P\M-p~\M-!

```

If you have unvis(1), run `unvis prime-inflate.vis > prime-inflate.rb` to restore the 109-byte script. Or you can decode the Base64, below, with `ruby -e 'print *STDIN.read.unpack(?m)' < prime-inflate.b64 > prime-inflate.rb`.

```
cmVxdWlyZSd6bGliJwpwdXRzIFpsaWIuaW5mbGF0ZSBEQVRBLnJlYWQKX19F
TkRfXwp42jM3H7zAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEp
FmXY3IaiDItPqQqMiQMAEPB+oQ==

```

I call `Zlib.inflate` so I don't need to design and golf my own decompression algorithm. I use `DATA` with `__END__` because the compressed string isn't valid UTF-8. Ruby code must be valid ASCII (in Ruby 1.9.x) or UTF-8 (from Ruby 2.0) or have a magic comment `#coding:binary` to change the encoding, but Ruby doesn't check the encoding after `__END__`.

# Answer
> 2 votes
# 6502 machine code (C64), 142 122 bytes

```
00 C0 A9 27 85 FB A2 00 86 FC A2 04 CA 10 01 60 BC 70 C0 BD 74 C0 20 D2 FF C6
FB D0 0B 48 A9 27 85 FB A9 0D 20 D2 FF 68 88 D0 EB E0 02 D0 DD 48 A5 FC 4A A8
B9 4A C0 90 04 4A 4A 4A 4A 29 0F F0 08 E6 FC A8 68 49 09 D0 CD 68 D0 C0 28 38
36 36 52 12 52 12 42 12 42 22 52 12 52 12 72 82 28 28 72 32 14 82 82 72 42 22
82 82 42 12 42 22 82 92 36 06 27 50 4F 9C 33 31 31 37

```

**Online demo**

**Usage:** `sys49152`

* -20 bytes with better implementation of same method and data tables for large blocks as well.

---

### Explanation

This also uses the lengths of the `1` and `8` sequences in the middle part; as they're all shorter than 16, two of them are encoded per byte.

Commented disassembly listing:

```
         00 C0        .WORD $C000       ; load address
.C:c000  A9 27        LDA #$27          ; counter for newlines (39)
.C:c002  85 FB        STA $FB
.C:c004  A2 00        LDX #$00          ; index for run-length data
.C:c006  86 FC        STX $FC
.C:c008  A2 04        LDX #$04          ; index for "blocks" (counting down)
.C:c00a   .blockloop:
.C:c00a  CA           DEX
.C:c00b  10 01        BPL .continue     ; block index underflow -> done
.C:c00d  60           RTS
.C:c00e   .continue:
.C:c00e  BC 70 C0     LDY .lseqlens,X   ; load length of next block to Y
.C:c011  BD 74 C0     LDA .chars,X      ; load character of next block to A
.C:c014   .outloop:
.C:c014  20 D2 FF     JSR $FFD2         ; output character
.C:c017  C6 FB        DEC $FB           ; decrement newline counter
.C:c019  D0 0B        BNE .skipnl
.C:c01b  48           PHA               ; newline needed -> save accu
.C:c01c  A9 27        LDA #$27          ; restore newline counter
.C:c01e  85 FB        STA $FB
.C:c020  A9 0D        LDA #$0D          ; load newline character
.C:c022  20 D2 FF     JSR $FFD2         ; output character
.C:c025  68           PLA               ; restore accu
.C:c026   .skipnl:
.C:c026  88           DEY               ; decrement repeat counter
.C:c027  D0 EB        BNE .outloop      ; repeat until 0
.C:c029  E0 02        CPX #$02          ; check for block index of text part
.C:c02b  D0 DD        BNE .blockloop    ; not in text part -> repeat
.C:c02d   .textpart:
.C:c02d  48           PHA               ; save accu
.C:c02e  A5 FC        LDA $FC           ; load index for run-length data
.C:c030  4A           LSR A             ; and shift right
.C:c031  A8           TAY               ; -> to Y register
.C:c032  B9 4A C0     LDA .seqlens,Y    ; load run-length data
.C:c035  90 04        BCC .lownibble    ; carry clear from shift -> low nibble
.C:c037  4A           LSR A             ; shift high nibble into low nibble
.C:c038  4A           LSR A
.C:c039  4A           LSR A
.C:c03a  4A           LSR A
.C:c03b   .lownibble:
.C:c03b  29 0F        AND #$0F          ; mask low nibble
.C:c03d  F0 08        BEQ .textdone     ; run-length zero? then text block done
.C:c03f  E6 FC        INC $FC           ; increment index for run-length data
.C:c041  A8           TAY               ; run-length to y-register
.C:c042  68           PLA               ; restore accu
.C:c043  49 09        EOR #$09          ; toggle between '8' and '1'
.C:c045  D0 CD        BNE .outloop      ; and back to output loop
.C:c047   .textdone:
.C:c047  68           PLA               ; restore accu
.C:c048  D0 C0        BNE .blockloop    ; back to loop for next block
.C:c04a   .seqlens:
.C:c04a  28 38 36 36  .BYTE $28,$38,$36,$36
.C:c04e  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c052  42 12 42 22  .BYTE $42,$12,$42,$22
.C:c056  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c05a  72 82 28 28  .BYTE $52,$82,$28,$28
.C:c05e  72 32 14 82  .BYTE $72,$32,$14,$82
.C:c062  82 72 42 22  .BYTE $82,$72,$42,$22
.C:c066  82 82 42 12  .BYTE $82,$82,$42,$12
.C:c06a  42 22 82 92  .BYTE $42,$22,$82,$92
.C:c06e  36 06        .BYTE $36,$06
.C:c070   .lseqlens:
.C:c070  27 50 4F 9C  .BYTE $27,$50,$4F,$9C
.C:c074   .chars:
.C:c074  33 31 31 37  .BYTE "3117"

```

# Answer
> 2 votes
# Python 2, 112 bytes

```
print'7'*156+'1'*78+bin(int('JAOKI5B0O6K9IWDU8P76KDLR0VZMNWQ2WB9D8BOS8',36))[2:].replace('0','88')+'1'*80+'3'*39

```

Try it online!

# Answer
> 2 votes
# C (gcc), 224 bytes

```
f(i,j,c){for(i=0;c="wwdfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD"[i/2]>>i++%2*4&15;c-6?putchar(c-4?c+48:49):printf("88"))for(j=0;j++<c%2*38;)putchar(c+48);}

```

Try it online!

Contains some unprintables, the string literal is `"ww\x11dfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD\x11\x03"`.

# Answer
> 2 votes
# x86-16 machine code, IBM PC DOS, ~~117~~ ~~108~~ 107 bytes

Binary:

```
00000000: be14 01b1 53ac d404 bb67 01d7 cd29 fecc  ....S....g...)..
00000010: 75fa e2f1 c3ff b7fd 4122 0922 0d1a 0d1a  u.......A"."....
00000020: 0d0a 150a 050a 150a 050a 110a 050a 110a  ................
00000030: 090a 150a 050a 150a 050a 1d0a 2122 0922  ............!"."
00000040: 090a 1d0a 0d12 050a 210a 210a 1d0a 110a  ........!.!.....
00000050: 090a 210a 210a 110a 050a 110a 090a 210a  ..!.!.........!.
00000060: 251a 0d1a fd45 9c33 3138 37              %....E.3187

```

Listing:

```
BE 011E         MOV  SI, OFFSET DAT     ; RLE table
BB 0171         MOV  BX, OFFSET CHR     ; character table
B1 53           MOV  CL, 83             ; data length
            BYTE_LOOP:
AC              LODSB                   ; AL = byte
D4 04           AAM  4                  ; Unpack AL = char index, AH = run length
D7              XLAT                    ; AL = ASCII char
            RLE_LOOP:
CD 29           INT  29H                ; write char to console
FE CC           DEC  AH                 ; decrement length counter
75 FA           JNZ  RLE_LOOP           ; loop until end of run
E2 EC           LOOP BYTE_LOOP          ; loop until end of bytes
            DAT:
C3              RET                     ; return to DOS (and first byte of DAT)
                DB  0FFH,0B7H,0FDH,41H,22H,09H,22H,0DH,1AH,0DH
                DB  1AH,0DH,0AH,15H,0AH,05H,0AH,15H,0AH,05H,0AH,11H
                DB  0AH,05H,0AH,11H,0AH,09H,0AH,15H,0AH,05H,0AH,15H
                DB  0AH,05H,0AH,1DH,0AH,21H,22H,09H,22H,09H,0AH,1DH
                DB  0AH,0DH,12H,05H,0AH,21H,0AH,21H,0AH,1DH,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,21H,0AH,11H,0AH,05H,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,25H,1AH,0DH,1AH,0FDH,45H,9CH
            CHR:
                DB  '3','8','1','7'

```

Uses a form of RLE to encode the lengths for each run of numbers. Since there's only four possible numbers, these are encoded using 2 bits of each byte and the remaining 6 bits for the length of the run. This compresses the 624 byte input down to 83. For example:

```
Run       Len    Num   Hex
888888 -> 000110 10  = 0x1A
777    -> 000011 00  = 0x0C
1111   -> 000100 01  = 0x11

```

A standalone PC DOS executable COM program. Output to console (in delightful MDA amber today):

Or formatted with line breaks:

*-8 bytes thanks to @gastropner for the excellent idea to use `AAM` to unpack the byte instead of bit shifting!*

*-1 byte thanks to @gastropner adjusting data to start with a `0xC3` (`RET` opcode)!*

# Answer
> 2 votes
# , ~~178~~ 165 bytes

*-10 bytes thanks to Dominic van Essen*

```
`?`=c
w=8?2?8?2
x=5?2?1?2
y=2?4?2?2?2
z=4?2?1?y
cat(rep(7?0:76%%2*7+1?3,156?79?8?2?8?3?6?3?6?3?2?x?x?z?x?x?7?2?8?w?2?7?2?3?4?1?2?w?7?y?w?z?8?2?9?6?3?6?80?39),sep="")

```

Try it online!

A run-length-decoding solution with a few optimizations thanks to this tip.

# Answer
> 2 votes
# JavaScript (ES6), 183 bytes (possibly 182?)

```
x=>"7"[r="repeat"](156)+(o="1"[r](78))+"...".replace(/./g,x=>x.charCodeAt().toString(2).padStart(8,0).replace(/0/g,8))+1+o+"3"[r](39)

```

Where `...` is a string of 34 characters. Many of these are ASCII control characters or weird possibly invalid ones like `0x80`, but if I save it to a file on my laptop it will produce the correct output (with a `console.log` of course). Oddly it seems to work with a raw null byte too, but as I'm not sure if I'm right about that I've just used a `\0`. The string looks something like:

```
"\x80`\x1C\x0E\x07>O\x93Éæ|\x9F'óü\x03\x00Ïç\tþ\x7F\x9FÏ3üÿ<\x9Egùÿ\x03\x81"

```

For now this is a 1-2 bytes behind the current answer (was ahead until I remembered to add `x=>` \>:|), but I worked pretty hard on it and I'm sure it's possible to find a couple of bytes to golf somewhere.

# Answer
> 1 votes
# Jelly, 86 bytes

```
Lẋ@1,8żḣLẋ/€F
7ẋ156;1ẋ78¤©;“½Ẹ^o“2FẒ⁶ġbȥ“¡E⁷£cṿ“t¡ɗḋ“£F¢Xȥ“¡McṾbȥ“¬3Ṭo’DÇ€F¤;®;3rẋ39¤Ḍ

```

Try it online!

-12 bytes thanks to user202729

# Answer
> 1 votes
# Python 2, ~~309~~ ~~158~~ ~~155~~ ~~136~~ 135 bytes

```
x='1'*78
s='7'*156+x
a=1
for c in str(int('109PDKEZ3U32K97KJQVELW8GKXCD42EGEYK715B6HPMPL0H8RU',36)):s+=`a`*int(c);a^=9
print s+x+'3'*39

```

Try it online!

# Python 2, 137 bytes

```
s='7'*156
a=1
for c in'90'*8+str(int('PL6PU5TXIC24LCKIQY50C2LPAIC9TVZEVQGTMM63IHGBBUV1XSA6',36))+'09'*8:s+=`a`*int(c);a^=9
print s+'3'*39

```

Try it online!

# Answer
> 1 votes
# Jelly, 85 bytes

```
”7ẋ“ɓ’80“¡Ȯ⁶LÑɓĠ⁶-€Øġ°$¤ṛọḳƓƒṭ⁽@^ḥ⁷Ofạ<e½Ṇż;,RṘ¶ṀḊ+`⁸ⱮḃĿþṛ9.wƑ¡kḟUẎgLLµ’ḃĖŒṙị⁾1839”3ẋ

```

Try it online!

Based on Dennis's approach to the Trinity Hall challenge, minus the symmetry, plus the leading `7`s and trailing `3`s.

# Answer
> 1 votes
# PowerShell, 164 bytes

```
$a='136361616151315131531532513151315215436365213213315454521532545453153254541616';6..2|%{$a=$a-replace$_,(11,88,22,34,3332)[$_-2]};'7'*156+'1'*78+$a+'1'*78+'3'*39

```

Try it online!

String multiplication, concatenation, and replacements. PowerShell doesn't have base 36 or similar, so large-number compression options are limited. There might be a better way to "compress" the middle part -- I'm still checking on that.

# Answer
> 1 votes
# Wolfram Language (Mathematica), 89 (17+71+1) bytes

First you export the number to a GZIP file. This file, named "o" with no extension will be exactly 71 bytes, which counts towards the total. By default, it will go to your `$TemporaryDirectory`. Omitting digits for readability.

```
Export["o",777777...,"GZIP"]

```

Then

```
"o"~Import~"GZIP"

```

will reconstruct the number. The file name is one byte so that's where the +1 comes from.

Try it online!

# Answer
> 1 votes
# C (gcc), ~~188~~ ~~187~~ ~~185~~ ~~181~~ ~~176~~ 156 bytes

-1 thanks to JonathanFrech.

-2 -4 thanks to ceilingcat.

```
x;r(d,n){for(;n--;)printf("%d",d);}f(i){r(7,156);r(1,79);for(i=38;i--;r(1,x%10))x="PS10*,),00*,/00=+/ff0/)-)-*,),)-)-SSgf"[i]-20,r(8,x/10);r(1,80);r(3,39);}

```

Try it online!

# Answer
> 1 votes
# Befunge-93, 500 bytes

```
v F         >20g1-20p
>"3"20g10g`#^_>52*"F"20p30g10g`#v_"^!1"21p30p84*2+1p
^                       p03-1g03<
^>"81118888888811888888881>!"30p84*2+1p52*
^^"8888811188888811"*25"188111118"<>">#7"21p30p57*5p
>*"188111188188111188188111118818"^ $>:#,_@
^25"18811111881881111188188111111"<
>"8888811888888881"25*"1111111881"^
^"88811881111111881118888"*25"188"<
>"1188111111188111111118811111111"^
^"11881"*52"188111111118811111111"<
>"11111881"52*"188111188188111188"^
^"1118811111111188888811188888811"<

```

Try it online!

# Answer
> 1 votes
# Knight, 113 bytes

```
;=s*"1"311;=p;=l',kr`\J&J&A&A/J&J&\kke\:8ee\A/eeA&A/er`'76;Wl=sSs=p+p/=t-Al;=lSlF1""9 9F*"8"%t 9O++*"7"156s*"3"39

```

Try it online!

This one was fun to golf. Not sure if it is *optimal*, but cool nonetheless. Came up with it myself, I see others had similar ideas.

One challenge in Knight is that only printable ASCII, tab, newline, and CR is allowed. All other characters are UB (although generally supported).

So basically, this uses a lookup table containing indices of `8`s and the length.

It is specifically encoded as \\$9 + \text{len} + 9 \times \Delta\text{pos}\\$.

Specifically, it was generated by this C program (string literal snipped)

```
#include <stdio.h>
#include <string.h>
int main()
{
    // the range containing all the 8s
    char str[] = "8888888811888888...*snip*";
    char acc[40] = {0};
    // Start at -3 to make our first index in ASCII range. We start at 79, so this is free.
    int pos = -3, i = 0;
    // loop through all the 8s using a strtok loop
    for (const char *s = strtok(str, "1"); s != NULL; s = strtok(NULL,"1"))
    {
        // 9 + len + 9 * offset from last index
        acc[i] += strlen(s) + 9;
        acc[i++] += (s - str - pos) * 9;
        // update position
        pos = s - str;
    }
    // print
    puts(acc);
}

```

So, with that out of the way, here is the program ungolfed:

```
# Create the base string with all 1's
# This is string repetition, not arithmetic.
; = str * "1" 311
# Position to start inserting.
# The first 8 is at index 79, but we start early to make
# the first character in the LUT in ASCII range.
; = pos 76
# magic lookup table
; = lut ',kr`\J&J&A&A/J&J&\kke\:8ee\A/eeA&A/er`'
# For all chars in lut
; WHILE lut {
    # Get codepoint of the front of lut and subtract 9
    ; = chr - ASCII(lut) 9
    # Pop first char from lut
    ; = lut SUBSTITUTE(lut 0 1 "")
    # Extract delta and length
    ; = delta / chr 9
    ; = length % chr 9
    # Advance position
    ; = pos + pos delta
    # Inject <length> 8's into str
    : = str SUBSTITUTE(str pos 0 (* "8" length))
}
# Add leading 7's and trailing 3's
; = str + (* "7" 156) str
; = str + str (* "3" 39)
# print
: OUTPUT(str)

```

# Answer
> 1 votes
# Scratch, 396 bytes

Try it online!

There's probably room for optimization.

```
define(n)(t
repeat(t
set[P v]to(join(P)(n
when gf clicked
set[P v]to(
[7][156
[1][78
[1888888881][2
[1][2
[888888111][2
repeat(2
[8][2
[1][5
[881][1
end
repeat (2
[8][2
[1][4
[881][1
end
[1][1
repeat(2
[8][2
[1][5
[881][1
end
[881111111][2
[1888888881][2
[188][1
[1][7
[8811188881][1
[8][2
[1111111188][2
[1][7
[8811118811][1
[8811111111][2
[881111881][2
[1881111111][2
[118888881][2
[1][79
[3][39

```

# Answer
> 1 votes
# Vyxal `s`, 66 bytes

```
7113Sf»«u2F»S4/⌊*2 18f38ẋf».⟩o2d≥s¾T¢(₀P⟇iŀ₍#(⇩t⁽ ≠ṗ²½u&⁼∑H»fZødṅṀ

```

Try it online!

# Answer
> 0 votes
# Python 2, ~~244~~ ~~128~~ 120 bytes

*-8 bytes thanks to @JonathanFrech*

```
s='1'*78
print'7'*156+s+bin(int("8zlghh9gqo74zwzntkcjmoou35vvlbg1cmasrm6ny1iafcvw568sj",36))[2:].replace(*'08')+s+'3'*39

```

Try it online!

# Answer
> 0 votes
# ///, 180 bytes

```
/~/\/\///P/IH~O/1G~N/1J~M/AA~L/77~J/IB~I/88~H/11~A/LLLLLL~B/HHH1~C/333333333~D/BB~E/III~F/H1I~G/F1/MMMMMMADDDDDBHEPEP1EH1EGOPGIOIO1PGPGJJ1EPEPJIFINNNIONN1IOIONNHEH1EDDDDDBH1CCCC333

```

Try it online!

# Answer
> 0 votes
# FEU, 178 bytes

```
a/lllmtwrzxyzrrszwqqwqqwzqwzxzwqqwqqwszvyzxyzxzwszszzqvzvzwszwzxzvzvzwzqwzxzvzv1yrtvooop
m/l/mmmm/m/nnn/n/7777/o/pppp/p/333/q/1z/r/sy/s/x1/t/uuu/u/vvv/v/ww/w/xx/x/11/y/zzz/z/88/g

```

Try it online!

Compression. My compression testing wasn't very rigorous, so this might be able to be optimized.

# Answer
> 0 votes
# brainfuck, ~~531~~ 503 bytes

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

```

Try it online!

# Answer
> 0 votes
# 05AB1E, 148 bytes

```
•d•Å3•Θ•Å1ì•2œP²IM›BŽт›ÖΛZY
‰ øÕŒQÉΓΩr‡'?₁0rºн∊÷ζì‰ÉöΘ…çнEîx5›иñÄÂ½ü’üΔιàòEγ®é∍NaV†Sƒ¯%à˜PÝ™₆·à≠ø€ćËÙzLtp:Ö†p\nJ$gāböò_¿®₂@h”•rª•Δ•Å1ìƵtÅ7ì»¶õ.:ðõ.:

```

Try it online!

## Explanation

```
•d•Å3•Θ•Å1ì•...•rª•Δ•Å1ìƵtÅ7ì»¶õ.:ðõ.:
•d•Å3                                  push 39 "3"s
     •Θ•Å1                             push 80 "1"s
          ì                            merge lists
           •...•                       compressed number containing the "1"s and "8"s (probably could be shortened)
                r                      reverse stack
                 ª                     append
                  •Δ•Å1                push 79 "1"s
                       ì               merge everything
                        »              convert list to newline separated string
                          ¶õ.:         replace newlines with nothing
                              ðõ.:     replace spaces with nothing
                                       (implicit print)

```

Definitely can be golfed...

---
Tags: code-golf, kolmogorov-complexity, primes
---