title: Implement Entombed's lookup table

text:
# Question
Title: Implement Entombed's lookup table
## Background

Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research — despite the strict hardware limitations of the Atari 2600, it somehow manages to create solvable mazes every time. By disassembling the game's ROM, researchers discovered that this is done with the help of a mysterious lookup table.

When a tile **X** is to be generated, the game first looks at the states of 5 tiles **A**, **B**, **C**, **D**, and **E** which are around it:

$$ \bbox\[5px, border: 1px solid white\]{\color{white}{\mathsf{x}}} \bbox\[6px, border: 1px solid black\]{\mathtt{C}}\\, \bbox\[6px, border: 1px solid black\]{\mathtt{D}}\\, \bbox\[6px, border: 1px solid black\]{\mathtt{E}}\\ \\; \bbox\[6px, border: 1px solid black\]{\mathtt{A}}\\, \bbox\[6px, border: 1px solid black\]{\mathtt{B}}\\, \bbox\[6px, border: 1px solid white\]{{\mathtt{X}}}\\, \bbox\[10px, border: 1px solid white\]{\color{white}{\mathsf{x}}}\\, $$

These five values then index into the following 32-byte lookup table to determine what should appear at **X** — a wall, an empty space, or either a wall **or** an empty space, chosen at random:

```
A B C D E    X
0 0 0 0 0    1
0 0 0 0 1    1
0 0 0 1 0    1
0 0 0 1 1    R
0 0 1 0 0    0
0 0 1 0 1    0
0 0 1 1 0    R
0 0 1 1 1    R
0 1 0 0 0    1
0 1 0 0 1    1
0 1 0 1 0    1
0 1 0 1 1    1
0 1 1 0 0    R
0 1 1 0 1    0
0 1 1 1 0    0
0 1 1 1 1    0
1 0 0 0 0    1
1 0 0 0 1    1
1 0 0 1 0    1
1 0 0 1 1    R
1 0 1 0 0    0
1 0 1 0 1    0
1 0 1 1 0    0
1 0 1 1 1    0
1 1 0 0 0    R
1 1 0 0 1    0
1 1 0 1 0    1
1 1 0 1 1    R
1 1 1 0 0    R
1 1 1 0 1    0
1 1 1 1 0    0
1 1 1 1 1    0

```

Here **R** represents a value to be chosen randomly.

## Task

Given values for **A**, **B**, **C**, **D**, and **E** as input, your program or function should output the correct value for **X** (either 0 or 1, depending on which row of the table the input corresponds to). **However**, if the input corresponds to a row in the table with an **X** value of **R**, your program should output either 0 or 1 uniformly randomly.

## Rules

* This is , so shortest answer in bytes wins.
* Your input can be given in any reasonable format, e.g. a list of values, a string with the values in it, an integer in the range \[0..31\], etc.
* When receiving input that corresponds to an **X** value of **R** in the table, your output has to be non-deterministic.

# Answer
# Jelly, ~~21~~ ~~19~~ 15 bytes

```
ị“£ṅ@kṃżF’b3¤BX

```

Try it online!

-4 bytes after inspiration from @Neil's Charcoal Answer (binary!).

Try all testcases listed out in a grid (each row is one input tested multiple times).

### How?

```
ị“£ṅ@kṃżF’b3¤BX     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0,1]
                          # (2 => R; 1 => 1; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             B            # convert to binary: 2 => [0,1], 1 => [1], 0 => [0]
              X           # Pick a random element from that list

```

---

## 19 byte version

(I personally like this one more because it uses special properties of  and `X`)

Try it online!

Try all testcases.

```
ị“©½B.ọṅc’b3¤Hị1,0X     # Main link
 “©½B.ọṅc’                # The integer 1719989029560350
          b3              # to base 3: [2,2,1,0,0,1,1,2,2,2,2,1,0,0,0,2,2,2,1,0,0,0,0,1,0,2,1,1,0,0,0,2]
                          # (2 => 1; 1 => R; 0 => 0)
ị           ¤             # Index the input into the base 3 list above
                            # (1-indexed, and 0 gives the last element)
             H            # Halve: [2,1,0] => [1,0.5,0]
              ị1,0        # Index into 1,0 (again 1-indexed)
                            # 1 gives 1, and 0 gives 0
                            # 0.5 gives [0,1]; since it is a fractional index, it gives both the element corresponding to floor(0.5) and ceil(0.5)
                  X       # Random; 3 different functions
                            # 0 => 0
                            # 1 => random integer from 1 to 1 => 1
                            # [0,1] => random element of [0,1]

```
> 13 votes

# Answer
# JavaScript (ES6), 47 bytes

Expects an integer in \\$\[0..31\]\\$ as input.

Similar to @histocrat's Ruby answer, except that the \\$\text{R}\\$-mask is left-shifted by 1 position so that we can directly get \\$0\\$ or \\$2\\$.

```
n=>Math.random()*(975060894>>n&2)|67571463>>n&1

```

Try it online!

---

# JavaScript (ES6),  ~~58 56~~  49 bytes

Expects an integer in \\$\[0..31\]\\$ as input.

```
n=>(Math.random(k=n*5%62%46%18)*2|k<11)&253553>>k

```

Try it online!

### How?

The input \\$n\\$ is turned into an index \\$k \in\[0..17\]\\$ with the following formula:

$$\big(((n\times 5)\bmod 62)\bmod 46\big)\bmod 18$$

In addition to reducing the size of the lookup table, it isolates all \\$\text{R}\\$ values at the end of the table, with an index greater than \\$10\\$.

As a string, the lookup table looks as follows:

```
10001110011RR0RRRR

```

Therefore, we can use a bitmask to determine if the answer is either \\$0\\$ or something else, and the test \\$k\<11\\$ to decide between \\$1\\$ and \\$\text{R}\\$.

```
  n | * 5 | mod 62 | mod 46 | mod 18 | output
----+-----+--------+--------+--------+--------
  0 |   0 |    0   |    0   |    0   |   1
  1 |   5 |    5   |    5   |    5   |   1
  2 |  10 |   10   |   10   |   10   |   1
  3 |  15 |   15   |   15   |   15   |   R
  4 |  20 |   20   |   20   |    2   |   0
  5 |  25 |   25   |   25   |    7   |   0
  6 |  30 |   30   |   30   |   12   |   R
  7 |  35 |   35   |   35   |   17   |   R
  8 |  40 |   40   |   40   |    4   |   1
  9 |  45 |   45   |   45   |    9   |   1
 10 |  50 |   50   |    4   |    4   |   1
 11 |  55 |   55   |    9   |    9   |   1
 12 |  60 |   60   |   14   |   14   |   R
 13 |  65 |    3   |    3   |    3   |   0
 14 |  70 |    8   |    8   |    8   |   0
 15 |  75 |   13   |   13   |   13   |   0
 16 |  80 |   18   |   18   |    0   |   1
 17 |  85 |   23   |   23   |    5   |   1
 18 |  90 |   28   |   28   |   10   |   1
 19 |  95 |   33   |   33   |   15   |   R
 20 | 100 |   38   |   38   |    2   |   0
 21 | 105 |   43   |   43   |    7   |   0
 22 | 110 |   48   |    2   |    2   |   0
 23 | 115 |   53   |    7   |    7   |   0
 24 | 120 |   58   |   12   |   12   |   R
 25 | 125 |    1   |    1   |    1   |   0
 26 | 130 |    6   |    6   |    6   |   1
 27 | 135 |   11   |   11   |   11   |   R
 28 | 140 |   16   |   16   |   16   |   R
 29 | 145 |   21   |   21   |    3   |   0
 30 | 150 |   26   |   26   |    8   |   0
 31 | 155 |   31   |   31   |   13   |   0

```
> 12 votes

# Answer
# Ruby, 35 bytes

```
->i{[67571463,487530447].sample[i]}

```

Try it online!

There are 128 different pairs of numbers such that the nth bit is 0 for both when the table's value is 0, 1 for both when the table's value is 1, and different when the table's value is R. So we just choose one of the two at random and take the nth bit.

It seems very likely there's a way to compress this array since we have 128 pairs to choose from, but some quick searching didn't turn it up.
> 9 votes

# Answer
# , ~~30~~ 28 bytes

Takes in an integer.

```
>.@?@{&(36bkmh2k8esv#:~32#3)

```

Try it online! Apparently TIO resets J's random seed every session. If you run it locally, the results of **R** will change.

### How it works

```
>.@?@{&(36bkmh2k8esv#:~32#3)
        36bkmh2k8esv         base 36 representation of the table
                               with 0 and 1 swapped
                    #:~32#3  back to base 3 (there is usually the
                               shorter 3#.inv, but that would drop the
                               leading 0's.)
     {                       get the corresponding entry
   ?                         roll: 1 -> 0
                                   2 -> 0 or 1
                                   0 -> open interval (0,1)
>.                           round up the floats from 0.… to 1

```
> 5 votes

# Answer
# Charcoal, ~~20~~ 19 bytes

```
‽⍘Ｉ§”)∨‴)Ｃ]!P"”↨²Ｓ²

```

Try it online! Link is to verbose version of code. Takes input as a string of five bits. Explanation:

```
    ”...”       Compressed string
   §            Indexed by
           Ｓ    Input string
         ↨²     Converted from base 2
  Ｉ             Cast to integer
 ⍘          ²   Converted to base 2
‽               Random element
                Implicitly print

```

The compressed string contains `2` where either `0` or `1` is allowed. This converts to base two as `10` thus giving the randomisation operator a choice.
> 5 votes

# Answer
# Python 3, 66 bytes

```
lambda n:randint(67571463>>n&1,487530447>>n&1)
from random import*

```

Try it online!
> 4 votes

# Answer
# Retina, 55 bytes

```
~`.+
K`111R00RR1111R000111R0000R01RR000¶$&L`.
R
10
@L`.

```

Try it online! Link includes test cases. Explanation:

```
.+
K`111R00RR1111R000111R0000R01RR000¶$&L`.

```

Replace the input by Retina code that takes the `n`th character of the lookup table.

```
~`

```

Evaluate that code.

```
R
10

```

Change `R` to `10`.

```
@L`.

```

Output a random character.
> 3 votes

# Answer
# Excel, ~~63 56~~ 55 bytes

Cell `A1` (33 bytes):

```
=MID(BASE(940349744638137,3),A2,1

```

Cell `B1` (Output Cell, 22 bytes):

```
=--IF(A1-2,A1,.5<RAND(

```

*-8 thanks to @Calculuswhiz*

Input goes into cell `A2`. Input is 1 indexed rather than 0 indexed, and needs to be in the range \\$\[1, 32\]\\$

## But How?

Well, lets first look at cell `A1`. This is where the row lookup is performed.

```
     BASE(940349744638137,3)        | Produces the number 11120022111120001112000020122000
=MID(                       ,A2,1   | Indexes that number at the position in A2 (input)

```

Then, we go to cell `B1` (the output cell). This is where we check if we need to pick a random number.

```
    IF(A1-2,                | Coerce A1 to Number and subtract 2 from it.
            A1,             | If A1 isn't 2, condition is nonzero->TRUE. Set to A1.
               .5<RAND(     | Otherwise, pick FALSE or TRUE at random
=--                         | Coerce Boolean to Number, or do nothing to Number

```

## Where's the Closing Brackets?!?

Not needed. That's where. ;P
> 3 votes

# Answer
# 05AB1E, 15 bytes

```
•3-aáδÜ[•3вbIèΩ

```

Input as an integer in the range \\$\[0,31\]\\$.

Try it online or verify all test cases.

**Explanation:**

```
•3-aáδÜ[•  # Push compressed integer 940349744638137
 3в        # Convert it to base-3 as list:
           #  [1,1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0]
   b       # Take the binary string of each, converting the 2s to 10s:
           #  [1,1,1,10,0,0,10,10,1,1,1,1,10,0,0,0,1,1,1,10,0,0,0,0,10,0,1,10,10,0,0,0]
    Iè     # Index the input-integer into this list
      Ω    # And pop and push a random digit of this integer
           # (after which it is output implicitly as result)

```

See this 05AB1E tip of mine (sections *How to compress large integers?* and *How to compress integer lists?*) to understand why `•3-aáδÜ[•` is `940349744638137` and `•3-aáδÜ[•3в` is `[1,1,1,2,0,0,2,2,1,1,1,1,2,0,0,0,1,1,1,2,0,0,0,0,2,0,1,2,2,0,0,0]`.
> 1 votes

# Answer
# C (gcc), ~~81~~ \\$\cdots\\$ ~~66~~ 52 bytes

Saved 2 bytes thanks to ceilingcat!!!

Saved a whopping 14 bytes thanks to Neil!!!

```
f(n){n=(n=0x29200950255a095l>>n*2&3)<2?n:time(0)&1;}

```

Try it online!

Inputs an integer in the range \\$\[0,31\]\\$ and returns either \\$0\\$, \\$1\\$, or one of them randomly.
Uses the bits of a `long int` to map each return value to 2-bits.
> 1 votes

# Answer
# Japt, 20 bytes

Takes input as `0-31`.

```
g`qn77sq5p`nH ì3)¤ö

```

Try it \- includes all test cases
> 1 votes

# Answer
# Vyxal `r`, 14 bytes

```
3»∧l%≥D⋎v»τiB℅

```

Try it Online!

Takes input as a number.
> 1 votes

---
Tags: code-golf, kolmogorov-complexity, random, game
---


# Question
Title: Almost Illegal Strings, Mark II (Robbers)
This is the robbers' thread for 'Almost Illegal Strings'.

See the cop's thread for information on participating. A section from the post is included here for convenience.

> ## The Robbers' Challenge
>
> Find an uncracked answer. Write a program in the language specified that contains as a contiguous substring the almost illegal string specified and does not error. Your program may not use any character in the set of banned characters, unless it is part of the almost illegal string. Your program does not need to be exactly what the cop had in mind. Post an answer to the robber's thread and leave a comment on the cops' answer to crack it.

# Answer
> 11 votes
# Python 2, 7 bytes, cracks xnor's post

```
0xbin()

```

Try it online!

The answer is easy to understand if syntax highlighting for above snippet works correctly.

So bad. The syntax highlighting *did* work correctly. But SO changed their render library... Anyway, above code is:

```
0xb in ()

```

# Answer
> 7 votes
# Haskell, doge doge's answer, 26 bytes

```
main=print()where{3
#""=3}

```

Try it online!

The idea here is that within a `{}` block whitespace rules are weakened a good deal. With that we can turn `#"` into the declaration of an infix function and write the rest of our program with no issues. From there we use `where` attached to our `main` function to start the block.

I don't really know why these blocks have weaker rules. I am just learning about this now as well. But for some reason I had a suspicion it might work and it does.

# Answer
> 7 votes
# , cracks Robin Ryder's challenge

```
try(x %'"% y,T)

```

Try it online!

The 'almost illegal' string we're trying to use is `'"`.

`try` attempts to run the code contained in its first argument. The second argument, `silent` (not explicitly named here) is set to `T`RUE to prevent output if the result is an error.

The first argument here attempts to apply the (nonexistant) `%'"%` function to (nonexistant) variables `x` and `y`.
The `%...%` notation - known as SPECIAL in  \- allows us to incorporate characters that are usually forbidden for variables and function names, like `'"` in this case.

# Answer
> 5 votes
# Jelly, 6 bytes, cracks caird coinheringaahing's

```
“

«{”

```

Try it online!

**EDIT**

I actually don't know why this works lmao

# Answer
> 4 votes
# Jelly, 6 bytes, cracks caird coinheringaahing's

```

«{0¡

```

Try it online!

Instead of string literal weirdness, this uses the fact that arity mismatches don't cause errors until things are actually evaluated--`{` doesn't try to turn a monad into a dyad so much as it calls a Python lambda assumed to have one argument from a Python lambda with two arguments, and  repeats it zero times.

# Answer
> 4 votes
# Python 3, cracks qwatry's challenge

Illegal text: `int(A,B,C)`, with all ASCII but `~+2()` and newlines banned.

```
((22+22+22+~2+2)+(22+22+22+~2+2+~2+~2+2)+(22+22+22)+(22+22+22+~2+2+~2+~2+2)+(22+22+22+2+2+~2)+(22+22+22+~2+2+~2+~2+2)+(22+22+2+2))
int(A,B,C)

```

Try it online!

Python 3 normalizes Unicode identifiers, so " " is turned into "fancy unicode".

This turns it into

```
exec(chr(22+22+22+~2+2)+chr(22+22+22+~2+2+~2+~2+2)+chr(22+22+22)+chr(22+22+22+~2+2+~2+~2+2)+chr(22+22+22+2+2+~2)+chr(22+22+22+~2+2+~2+~2+2)+chr(22+22+2+2))
print(A,B,C)

```

And when we expand the `chr` statements, we get `'A=B=C=0'`:

```
exec('A=B=C=0')
print(A,B,C)

```

And you can figure it out from there.

I would love to say I discovered it, but nah. This isn't the first time normalization memes have been posted here.

Also, I brute forced the ASCII arithmetic instead of calculating it, so it is not optimized.

# Answer
> 3 votes
# Julia, 12 bytes, cracks @binarycat's answer

```
`\?""":"`

```

Try it online!

Backticks in Julia delimit shell commands, as in Perl or Ruby. But unlike Perl or Ruby, the command isn't actually executed; rather, a `Cmd` object representing the command is created. Hence it doesn't matter that `\?""":"` isn't a valid shell command.

# Answer
> 2 votes
# Ruby, 21 bytes, cracks @dogedoge's first answer

```
%q(=end
#{"""'}
=end)

```

Try it online!

Wraps the almost illegal string in a single-quoted string (which doesn't allow interpolation).

---

# Ruby, 23 bytes, cracks @dogedoge's first and second answers

```
/#{'}=end
#{"""'}
=end/

```

Try it online!

Here's an alternative that doesn't use `%` (in response to a comment). This time we wrap in a regexp, interpolating a single quote to close the `"""'` sequence that occurs later.

---

# Ruby, 28 bytes, cracks @dogedoge's third answer

```
<<S
#{'}=end
#{/"""'}
=end
S

```

Try it online!

Now the wrapper is a here doc. This approach also works for the first two cops (which don't include the `/`).

# Answer
> 2 votes
# Julia, 12 bytes, cracks @dogedoge's answer

```
"""?"""::Any

```

Try it online!

Define a (triple-quoted) string and assert it to be of type `Any` (`String` also works).

# Answer
> 2 votes
# Desmos, 5 bytes, cracks Aiden Chow's answer

```

\{\}
```

# Answer
> 2 votes
# Rust `-Z unstable-options --pretty normal`, cracks @Deadbeef's answer

```
const x:! =1;

```

Not sure if this is the intended interpretation of "you may pass any flags to rustc if you like." or a loophole.

I could just do `--help` but this one actually parses the file and needs a *sorta* valid Rust program.

Specifically, the `--pretty` option on Nightly will just format the code instead of compiling it.

# Answer
> 2 votes
# Python 3, cracks qwatry's revised answer

```
x: 1=2

```

Try it online!

or

```
x: 1+1=2

```

Try it online!

(not entirely sure which it's supposed to be but it works either way).

I completely forgot how *flexible* type hints are until I ~~cheated~~ searched the grammar for the `=` character.

# Answer
> 2 votes
# Desmos, to crack HitchHacker's cop

There is in fact a way to crack this answer without using notes. Type the closing parenthesis `)` after the expression, then go back one character and type the closing bracket `]`. The result, `sort(3,2])`, should be interpreted as `sort([3,2])`.

# Answer
> 2 votes
# JavaScript, cracks Etheryte's answer

```
void$=Array();console.log(...void$)

```

Try it online!

This seems way too easy... Uses spread syntax `...expression` to use the elements of `void$` (initialized to `Array()`, an empty array `[]`) as separate arguments to `console.log`. Since it's empty, it uses no arguments, which is perfectly valid as well; it just calls `console.log()`.

# Answer
> 2 votes
# JavaScript, cracks Etheryte's revised answer

```
eval(...void 0||Array())

```

Try it online!

# Answer
> 2 votes
# Desmos, cracks HitchHacker's answer

```
\sort(3,2

```

Desmos programs are normally scored based on the text pasted into the textbox. Pasting in invalid-formatted text simply does nothing, which doesn't meet the error criteria of showing a "danger sign" laid out by HitchHacker. The easiest way to do this is by using a `\` before sort. Desmos doesn't recognize "sort" as an escapable sequence like `\left` or `\operatorname` or even `\sin` so it simply ignores the whole program.

# Answer
> 2 votes
# Python 3, cracks Makonede's answer

Code contains unprintable characters, so is provided as a hexdump:

```
00000000: 2300 0400 040a 3f22 2222 3f27 2727 3f    #.....?"""?'''?

```

Derived from feersum's comment on an identical Python answer to the original find an illegal string challenge. I made it slightly shorter and adjusted it to the banned characters in this challenge, but have no idea how or why this works.

Try it online!

# Answer
> 1 votes
# Desmos, cracks HitchHacker answer

The solution is in the answer, **note** is the key: instead of evaluating it as an expression the *illegal string* is put in a note ¯\\\_(ツ)\_/¯

# Answer
> 1 votes
# Python 3, cracks Makonede's challenge

```

raiser=3

```

Try it online!

Should've banned `=`...

# Answer
> 1 votes
# Python 3, cracks Makonede's second challenge

```

raise`TAB`SystemExit

```

Try it online!

I am sure this is another unintended loophole…

# Answer
> 1 votes
# Python 3, cracks Makonede's revised second challenge

```

raiser:str

```

Try it online!

Uses a type annotation. I think this is the actual solution you meant.

# Answer
> 1 votes
# Python 3, cracks qwatry's answer

```
foo1=2

```

Try it online!

The string to crack is `1=2`.

# Answer
> 1 votes
# Zsh, cracks pxeger's post, cracked after being safe.

Did I get the rules correctly?

```
a=1;: "
#include <cstdlib>
#include <iostream>

int main() {
    srand(time(NULL));
    hello();
    return rand() % 2;
}

/*
  main
  a=0
  \
  print "$((1/$a))"
*/

void hello() std::cout << "Hello, World!" << std::endl;
 "

```

Try it online!

# Answer
> 1 votes
# Vim, 6 bytes, cracks Aaron Miller's

```
<C-w>n<Esc><Esc>ZQ

```

## What it does

* Make a new window first.
* Close it by last four keys.

---

# Vim, 5 bytes, cracks Aaron Miller's

```
<C-w>n<Esc>ZQ

```

Same as above.

# Answer
> 1 votes
# Vyxal, 16 bytes, Cracks A Username's answer

```
Q
«Wi«»Wi»`Wi`Wi

```

Try it Online!

Ez. Just quit before you get to the unavoidable stuff.

---
Tags: code-challenge, restricted-source, cops-and-robbers
---


# Question
Title: Is there a language that supports Turing machines?
Is there a programming language that supports single tape Turing machines specified in some format?

I am aware multiple formats for expressing them exist, but is there a standard one using which an acceptable answer can be published on this site?

If it doesn't exist can somebody create one? Golfing Turing machines has academic relevance too.

# Answer
> 2 votes
It should be acceptable to post answers in pure turing machine code. I have seen people do this before.

Examples:

https://codegolf.stackexchange.com/a/200380/95627

Simple cat program

If anyone knows more about this, you can edit.

# Answer
> 1 votes
I’ve made one.

It’s an interpreter written in Python, so it’s not ideal for anything intensive, but the source format is fairly concise for golfing. It uses Unicode characters as tape symbols.

---
Tags: tips
---


title: Oreo? No... Lollipop, maybe?

text:
# Question
Title: Oreo? No... Lollipop, maybe?
Since 2009, Android's version code names have been confectionery-themed. Android 1.5 is Cupcake, Android 1.6 is Donut, Android 2.0 is Eclair, etc.. In fact, the version names are alphabetical!

```
C -> Cupcake
D -> Donut
E -> Eclair
F -> Froyo
G -> Gingerbread
H -> Honeycomb
I -> Ice Cream Sandwich
J -> Jellybean
K -> Kitkat
L -> Lollipop
M -> Marshmallow
N -> Nougat
O -> Oreo

```

In order:

```
Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream Sandwich, Jellybean, Kitkat, Lollipop, Marshmallow, Nougat, Oreo

```

## Challenge

Write a **program/function** that takes a letter from `C` to `O` and outputs its respective Android version code name.

### Specifications

* Standard I/O rules **apply**.
* Standard loopholes are **forbidden**.
* You can choose to either support lowercase input or uppercase input or even both.
* The output may be in title case (`Cupcake`) or completely lower case (`eclair`). `Ice cream sandwich` may be capitalized however you like. (I didn't expect it to cause so much confusion...)
* This challenge is not about finding the shortest approach in all languages, rather, it is about finding the **shortest approach in each language**.
* Your code will be **scored in bytes**, usually in the encoding UTF-8, unless specified otherwise.
* Built-in functions (Mathematica might have one :P) that compute this sequence are **allowed** but including a solution that doesn't rely on a built-in is encouraged.
* Explanations, even for "practical" languages, are **encouraged**.

### Test cases

These are uppercase and title case.

```
Input   Output

F       Froyo
I       Ice Cream Sandwich
J       Jellybean
N       Nougat
G       Gingerbread
L       Lollipop

```

In a few better formats:

```
F, I, J, N, G, L
f, i, j, n, g, l

F I J N G L
f i j n g l

```

# Answer
# Charcoal, 73 bytes

```
θ§⪪”%↖↙1¬¢/vy⁵⸿ψＪPP±≔Ｓ×5Jρνξ–Ｇu ◧；Yx³F▶ψ;εB↥:P¹N﹪J$α✂χ✳⦄⟲*±¶Sp:ς↘Ｖ◧◧”x℅θ

```

Try it online! I/O is in lower case. Based on this verbose version. Explanation:

```
                Implicitly print:
θ               Input character
                Implicitly print:
   ”...”        Long compressed string "oneycombx...xingerbread"
  ⪪            Split on
        x       The string "x"
 §              Circularly indexed by
          ℅     Character code of
           θ    Input character

```
> 14 votes

# Answer
# Bash + Core Utils ~~131~~ ~~128~~ ~~122~~ 117 bytes.

The script is encoded as Base64 because it contains special (weird) characters.

Accepts the Android codename letter **only in lowercase** as its first positional parameter. Returns the full codename **also in lowercase**.

```
CiPBUeICicG5tJ8W5a0Pc/hYuw7hkNMSIYkAPjARkdgFrdbh3NJgTmB4gRPiiQDJAaOyBH4ki14C
QDeKRNQJ8IJYER411DAnx0SO4CAKYmFzZTMyICQwfHRyICdBLVo0NwonICdhLXoKICd8Z3JlcCBe
JDEK

```

---

### Explanation:

```
#�Q��������s�X����!�>0�������`N`x������~$�^@7�D�    ��X5�0'�D��
base32 $0|tr 'A-Z47
' 'a-z
 '|grep ^$1

```
* The first two lines are the binary blob with the data (see a the end of the answer for more information). The first line is empty, to avoid problems with Bash, as otherwise it may think that is being fed with a binary file.
* `base32 $0` encodes the script contents with Base32, with the default line wrapping of 76 characters.
* `tr 'A-Z47\n' 'a-z\n '` (note that the `\n` is written as a literal newline) will lowercase the input and replace ***4***, ***7*** and `\n` by `\n`, ***space*** and ***space*** respectively.
* `grep ^$1` will output the lines matching the string provided as first argument to the script.

---

### Binary data

This octet stream was forged so it doesn't contain newlines and when it's decoded with Base32 as per RFC 4648, the resulting string is the list of Android codenames (using ***4*** as item delimiter and ***7*** to replace the *space* character). Among its peculiarities, it begins with a newline character and a hash (`#`) so it behaves as a comment and, therefore, isn't executed by the interpreter.

Also, the default line wrapping to 76 characters of this Base32 implementation helped me a byte, as I reordered the items to use the line break as one of the *Ice cream sandwich* spaces.

---

Also, and going a bit off-topic, I think that Google shouldn't ~~in~~directly advertise commercial products in the Android codenames.
> 14 votes

# Answer
# Jelly, 57 bytes

```
Oị“¡ȥọ⁴ḷæĿɱ}#n#i®ÞSỊ3ƙɼıjṁ)-⁵g7ḥjC?4ƘẠʂ+ḋ¤⁺jṣð£?v»Ḳ¤F⁾! y

```

Try it online!

-5 thanks to Jonathan Allan.
> 11 votes

# Answer
# Bash + Core Utils (Grep): 132 130 Bytes

Simple as could be

```
grep ^$1<<<'Cupcake
Donut
Eclair
Froyo
Gingerbread
Honeycomb
Ice Cream Sandwich
Jellybean
Kitkat
Lollipop
Marshmallow
Nougat
Oreo'

```
> 11 votes

# Answer
# Python 3, 139 bytes

```
lambda x:x+'upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo'.split(",")[ord(x)-67]

```

Try it online!
> 10 votes

# Answer
# C++, ~~206~~ ~~201~~ 198 bytes

*Thanks to @sergiol for helping to save 3 bytes!*

```
#import<cstdio>
void f(int l){char*w[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};printf("%c%s",l,w[l-67]);}

```

Try it online!

# C, 173 bytes

```
f(l){char*w[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};printf("%c%s",l,w[l-67]);}

```

Well, it started as C++, but now it's also valid C, and some bytes can be saved by compiling it as C.

Try it online!
> 8 votes

# Answer
# JavaScript (ES6), ~~137~~ 136 bytes

*Saved 1 byte thanks to Neil*

```
c=>'CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo'.match(c+'([a-z]| .)+')[0]

```

### Demo

```
let f =

c=>'CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo'.match(c+'([a-z]| .)+')[0]

;[...'CDEFGHIJKLMNO'].map(c => console.log(c, '->', f(c)))
```
> 7 votes

# Answer
# Japt, ~~81~~ 79 bytes

Contains a few characters that won't display here.

```
U+`Æ+tfÆ÷¯kef©fclairfê $ßdfey¬mbf ×Äm ÑØrfÁKÞ fkfo¥ipopfÂâÚaow`qf gUc

```

Test it

* 2 bytes saved thanks to Oliver.

---

## Explanation

Implicit input of uppercase character string `U`.

A compressed string (everything between the backticks) of the names, separated with an `f` and without their first letter is split (`q`) into an array on `f`.

Within that array we get the element at the index (`g`) of `U`s character code. (Yay, index wrapping!)

We append that to `U` and implicitly output the resulting string.
> 5 votes

# Answer
# Excel VBA, ~~137~~ ~~134~~ 132 Bytes

Anonymous VBE immediate window function that takes input as expected type `Variant\String` and length `1` holding a **capital** letter from cell `[A1]` and outputs to the VBE immediate window function

```
?[A1]Split("upcake onut clair royo ingerbread oneycomb ce cream sandwich ellybean itkat ollipop arshmallow ougat reo")(Asc([A1])-67)

```

-5 Bytes for changing the spaces in `ce cream sandwich` from  (char 32) to ~~(char 160)~~ \`\` (char 127) and removing comma delimiter in the `Split` function
> 5 votes

# Answer
# SOGL V0.12, 81 bytes

```
]&ŗ√‰fō¶č▓'▼$»3↕█γb└a}⅟∑─b¹¦Æ:↕┘∞½Σ#gī±⅔≡≥\3Qy-7todΥ7ā‼D←εPρρ:¬c‰ƨ}fæ²‘θ╔@ŗz,WHHw

```

Try it Here!

Explanation:

```
...‘            push "cupcake donut eclair froyo gingerbread honeycomb ice_cream_sandwich jellybean kitkat lollipop marshmallow nougat oreo"
    θ           split on spaces
     ╔@ŗ        replace underscores with spaces
        z,W     find the inputs index in the lowercase alphabet
           HH   decrease by 2
             w  get that item from the array

```

Now there is a shorter 80 byte version, but I added the +2/-2 built-ins because of this challenge :p

The compressed string is split like `"cup","cake"," donut eclair fro","yo gingerbread honeycomb ice","_","cream","_","sandwich jelly","bean kit","kat loll","i","pop marsh","mallow"," nougat oreo"` for maximum usage of english words (many weren't in SOGLs dictionary), right now I can't find any improvements.
> 4 votes

# Answer
# Cubically, ~~1047~~ ~~852~~ 830 bytes

Functions sure help golf large programs...

```
⇒+552
⇒+551
⇒+553
⇒+55
⇒/1+52
⇒/1+53
~@7+4f5=?{:5+53@:4/1f1@:5+51@:5+2/1f4@:5+3/1f2@:2/1f2@}
+5f5=?{:3/1f1@:2/1f1@:5+53@:5+3/1f1@}
+51f5=?{:5+51@+1@:5+2/1f4@:5+1/1+551@+1@}
+52f5=?{:5+1/1f1@:3/1f1@:4/1f3@:3/1f1@}
+53f5=?{:5+1/1f2@:2/1f1@:4/1f2@:2/1f2@:5+1/1f1@:5+3/1f4@:5+1/1f1@:2/1f2@:5+2/1f4@:1/1f2@}
+53=?{:3/1f1@:2/1f1@-1@:4/1f3@:5+51@:3/1f1@:1/1f1@:5+3/1f4@}
+1f6=?{:5+51@:2/1f2@:5/1+3@:4/1+52@:5+1/1f1@:2/1f2@:5+2/1+55@:1/1f1@:5/1+3@:2/1+54@:5+2/1f4@6:2/1f1@6:1/1f2@6:2/1f3@6:5+1/1f2@6:5+51@6:5/1f2@6}
+2f6=?{:2/1f2@:5+52@@:4/1f3@:5+3/1f4@:2/1f2@:5+2/1f4@:2/1f1@}
+3f6=?{:5+1/1f2@:5+3/1f1@-1@:5+2/1f4@:5+3/1f1@}
+4f6=?{:3/1f1@:5+52@@:5+1/1f2@:4/1f1@:3/1f1@:4/1f1@}
+5f6=?{:5+2/1f4@:5+1/1f1@:5+2/1f1@:5/1f2@:1/1f1@:5+2/1f4@:5+52@@:3/1f1@:2/1f3}
+51f6=?{:3/1f1@:5+53@:4/1f2@:5+2/1f4@:5+3/1f1@}
+52f6=?{:5+1/1f1@:2/1f2@:3/1f1@}

```

Try it online! This is 830 bytes in Cubically's SBCS.

* `~` reads input, `@` prints it. (This breaks when the input is invalid.)
* Each of the `+.../...+...=7?6{...}` compares the input to each ASCII value (`C`, `D`, `E`, `F`, etc) and executes the code within `{...}` if they are equal.
* Each code block (`{...}`) prints the rest of the name (the first character is already printed).

Thanks to TehPers' ASCII to Cubically translator which was very helpful.
> 4 votes

# Answer
# \>\<\>, 181 bytes

```
!vi:od5*-0$6a*@p!
v<
 v"upcake"
 v"onut"
 v"clair"
 v"royo"
 v"ingerbread"
 v"oneycomb"
 v"ce Cream Sandwich"
 v"ellybean"
 v"itkat"
 v"ollipop"
 v"arshmallow"
 v"ougat"
 v"reo"
o<>

```

Try it online!

This works by self-modifying the program to place a `<` in front of the correct name to print, the position of which is determined by the value of the inputted letter.
> 4 votes

# Answer
# Dyalog APL, ~~158~~ ~~143~~ 131 bytes

*1 byte saved thanks to @Zacharý*

*12 bytes saved thanks to @Gil*

```
{⍵,(⎕A⍳⍵)⊃','(1↓¨=⊂⊢)',,,upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo'}

```

Try it online!

**How?**

`',,,upcake...'` \- list of words

`','(1↓¨=⊂⊢)` \- split by `','`

`(⎕A⍳⍵)⊃` \- take from the place of the argument in the alphabet

`⍵,` \- and append to the letter
> 3 votes

# Answer
# C (gcc), ~~195~~ ~~192~~ 190 bytes

-2 bytes thanks to @Quentin

```
*V[]={"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo"};main(c,v)char**v;{printf("%c%s",c,V[(c=*v[1])-67]);}

```

Try it online!
> 3 votes

# Answer
# Tcl, 158 bytes

```
proc A s {puts $s[lindex {upcake onut clair royo ingerbread oneycomb "ce Cream Sandwich" ellybean itkat ollipop arshmallow ougat reo} [expr [scan $s %c]-67]]}

```

Try it online!
> 3 votes

# Answer
# EXCEL, 154 bytes

```
=A1&CHOOSE(CODE(A1)-66,"upcake","onut","clair","royo","ingerbread","oneycomb","ce Cream Sandwich","ellybean","itkat","ollipop","arshmallow","ougat","reo")

```
> 3 votes

# Answer
# Pyth, ~~117~~ 116 bytes

Port of my Python answer.

```
+Q@c"upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"\,a67C

```

**Try it here!** or **Check out the Test Suite**

# Pyth, 99 bytes (70 characters)

*-15 bytes thanks to @insert\_name\_here!*

```
+Q@c." y|çEC#nZÙ¦Y;åê½9{ü/ãÑª#¤
ØìjX\"¦Hó¤Ê#§T£®úåâ«B'3£zÞz~Ð£ë"\,a67C

```

**Try it here!**
> 2 votes

# Answer
# Gaia, 110 bytes

```
:c“reo“upcake“onut“clair“royo“ingerbread“oneycomb“ce Cream Sandwich“ellybean“itkat“ollipop“arshmallow“ougat”=+

```

Try it online!

### Explanation

```
:          Push two copies of the input
 c         Get the codepoint of the top one
  “...”    Push the list of version names without their first letters
       =   Modularly index the code point into the list
        +  Append to the input

```
> 2 votes

# Answer
# Haskell, 145 bytes

```
f c=takeWhile(/=succ c)$dropWhile(/=c)"CupcakeDonutEclairFroyoGingerbreadHoneycombIce Cream SandwichJellybeanKitkatLollipopMarshmallowNougatOreo"

```
> 2 votes

# Answer
# Java (OpenJDK 8), 128 bytes

```
c->c+"upcake#onut#clair#royo#ingerbread#oneycomb#ce Cream Sandwich#ellybean#itkat#ollipop#arshmallow#ougat#reo".split("#")[c-67]

```

Try it online!

---

# Using regexes, 149 bytes

```
s->"CupcakeDonutEclairFroyoGingerbreadHoneycombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo".replaceAll(".*?("+s+"[a-z ]+).*","$1")

```

Try it online!

* 4 bytes saved on the regex solution thanks to Kevin Cruijssen!
> 2 votes

# Answer
# Ruby, 127 bytes

```
->c{c+%w[upcake onut clair royo ingerbread oneycomb ce\ Cream\ Sandwich ellybean itkat ollipop arshmallow ougat reo][c.ord-67]}

```

Takes uppercase input. Try it online!
> 2 votes

# Answer
# , 125 bytes

```
Ccupcake
donut
eclair
froyo
gingerbread
honeycomb
ice cream sandwich
jellybean
kitkat
lollipop
marshmallow
nougat
oreoÇ^"/d

```

Try it online!
> 1 votes

# Answer
# Recursiva, ~~130 119~~ 118 bytes

```
+aYQ'upcake!onut!clair!royo!ingerbread!oneycomb!ce cream sandwich!ellybean!itkat!ollipop!arshmallow!ougat!reo''!'-Oa99

```

Try it online!
> 1 votes

# Answer
# Pyke, 117 bytes

Port of my Python answer.

```
"upcake,onut,clair,royo,ingerbread,oneycomb,ce cream sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"\,cQ.o67-@+

```

**Try it here!**

Encoded as hex codes, the new technique of golfing in Pyke, it would be **116 bytes**:

```
22 75 70 63 61 6B 65 2C 6F 6E 75 74 2C 63 6C 61 69 72 2C 72 6F 79 6F 2C 69 6E 67 65 72 62 72 65 61 64 2C 6F 6E 65 79 63 6F 6D 62 2C 63 65 20 63 72 65 61 6D 20 73 61 6E 64 77 69 63 68 2C 65 6C 6C 79 62 65 61 6E 2C 69 74 6B 61 74 2C 6F 6C 6C 69 70 6F 70 2C 61 72 73 68 6D 61 6C 6C 6F 77 2C 6F 75 67 61 74 2C 72 65 6F 22 5C 2C 63 51 EF 36 37 2D 40 2B

```

(Paste in and check `Use hex encoding?`).
> 1 votes

# Answer
# R, ~~131~~, ~~126~~, ~~123~~, ~~112~~, 178 bytes

```
grep(paste0('^',scan(,'')),c("Cupcake","Donut","Eclair","Froyo","Gingerbread","Honeycomb","Ice Cream Sandwich","Jellybean","Kitkat","Lollipop","Marshmallow","Nougat","Oreo"),v=T)

```

Thanks for @Mark for saving 5 + 8 + 3 bytes
> 1 votes

# Answer
## C#, ~~147~~ ~~136~~ 129 bytes

---

### Data

* **Input** `Char` `c` The first letter of the version name
* **Output** `String` The full name of the version

---

### Golfed

```
// Requires the input to be uppercase.
// This is the one counting for the challange
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-67];

// Optional. Requires the input to be lowercase.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-99];

// Optional. Works with both uppercase and lowercase with the additional cost of 10 bytes.
c=>c+"upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo".Split(',')[c-(c<99?67:99)];

```

---

### Ungolfed

```
c =>
    c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - 67 ];

```

---

### Ungolfed readable

```
// Takes a char
c =>
    // Appends the input letter to...
    c +

    // ... the name in the resulting index of the subtraction of the char with 67 ('C'), or with 99 ('c') for the lowercase version
    "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - 67 ];

// Takes a char
c =>
    // Appends the input letter to...
    c +

    // ... the name in the resulting index of the subtraction of the char with 67 ('C') if the char is uppercase ( 'C' == 67, 'O' == 79 )
    //    or with 99 ('c') if the char is lowercase ( 'c' == 99, 'o' == 111 )
    "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
        .Split( ',' )[ c - ( c < 99 ? 67 : 99 ) ];

```

---

### Full code

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestBench {
    public static class Program {
        private static Func<Char, String> f = c =>
            c + "upcake,onut,clair,royo,ingerbread,oneycomb,ce Cream Sandwich,ellybean,itkat,ollipop,arshmallow,ougat,reo"
                .Split( ',' )[ c - 67 ];

        static void Main( string[] args ) {
            List<Char>
                testCases = new List<Char>() {
                    'C',
                    'D',
                    'E',
                    'F',
                    'G',
                    'H',
                    'I',
                    'J',
                    'K',
                    'L',
                    'M',
                    'N',
                    'O',
                };

            foreach(Char testCase in testCases) {
                Console.WriteLine($" Input: {testCase}\nOutput: {f(testCase)}\n");
            }

            Console.ReadLine();
        }
    }
}

```

---

### Releases

* **v1.0** \- `147 bytes` \- Initial solution.
* **v1.1** \- `-11 bytes` \- *Borrowed* Olivier Grégoire's idea.
* **v1.2** \- `- 7 bytes` \- Changed the function input from explicit to implicit.

---

### Notes

* None
> 1 votes

# Answer
## R, 169 155 bytes

```
sub(paste0(".*(",scan(,""),"[^A-Z]+).*"),"\\1","CupcakeDonutEclairFroyoGingerbreadHoneycombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo")

```
> 1 votes

# Answer
# Dyalog APL, 125 bytes

```
{⍵/⍨⍞=⎕A[+\⍵∊⎕A]}'ABCupcakeDonutEclairFroyoGingerbreadHonecombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreo'

```

Try it online!

## How?

* `⍵∊⎕A`  (the long string) with 1 for capital letters, 0 for lowercase/spaces.
* `+\` Group (returning numbers) ⍵ by capital letters.
* `⎕A[...]` The capital letter signified by a number
* `⍵/⍨⍞=` The group signified by that number
* `{...}'...'` Set  to the long string
> 1 votes

# Answer
# C (gcc), 168 bytes

```
main(){puts(memchr("Cupcake\0Donut\0Eclair\0Froyo\0Gingerbread\0Honeycomb\0Ice cream sandwich\0Jellybean\0Kitkat\0Lollipop\0Marshmallow\0Nougat\0Oreo",getchar(),117));}

```

Try it online!
> 1 votes

# Answer
# PowerShell, 136 134 bytes

```
param($c)$c+('upcake0onut0clair0royo0ingerbread0oneycomb0ce cream sandwich0ellybean0itkat0ollipop0arshmallow0ougat0reo'-split0)[$c-99]

```

Try it online!

Takes a `[char]` input character, in lowercase, and outputs in lowercase.

-2 thanks to AdmBorkBork's suggestion to `-split0` instead of `-split','`.
> 1 votes

# Answer
# VBA for Word, 163 bytes

```
a=left(ActiveDocument.Range.Text,1):?a+Split("upcake onut clair royo ingerbread oneycomb ce cream sandwich ellybean itkat ollipop arshmallow ougat reo")(asc(a)-67)

```

@tisaconundrum asked for Word. The closest I can get is a port of VBA for Excel solution by @TaylorScott.
> 1 votes

# Answer
# C#, 271 characters

```
var i="Cupcake|Donut|Eclair|Froyo|Gingerbread|Honeycomb|Ice cream sandwich|Jellybean|Kitkat|Lollipop|Marshmallow|Nougat|Oreo";var s=i.Split('|');int b;var c=new char[12];for(b=0;b<12;b++){c[b]=s[b][0];}for(b=0;b<12;b++){if(Console.Read().ToString()[0]==c[b])return s[b];}

```

Accepts one character from the console input stream, then returns the correct version number. Please tell me if I've done anything wrong or omitted something that should be here, this is my first time golfing.
> 0 votes

# Answer
# SimpleTemplate, 183 bytes

This just simply checks if the first letter of the word is the same or not.
Nothing super fancy.

```
{@setl"Cupcake","Donut","Eclair","Froyo","Gingerbread","Honeycomb","Ice Cream Sandwich","Jellybean","Kitkat","Lollipop","Marshmallow","Nougat","Oreo"}{@eachl}{@ifargv.0 is_.0}{@echo_}

```

**Ungolded**:

```
{@// array with all the names}
{@set list "Cupcake", "Donut", "Eclair", "Froyo", "Gingerbread", "Honeycomb", "Ice Cream Sandwich", "Jellybean", "Kitkat", "Lollipop", "Marshmallow", "Nougat", "Oreo"}
{@each list as name}
    {@if argv.0 is name.0} {@// name.0 -> first character}
        {@echo name}
    {@/}
{@/}

```

Try it on http://sandbox.onlinephpfunctions.com/code/002cfd9c5a84546dac3a656f6011b998ccfe33af
> 0 votes

# Answer
# Cinnamon Gum, 118 bytes

Hexdump:

```
0000000: 6c0d cac9 1183 300c 05d0 5638 fd26 74cc  l.....0...V8.&t.
0000010: bed7 2084 020e b2c5 0818 c6dd 87eb 9b77  .. ............w
0000020: 80ac 93f0 a874 44e7 655d e804 15e3 1474  .....tD.e].....t
0000030: c637 bc3a 5dd0 a7d2 6bb4 a1dc d115 8317  .7.:]...k.......
0000040: ade2 b9a5 1b92 6823 bbe7 66e6 d26d 4906  ......h#..f..mI.
0000050: bae3 a766 b555 2ef4 c098 9691 177a c2dc  ...f.U.......z..
0000060: 2c4d 3ed1 0b99 631e 329b f946 6f14 5ffb  ,M>...c.2..Fo._.
0000070: 7d7c e0a1 fe07                           }|....

```

Try it online!
> 0 votes

# Answer
# PHP, 133+1 bytes

```
<?=$argn,[upcake,onut,clair,royo,ingerbread,oneycomb,"ce Cream Sandwich",ellybean,itkat,ollipop,arshmallow,ougat,reo][ord($argn)-67];

```

no TiO this time. Run as pipe with `-nR`.
> 0 votes

# Answer
# SQL, 2017, 206 bytes

Assuming a function/procedure would have to be created otherwise you can't take input.

```
CREATE PROCEDURE X(@x VARCHAR)AS SELECT*FROM STRING_SPLIT('Cupcake,Donut,Eclair,Froyo,Gingerbread,Honeycomb,Ice cream sandwich,Jellybean,Kitkat,Lollipop,Marshmallow,Nougat,Oreo',',') WHERE value like @x+'%'

```

Cannot find a place to show this version online so there's a "slightly" more version-friendly submission

# SQL, 244 bytes

```
CREATE PROCEDURE Y(@y VARCHAR,@x VARCHAR(999)='CupcakeDonutEclairFroyoGingerbreadHoneycombIce cream sandwichJellybeanKitkatLollipopMarshmallowNougatOreoP')AS SELECT STUFF(STUFF(@x,CHARINDEX(CHAR(ASCII(@y)+1),@x),999,''),1,CHARINDEX(@y,@x)-1,'')

```

Things to note, this is on a case-sensitive database therefore the delimiter could be the capital letter.

Explanation

```
Database is case-sensitive
Inner STUFF - removes everything from the the next capital letter in alphabet
Outer STUFF - removes everything before the input capital letter

```

SQL Fiddle worked example, not able to show a case sensitive database online so changed to a comma delimited list that works the same.
> 0 votes

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


title: Possible numbers on a broken screen

text:
# Question
Title: Possible numbers on a broken screen
A screen consisted of some LED segments like such:

```
 _ _    _ _ _
|_|_|..._|_|_|
|_|_|   _|_|_|

```

However, some of the LEDs are broken, and it's possible that only these are left:

```
 _ _
 _|_|
|_|_|

```

Now, you're required to output all integers possibly expressed on this screen. An integer, something matching RegEx `/^0$|^-?[1-9][0-9]*$/`, can be expressed iff each of its character can be displayed in order using the unbroken LEDs, any two characters not overlapping or touching.

Shapes of characters `0123456789-` are given below:

```
 _     _  _       _   _  _   _   _
| |,|, _|,_|,|_|,|_ ,|_ , |,|_|,|_|,_
|_| | |_  _|   |  _| |_|  | |_|  _|

```

Sample Input:

```
 _ _
 _|_|
|_|_|

```

Sample Output:

```
{-7,-1,0,1,2,3,4,5,6,7,8,9,11,21,31,71}

```

Your can take input in reasonable ways e.g. taking a repeating pattern of a good screen and treat \\$ \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \\$ as \\$\[ \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix}, \begin{matrix}|\\\|\\\end{matrix} \color{cyan}{\begin{matrix}-\\\-\\\-\\\end{matrix}}\] \\$ (cyan means broken); or maybe 5 arrays of each kinds of LEDs, etc. Your output needn't be sorted, either. Shortest code wins.

## Notes:

* A good screen actually can be \\$ \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \\$, but we'll just input it as \\$ \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \color{cyan}{\begin{matrix}-\\\-\\\-\\\end{matrix}} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \begin{matrix}-\\\-\\\-\\\end{matrix} \begin{matrix}|\\\|\\\end{matrix} \\$.
* I thought this question and the other LED one together in one question but later decided to separate.

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

Expects an array of 5-bit integers, matching the segments as described below:

Returns a set.

The code contains 3 unprintable characters, which are escaped below.

```
f=([v,...a],p,o=(s=new Set,''),P)=>1/v?f(a,v,o,Buffer("w`>|i]_d\x7f}\x03\x08").map((x,i)=>(p|v%4<<5)&x^x||P>3&&x%6&&P-8|x%10||f(a,v,o+('1-'[i-10]||i),x))):o&&1/o?s.add(+o):s

```

Try it online!

(Includes some post-processing to sort the results for the sake of clarity.)

### How?

The full byte describing enabled segments is obtained by shifting the two least significant bits of the current mask `v` by 5 positions to the left and adding them to the previous mask `p`:

```
p | v % 4 << 5

```

The shapes of the digits and the minus sign are encoded as the ASCII codes of a 12-character string. Note that there are two versions of the "1" (right-aligned and left-aligned).

```
 119 |   96  | 62 | 124 | 105 | 93 | 95 | 100 | 127 | 125 |   3   | 8
-----+-------+----+-----+-----+----+----+-----+-----+-----+-------+---
   0 | 1 (a) |  2 |   3 |   4 |  5 |  6 |   7 |   8 |   9 | 1 (b) | -

(a): right-aligned
(b): left-aligned

```

The test `P > 3 && x % 6 && P - 8 | x % 10` is used to reject characters that are touching each other:

```
P > 3 &&  // 1) the previous character is not empty
          //    and is not a left-aligned "1"
x % 6 &&  // 2) the current character is not a right-aligned "1"
          //    (the only character whose encoding byte is 0 modulo 6)
P - 8 |   // 3) the previous character is not a minus sign
x % 10    //    or the current character is not a "7"
          //    (the only character whose encoding byte is 0 modulo 10)

```
> 10 votes

# Answer
# Jelly, 92 bytes

```
Ø0ṭ;ḣ2$}¥Ɲ“⁸ɠḊṭṆƙ²ġ°ɦẋ‘BḊ€¤oẠ¥€T¥ⱮịØD;”-¤©;€⁶Œp®ḟ”1pƊḟ““-7”¤i$ƝẸ$Ðḟḟ€⁶Ḣ;ḟɗ€”-ḟ““-”ḟ”0;ɗṪ$€VQ

```

Try it online!

Horribly long for a Jelly answer but I think it works! A monadic link taking a list of lists of five 0s and 1s and returning a list of integers. The footer sorts the output. 1 represents a working LED segment and 0 a non-working one. They are numbered left to right and top to bottom, so the first two integers represent the left-hand side of the display and the next three represent the three horizontal segments.
> 2 votes

# Answer
# Charcoal, ~~158~~ 138 bytes

```
⊞υ⟦θηζω⟧ＦυＦ¹¹«≔⪪§⪪”{⊟∨÷θＡ<∧mTMm⁰)¶Þ[u↘∕{‽ＵïÞ6Zξ-Φ⊟F∕↖;⁶Ｃ↑Ｈ;z⦃”⸿κ¶ε≔ΦＬζ⬤ε⬤ν№⁺ §§ιξ⁺μρπδ¿δ⊞υＥι⎇⁼³μ⁺λ§Ｉ⊖κ⁰⭆λ⎇›ξ⁺⌊δＬ§εμν »ΦＥυ⊟ι∧››ι-№Φιμ-⁼ιＩＩι

```

Try it online! Link is to verbose version of code. Too long because I'm doing string manipulation instead of bit twiddling. Explanation:

```
⊞υ⟦θηζω⟧

```

Start a breadth first search with a trial of the input and no characters so far.

```
ＦυＦ¹¹«

```

Loop over each trial and character (`-` plus `0`..`9`).

```
≔⪪§⪪”{⊟∨÷θＡ<∧mTMm⁰)¶Þ[u↘∕{‽ＵïÞ6Zξ-Φ⊟F∕↖;⁶Ｃ↑Ｈ;z⦃”⸿κ¶ε

```

Extract the display for the given character.

```
≔ΦＬζ⬤ε⬤ν№⁺ §§ιξ⁺μρπδ

```

Find whether we can place the character using the remaining segments.

```
¿δ⊞υＥι⎇⁼³μ⁺λ§Ｉ⊖κ⁰⭆λ⎇›ξ⁺⌊δＬ§εμν

```

If so then add a new trial with the adjacent segments removed.

```
»ΦＥυ⊟ι∧››ι-№Φιμ-⁼ιＩＩι

```

Only output those trials that are integers (e.g. exclude `0-0`).
> 1 votes

---
Tags: code-golf
---


title: Is this a rectangle?

text:
# Question
Title: Is this a rectangle?
# The challenge:

Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.

## Rules:

* For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are **all counted as rectangles**
* Coordinates for rectangles can be given in any order, for example this:

```
A----B
|    |
D----C

```

and this:

```
A---B
|   |
|   |
|   |
C---D

```

are both rectangles.

* Rectangles can be rotated, so they won't always be parallel to x and y axis.
* You may take input in any form you like as long as the order for each coordinate is not mixed: \[x,x,x,x,y,y,y,y\] is not acceptable, where as \[x,y,x,y,x,y,x,y\] or \[(x,y),(x,y),(x,y),(x,y)\] is fine.
* Complex numbers are a valid form of input
* This is codegolf, so lowest byte count wins.

## Test cases:

```
[0,2, 3,2, 3,0, 0,0]      Truthy
[3,5, 2,0, 0,2, 5,3]      Truthy
[6,3, 3,5, 0,2, 3,0]      Falsy
[1,4, 5,2, 4,0, 0,2]      Truthy
[0,0, 0,0, 3,2, 4,0]      Falsy
[1,1, 1,1, 1,1, 1,1]      Truthy
[1,4, 100,1, 100,1, 1,4]  Truthy

```

# Answer
# Python 3, <sup>~~88~~ \\$\cdots\\$ ~~54~~</sup> 43 bytes

```
lambda l:len({abs(sum(l)/4-z)for z in l})<2

```

Try it online!

**How**

Calculates the distances from the quadrilateral's centre of mass to all of its vertices and tests if they're equal.

**Input** The four vertices as a sequence of complex numbers in any order.
**Output** `True`/`False`
> 23 votes

# Answer
# Jelly, 6 bytes

A port of Noodle9's Python answer with a slight adjustment for golfing purposes.

```
×4_SAE

```

A monadic Link accepting a list of four complex numbers which yields `1` if they form a rectangle or `0` if not.

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

### How?

Checks that all four coordinates are equidistant from the centre of mass of the uniform density quadrilateral.

```
×4_SAE - Link: list of complex numbers, C
 4     - literal four
×      - (C) multiply (4) (vectorises across C)
   S   - sum (of C)
  _    - (C×4) subtract (sum(C)) (vectorises across C×4)
    A  - absolute value (vectorises)
     E - all equal?

```

---

Note this still works given an equilateral triangle with a repeated coordinate (it would skew the centre of mass toward the repeated coordinate).

---

The equivalent change to Noodle9's program would be:

```
lambda l:len({abs(z*4-sum(l))for z in l})<2

```
> 8 votes

# Answer
# 05AB1E, 11 bytes

Port of Noodle9's Python answer. 05AB1E doesn't have complex numbers, so it ends up a bit long.

```
εIøO4/-}nOË

```

Try it online!
> 2 votes

# Answer
# Python 3, ~~115~~ ~~108~~ 107 bytes

This solution finds if any permutation of A,B,C,D results in a rectangle. Output is correct for all test cases **except test case 3 which is not a rectangle due to corners not equal to 90 degrees.**

```
lambda a,b,c,d:g(a,b,c,d)+g(a,c,b,d)+g(a,b,d,c)
g=lambda a,b,c,d:b+d-a-c==((b-a)*(d-a).conjugate()).real==0

```

Try it online!

**Input**: 4 complex numbers representing the 4 coordinates.
**Output**: a positive integer if input is a rectangle, or `0` if input is not.

*105 bytes if output can be `0` for rectangle, and non-zero for non-rectangle.*

```
lambda a,b,c,d:g(a,b,c,d)*g(a,c,b,d)*g(a,b,d,c)
g=lambda a,b,c,d:b+d-a-c or((b-a)*(d-a).conjugate()).real

```
> 1 votes

# Answer
# Ruby, 44 bytes

Input is an array of 4 complex numbers, again.

```
->l{l.map{|z|(l.sum/4.0-z).abs}.uniq.size<2}

```

Try it online!

Port of @Noodle9's Python answer.
> 1 votes

# Answer
# APL2: 33 bytes

Yet another port of Noddle9's answer, this time in APL2.

Prerequisites:

1. This is code is ⎕IO-dependant since it uses *Partition with axis*. This example in `⎕IO=0`
2. The list of coordinates is stored in variable C.

`D≡⌽D←↑+/(M-+/¨.25×M←⊂[1]⍉4 2⍴C)*2`

The result is either `1` for *true* or `0` for *false*.

### An example

If `C` is the vector `3,5,2,0,0,2,5,3` or rather `3 5 2 0 0 2 5 3`, then the first thing that happens is that `4 2⍴C` turns it into a 4x2 matrix:

```
3 5
2 0
0 2
5 3

```

Then  transposes that matrix and `⊂[1]` turns it into a vector of 2 vectors (x & y). This is stored as `M`: `((3 2 0 5)(5 0 2 3))`.

Next `M` is multiplied with `0.25` and summed element-wise: (this is what `+/¨ does)`

`(2.5 2.5)`.

Now we subtract this from `M` and square the differences: `(M- ...)*2` (yes, `*` is "power"). We now have: `(0.25 0.25 6.25 6.25)(6.25 6.25 0.25 0.25)`.

This is summed by the `+/` outside the brackets and we get `((6.5 6.5 6.5 6.5))`. Sadly we have a 4-element vector inside another structure so we have to "spend" a character to remove the outer shell: .

The inner vector is assigned to variable `D`. Finally we use  to compare `D` to its reverse `⌽D` thereby checking if all items are equal.
> 1 votes

# Answer
# APL (Dyalog Unicode), 25 bytes

```
{1=≢∪|⍵-+/⍵÷4}

```

Try it online!

input: complex numbers.

distances from centre of gravity must match.
> 1 votes

# Answer
# Husk, 13 bytes

```
Λ=mO½´×oΣzo□-

```

Try it online!

I'm not sure if this is correct.

It takes Euclidean distance between all pairs and checks if the resulting array is symmetric.
> 1 votes

# Answer
# Vyxal, 12 bytes

```
ƛ?ÞTvṁ-²∑√;≈

```

Try it Online!

```
ƛ         ;  # Map to...
 ?           # Input
  ÞT         # Transposed
    vṁ       # Take the average of each (center)
      -      # Get the x and y distances to the center
       ²∑√   # Pythagoras to get abs. dist. to center
           ≈ # Are all equal?

```
> 1 votes

# Answer
# Bash \+ GNU utilities, 77 bytes

```
cat>t;join -j3 t t|xargs -I% dc -e%sDsClD-d*sqlC-d*lq+p|sort|uniq -c|grep 2\

```

(There's a space at the end, after the backslash.)

Try it online!

Or try the entire test suite online.

The input is in the form:

```
x1 y1
x2 y2
x3 y3
x4 y4

```

(with a newline after each point).

The output is the exit code: 0 for falsey, 1 for truthy.

---

**Here's how it works** (there are no complex numbers available in bash):

1. The `join` computes all the pairs of points. There are 4 points, so there are 16 pairs of points. (This includes each pair in both orders, and it even includes pairs where the two points are the same.)
2. The `xargs` command uses `dc` to compute the square of the distance between each pair of points. We now have a list of all the squares of the distances between pairs of the points.
3. Now, `sort|uniq -c` computes how many times each value appears in the list of squared distances.
4. The original four points form a rectangle iff no value appears exactly twice in the list.
> 0 votes

# Answer
# Wolfram Language (Mathematica), 32 bytes

```
Equal@@Norm/@(r=#;Mean@r-#&/@r)&

```

This is a port of Noodle9's Python answer. I start by determining the centroid of the four points, which is their average position in space, by taking the mean of the four vectors corresponding to each. \[N.B.: If the points had mass, and their masses were identical, this would give their center of mass.\]. I then subtract each point from the centroid, and determine the lengths (norms) of the four resulting vectors. I then test to see if all four norms are the same.

Try it online!

Alternately, the following is also 32 bytes. Though this one is non-competing, since the challenge was posted ~May 2020, and this uses new syntax (`|->` as a shorthand for `\[Function]` ) that wasn't introduced until v. 12.2 of Mathematica, which was released in Dec. 2020:

```
Equal@@Norm/@(r|->Mean@r-#&/@r)&

```

Interestingly, the above doesn't work in tio.run , because it's using version 12.0.1 for Linux x86 (64-bit) (October 16, 2019).
> 0 votes

---
Tags: code-golf, decision-problem, geometry
---


# Question
Title: Print the last answerer's first submission
In this challenge, your past self comes back to help or hurt someone else!

The task is simple: write a **full program**, not a function, that prints the first code submission on this site submitted by the previous user, **in the language of *your* first answer**. (In the case that your first answer was purely prose, for example pxeger's first answer to a "Tips for Golfing" thread, use the first code-based answer.)

My first answer was

*/```
</code></pre>

That's a newline followed by `*/````. Suppose that Doorknob was the first to answer this question. His first answer was in JavaScript, so he might respond to this challenge

alert("\n*/```")
</code></pre>

And the next answerer here would have to print his first answer,

```
s='';c=5;r=Math.random;while(c--)s+='bcdfghjklmnpqrstvwxz'[r()*20|0]+'aeiouy'[r()*6|0]

```

Only accounts that submitted an answer before this question was posted are eligible to participate. **Each user may submit only one answer.**

This is code golf, so the shortest answer wins. The fun is that who can win depends on who answers!

# Answer
> 5 votes
# 5. user, Java (OpenJDK 8), 75 bytes

```
interface T{static void main(String[]a){System.out.print("print(\"N\")");}}

```

Try it online!

My first language was Java, lol. This is my first answer. It's 1055 bytes. Have fun.

```
interface T{static void main(String[]a){System.out.print("The basic idea of a [tag:kolmogorov-complexity] challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from [Borromean Rings](_%s/53417/ascii-borromean-rings) to [The Gettysburg Address_%s/15395/how-random-is-the-gettysburg-address). \n##Your Task\nThis % is similar, except that it requires printing of a special text - the text of this %. Specifically, the very Markdown code that I am typing right now. \nTo prevent an infinite recursion in the %, the exact text you have to print can be found [here_revisions/1f731ea3-0950-4b03-ae95-24fa812a9a28/view-source). \n##Clarifications\n- You are not allowed to use any external sources like the internet. \n- This means that the purpose of this % is not to download this % text and parse it, but instead to store it in you program. \n- This is [tag:code-golf], so shortest code in **bytes** wins!".replaceAll("_","])http://codegolf.stackexchange.com/").replaceAll("%","question"));}}

```

# Answer
> 3 votes
# 10. Neil \- GolfScript and Funge-98, ~~154~~ ~~153~~ ~~151~~ ~~147~~ 146 bytes

```
#.c5*01:$pd-1x
 v "var isSorted = function(array) { return \""'"'" + array == array.sort(function(a, b) { return a - b; }); }"
#>:'\-#^_$
#^@#,  _

```

My first answer was:

```
#>&:*.@
~2-1??

```

# Answer
> 2 votes
# 1. Purple P, √ å ı ¥ ® Ï Ø ¿, 9 bytes

<pre><code>'
*/```'W

Try it online!

This was my first answer:

```
Ißo

```

---

Ignore the `OUTPUT` and `Program execution information` banners. Those are automatically printed by the interpreter when any program in `√ å ı ¥ ® Ï Ø ¿` is executed.

It's been a while since I used `√ å ı ¥ ® Ï Ø ¿` (or remembered that it existed). This pushes the string

*/```</code></pre>

to the stack, then outputs it with `W`

# Answer
> 2 votes
# 6. hyper-neutrino, Brain-Flak (BrainHack), 19516 bytes

```
(((((<(((((((((((((<(((((((((((((((((<(((((((((((((((((((((((((((((((((<((<((((((((((((<((((((<(((((((<((<((((<((((((((<(((((((((((((((((((<((<(((((((((<(((((((<(((<((<((<(((((<((<(((((((<((((<((<(((((<(((<((((((<((((<((((((((<((<(((<((((<((((<((<(((((((<(((<((((<(((((<(((((((((<((((((((<(((<((((<(((((((<((((((((<(((<(((<((<(((((((<(((<(((<((((((((((((((((((((((<((((<((((((<((((((<(((((((((((((((((<((((((((((((((((((((((((((((((((<(((((<((<(((<(((((<((<((((<(((<((((<(((((<((((((<(((<((<(((((((((<((((((((<((<(((((((<(((((<(((<(((((<((((((<((<(<((((<((((<((((((((<((((<((((<(((((((((((((((<((((<((<((((<(((((<((((<(((((((<(<((<((((((((<((((((((<((<((((<(((((((<(((((((<((((<((((((((((<(((((<((((<((((((((((((((((((((((<(((((((((<(((((((((((<((((((((<((((((((((<((((<(((<(((((((((((((((((((((((((((((<(<((((((<((((((((((<(((((<((((<((<((((<(((<((((<((((<(((<(((((((<(((<(((((((<((((<(((((((<((((<((((((((<(((<((<((((((<(((<(<(((((<((<((<(((((((((<(((<(<((((<<(((((((((((((((<(<((<(((((((((((((((<((((<<(((<(((((((<((((((((((((((<(((((((((((((<(((((((((()(((()((()()()){}){}){}){}){})()()()()[])(()[]){})[()(()([]){}){}])()(()()[]){})[(()[]){}])[()()()()()])()())()())>(()()(()[])({}){})((()()()[]){}){})(()()[])({}){})[(()()()()){}])())[()()()()()[]])()()()()[])[()(()()()()()){}])[(()()()){}])[()(()()()()[])({}){}])(()(()()[]){}){})[()(()()()){}])[(()()()){}])[()()()()()])>(()()()()()()()()()[])()()(()[])({}){})[((()()()){}){}])(()()()()){})()()()()())[(()()()()()()()[]){}])()(()((()()()()()){}){}){})()()()[])[()()])[()(()()()()){}])()()()()())[()(()()()){}])[((()()()){}){}])()())()()()())>(()()()[])(()()[]){})[[]])(()(()(()()()()){}){}){})[(()()()){}])())[()(()(()()()){}){}])(()()()()){})>([])()((((()()()()){}){}){}){})(()()()){})[()])>((()(()(()()()()()){}){}){})>((()()()()()[]){})()())[()(()()()()){}])()()()()())(()()()){})>((((()()()()()){}){}){})[(()()()){}])(()(((()()()){}){}){}){})((()()()()()){}){})[()()()])[()()()()()()()()[]])()()()()[])[()])(()(()()()()){}){})[(()()()()()){}])[(()()()){}])[[]])()()()()()[])[()()()()()])())[()()()()])>((((()()()()){}){}){})()()()()()()[])[()(()()()()){}])>((((()()()()){}){}){})()((((()()()()){}){}){}){})>((((()()()()){}){}){})()(()((()(()()()){}){}){}){})()(((()()()){}){}){})[()(()(()()()()){}){}])(()()()){})[()((()(()()()()()){}){}){}])()((((()()()){}){}){}){})()()()())[()()()])())()())[(()()()()){}])(()()()()){})()()())[()()()])()(()()()){})>(()((()(()()()()()){}){}){})>(()()()()()[])((()()()){}){})[()()])()()())[()()()()])>(()()[])()(()(()()()()){}){})>(()()()()[])()(()()()()()){})()()()()())[((()(()()()){}){}){}])>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})()()()()())[()(()()()){}])()(()()()()()){}))[()(()()()){}])()(()()()()){})[()(()()()){}])[()()])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})(()()()()()){})>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})((((()()()()()){}){}){}){})()())[()(()()()()){}])()()()()())(()()()){})>((((()()()()){}){}){})()((((()()()()){}){}){}){})>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[(()(()()()){}){}])()(()(()()()){}){})>((((()()()()){}){}){})()((()((()()()){}){})({}){}){})(()()()){})[()])[()()()()])()()()()())[()])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[()(()()()()()){}])()(()()()){})()()())()())[()(()(()()()){}){}])(()(()()()){}){})())>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})((()()()){}){})[()(()()()()()){}])())>((((()()()()){}){}){})(()()()()){})((()(()(()()()()){}){}){}){})[((()()()){}){}])()(()()()){})(()()()){})[(()(()()()){}){}])())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()(()()()){}])()(()(()()()()){}){})>((((()()()()){}){}){})()((()(()(()()()()){}){}){}){})[(()()()()){}])[()()()()])()((()()()){}){})[()()()()()])()()()()())[()(()()()){}])>((((()()()()){}){}){})(((()(()()()()){}){}){}){})[()(()()()){}])(()(()()()()){}){})>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})()()()()())[()(()()()){}])()((()()()){}){})[()(()()()){}])[()()])[()])>((((()()()()){}){}){})((()((()()()){}){})({}){}){})())(()()()()){})>(()(((()()()()()){}){}){})()()()()())[(()(()()()){}){}])()(()(()((()()()){}){}){}){})(()(()()()){}){})>((((()()()()){}){}){})(((()(()()()()){}){}){}){})[()(()()()){}])()((()()()()()){}){})[()((()()()()){}){}])>((((()()()()){}){}){})(((()(()()()()){}){}){}){})[()(()()()){}])()()())>((((()()()()){}){}){})()((()(()(()()()()){}){}){}){})[((()()()){}){}])()((()()()){}){})()(()()()()()){})>((((()()()()){}){}){})()((()((()()()){}){})({}){}){})[()(()()()()){}])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])(()()()()){})>(((()(()()()()()){}){}){})[((()()()){}){}])(()(()((()()()()){}){}){}){})((()()()){}){})[()()()])[()()])>((((()()()()){}){}){})()(()((()(()()()){}){}){}){})[()(((()()()){}){}){}])()((()(()()()()()){}){}){})()()()))[()()()])[()()])[(()()()()){}])[()()()()])()((()()()){}){})>((((()()()()){}){}){})(()(((()()()){}){}){}){})()(()(()()()()()){}){})()()()()())[()(()()()){}])((()()()){}){})[(()(()()()()()){}){}])>((((()()()()()){}){}){})()(()(()((()()()){}){}){}){})>(()((()(()()()()){}){}){})((()((()()()){}){})({}){}){})[((()((()()()()){}){}){}){}])(()()()){})[()()])())[()()()])(()()()){})[(()()()()){}])(()(((()()()){}){}){}){})(()(()()()()){}){})[((()()()()){}){}])(()()()){}))[((()(()(()()()){}){}){}){}])()((()((()()()){}){}){}){})()((()()()){}){})()()()))[()()()])[()()])[(()()()()){}])[()()()()])()((()()()){}){})[()((((()()()()){}){}){}){}])()((()((()()()()){}){}){}){})[()(()()()()){}])()()()()())[()(()()()){}])((()()()){}){})>(()(((()()()()()){}){}){})[()(()()()()){}])((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})()(()((()(()()()){}){}){}){})[()(()()()){}])((()()()()()){}){})[()()()])>((((()()()()){}){}){})(()((()()()){}){})({}){})(()(()(()()()){}){}){})()(()(()()()){}){}))()()()()())[(()()()){}])[()((()()()()){}){}])()(()(()()()()){}){})[()()()])[()(()()()()()){}])>((((()()()()){}){}){})()(((()()()()){}){}){})()(()((()()()()){}){}){}))(()(()()()){}){})[()((()()()){}){}])(()(()()()){}){}))[((()()()()()){}){}])>(()((()(()()()()){}){}){})((()((()()()){}){})({}){}){})[((()((()()()()){}){}){}){}])()())()()()())[()()])(()()()){})[()()()()])[(()()()){}])()(((()(()()()){}){}){}){})()(()()()){})(()()()()){})>(()((()(()()()()()){}){}){})()((()((()()()()){}){}){}){})[()((()()()()){}){}])()((()()()){}){})[(()()()()()){}])()(()()()()()){})[()()])[((((()()()()){}){}){}){}])((()(()(()()()){}){}){}){})(()()()()()){})>(()((()(()()()()()){}){}){})()(()(()((()()()()){}){}){}){})[((()()()){}){}])[()()()])[(((()(()()()){}){}){}){}])(()((()(()()()){}){}){}){})[()()])()(()(()()()){}){}))()()()()())[(()()()){}])[()((()()()()){}){}])()(()(()()()()){}){})[()()()])[()(()()()()()){}])[(()((()(()()()){}){}){}){}])((()((()()()){}){}){}){})()()()))(()(()()()){}){})[()((()()()){}){}])(()(()()()){}){}))>(()(((()()()()()){}){}){})()()()()())[(()(()()()){}){}])((()(()(()()()){}){}){}){})(()(()()()()){}){})>(()(()((()()()()){}){}){}))(()(()((()()()){}){}){}){})(()(()()()()()){}){})(()()()){})[()()()])>((((()()()()){}){}){})((()((()()()){}){}){}){})()((()()()){}){})(()(()()()()){}){})[(()()()()){}])[()(()(()()()){}){}])(()(()()()()){}){})[(()((()()()){}){}){}])((()()()()()){}){})())(()()()()()){})>((((()()()()){}){}){})()()()()())[()()()()()])()(((()(()()()()){}){}){}){})(()()()()()){})>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[(()()()()()){}])()()()())[()()()()])()()())[()(()()()()()){}])()((()()()()){}){})>(((()(()()()()()){}){}){})[((()()()){}){}])()((()((()()()()){}){}){}){})()(()(()()()()){}){})[()((()()()()()){}){}])()())()(()()()()()){})()()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()(()()()){}])()(()(()()()()){}){})>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()(()()()()()){})>((((()()()()){}){}){})(()(((()()()()()){}){}){}){})[()((()()()){}){}])((()()()){}){})()()()())[((()()()){}){}])()(()()()()){})[()((()()()){}){}])(()(()()()){}){})>((((()()()()){}){}){})((((()()()()()){}){}){}){})()())[()(()()()()){}])()()()()())(()()()){})[()(()()()()()){}])()()()()())[()(()()()){}])>((((()()()()){}){}){})()((()((()()()){}){})({}){}){})[()(()()()()){}])>((((()()()()){}){}){})()((((()()()()){}){}){}){})>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[()()()])[()(()()()()()){}])[()()])(()()()){})[(()()()()){}])()(()()()()()){})>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()(()(()()()){}){}])()(()(()()()()){}){})[()()()()])>((((()()()()){}){}){})()((()()()){}){})[()((()()()){}){}])((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()(()(()()()){}){}])()(()(()()()()){}){})[()()()()])>((((()()()()){}){}){})()((()((()()()){}){})({}){}){})[()(()()()()){}])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])())(()()()()()){})>((((()()()()){}){}){})()()()()())()(()()()()){})[(()(()()()){}){}])()(()(((()()()){}){}){}){})()((()(()()()){}){}){})[()(()()()()()){}])[()()])(()()()){})[()()()])()()())[(()()()){}])[()()])()(()()()()()){}))()((()()()){}){})>(((()(()()()()()){}){}){})[((()()()){}){}])((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})(()(()((()()()()()){}){}){}){})[()((()()()()){}){}])()((()()()){}){})()(()()()){})>((((()()()()){}){}){})()((()(()()()()()){}){}){})((()()()()()){}){})()((()()()()){}){})[()(()()()){}])[()(()()()){}])()(()()()()()){})(()()()()){})[()(()()()()){}])>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})((()()()){}){})[()(()()()()()){}])())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()(()()()){}])()(()(()()()()){}){})>((((()()()()){}){}){})()(((()()()()()){}){}){})>((((()()()()){}){}){})()((((()()()()){}){}){}){})((()()()){}){})>((((()()()()){}){}){})((()((()()()()()){}){}){}){})()()()()())[()(()()()()){}])[()(()()()){}])()()()()())[()(()()()){}])>((((()()()()){}){}){})(()(((()()()()()){}){}){}){})[()(()()()()){}])[()()])())((()()()){}){})>((((()()()()){}){}){})((()((()()()){}){})({}){}){})())(()()()()){})>((()(()(()()()()()){}){}){})[(()(()()()){}){}])((()(()(()()()){}){}){}){})(()(()()()()){}){})[(()((()()()){}){}){}])()(()((()()()){}){}){})>((((()()()()){}){}){})((((()()()()()){}){}){}){})()())[()((()()()){}){}])()((()()()()){}){})[()((()()()()){}){}])()(()()()()){})(()()()){})>((((()()()()){}){}){})()((((()()()()){}){}){}){})()((()()()){}){})>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())[(()()()()){}])()()())()()()()())[()()()()()])()(()()()()()){})[()(()(()()()){}){}])>((((()()()()){}){}){})(()(((()()()()()){}){}){}){})[()((()()()){}){}])[()()])(()(()()()()){}){})[()()()])())[(()()()()()){}])(()()()){})[()])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})()()()()())()(()()()){})[((()()()){}){}])((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()(()()()()){}){})[()(()(()()()()()){}){}])()())()((()()()()){}){})>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()(()(()()()){}){}])()(()(()()()()){}){})[()()()()])>((((()()()()){}){}){})()(((()(()()()()()){}){}){}){})[(()()()()()){}])(()()()){})>((((()()()()){}){}){})(((()(()()()()){}){}){}){})[()(()()()){}])()((()()()()()){}){})[()((()()()()){}){}])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})((((()()()()()){}){}){}){})()())[()(()()()()){}])()()()()())(()()()){})>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})[()()])()((()()()){}){})>((((()()()()){}){}){})(()(((()()()()){}){}){}){})()()())>((((()()()()){}){}){})(()(()((()()()()){}){}){}){})()(()()()()){})(()()()){})[()(()()()){}])[(()()()()()){}])>((((()()()()){}){}){})()(()((()(()()()){}){}){}){})()((()()()){}){})[()()()])()((()()()){}){})[()((()()()){}){}])[(()()()){}])()(()(()()()()){}){})[()((()()()){}){}])()((()()()()){}){})[()((()()()){}){}])(()()()()()){})[(()()()()()){}])(()()()){})[()])()()()()())[((()((()()()()){}){}){}){}])()())()((()((()()()){}){}){}){})[()(()(()(()()()()()){}){}){}])[()()()()])[()()])((()((()()()){}){}){}){})[()()()()])[(()(()(()()()()()){}){}){}])[(()()()){}])()()())()(()()()()){})[()()()()])[()()()()()])[()()()])()(()()()){})(()(()(()()()()()){}){}){})>(((((()()()){}){}){}){})()()())[(()()()){}])((()((()()()){}){}){}){})()()()())[((()(()()()()()){}){}){}])[()()()()])[(()()()()){}])()()()()())()())(()(((()()()){}){}){}){})[()()()()()])[()(((()()()()()){}){}){}])[()(()()()){}])())()(()(()(()()()()()){}){}){})[(((()()()()()){}){}){}])(((()()()()()){}){}){})>((()(((()()()){}){}){}){})(()()()){})[()(()()()()){}])()(()(()((()()()()){}){}){}){})[()((()()()){}){}])[()()()()])(()(()()()()){}){})>(()((()(()()()()()){}){}){})(()(()((()()()()){}){}){}){})[()()()()])(()()()){})[()()()])[()(()(()()()){}){}])()())>(()(((()()()()()){}){}){})()()()()())[(()(()()()){}){}])((()(()(()()()){}){}){}){})(()(()()()()){}){})>(()(()((()()()()){}){}){}))(((()()()()){}){}){})()(((()()()()()){}){}){})[()(()()()()()){}])()((()()()()){}){})[()(()()()()){}])[()()()])()()())[(()()()){}])[()()])()(()(()()()()){}){})[()(()()()()()){}])(()()()){})[()])()()()()())[()(()(()()()()()){}){}])(()(()()()()){}){})[()((((()()()()){}){}){}){}])[()((()()()){}){}])()(((()(()()()){}){}){}){})(()(()()()()()){}){})(()()()){})>((((()()()()){}){}){})()((((()()()()){}){}){}){})()((()()()()){}){})[()((()()()){}){}])>((((()()()()){}){}){})((()((()()()){}){})({}){}){})())()()()()())>((((()()()()){}){}){})()((((()()()()){}){}){}){})()(()()()()()){}))()()())(()()()()){})[(()(()()()()){}){}])[()])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})()((()((()()()()()){}){}){}){})[()()])[(()(()()()){}){}])>((((()()()()){}){}){})()((((()()()()){}){}){}){})()((()()()){}){})()(()()()()()){})>((((()()()()){}){}){})()((()((()()()()){}){}){}){})()(()(()()()()){}){})[()()()()])[()(()(()()()){}){}])()((()()()){}){})[()()()()])[()((()()()){}){}])()(()()()()()){})>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[()()()()])(()()()){})[()()()])[()(()(()()()){}){}])()())(()(()()()){}){})>((((()()()()){}){}){})((()(()(()()()()){}){}){}){})[()()()])()())[(()()()){}])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())(()()()){})[()(()(()()()){}){}])()((()()()){}){})[()()()()])[()(()()()()){}])()(()(()()()){}){})>((()(()(()()()()()){}){}){})[(()(()()()){}){}])((()(()(()()()){}){}){}){})(()(()()()()){}){})[()((((()()()()){}){}){}){}])[()((()()()){}){}])((()((()()()){}){}){}){})((()()()()()){}){})())(()()()()()){})>((((()()()()){}){}){})()((()(()(()()()()){}){}){}){})[(()()()()){}])[()()()()])()((()()()){}){})()()()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()(()()()){}])()(()(()()()()){}){})>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])[()()()])>((((()()()()){}){}){})((((()()()()()){}){}){}){})()()()()())[()()()])[()()])[()])()()()())[(()(()()()){}){}])>((((()()()()){}){}){})()((()((()()()){}){})({}){}){})[()(()()()()){}])>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])())(()()()()()){})>((((()()()()){}){}){})()()()()())[()()()()()])()(((()(()()()()){}){}){}){})(()()()()()){})>((((()()()()){}){}){})((()((()()()){}){})({}){}){})())()()()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})((()((()()()()){}){}){}){})()(()()()()()){})(()()()()){})[()(()()()()){}])[()()])()()())[(()(()()()){}){}])()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[((()()()){}){}])())(()()()()()){})>((((()()()()){}){}){})()()()()())[()()()()()])((()((()()()()()){}){}){}){})[()(()(()()()){}){}])()(()(()()()()){}){})[()()()()])>((((()()()()){}){}){})()((((()()()()){}){}){}){})()((()()()){}){})[(()()()()()){}])>((((()()()()){}){}){})((((()()()()()){}){}){}){})[()(()(()()()){}){}])()((()()()()){}){})())[(()(()()()){}){}])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()(()()()()()){})>(((()(()()()()()){}){}){})[((()()()){}){}])(()(((()()()()){}){}){}){})()(()(()()()()){}){})[()])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())()()()()())())[()(()(()()()){}){}])[()()()()])()()())>((((()()()()){}){}){})((()((()()()()()){}){}){}){})[()()()()()])>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})())[()()()()()])()()())[()((()()()){}){}])>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()(()()()()()){})>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())>((((()()()()){}){}){})()(((()(()()()()()){}){}){}){})[(()()()()()){}])(()()()){})>((((()()()()){}){}){})((((()()()()()){}){}){}){})()())[()()()])[(()()()()){}])()(()()()()()){})[()((()()()()){}){}])((()()()){}){})>((()(()(()()()()()){}){}){})[(()(()()()){}){}])((()(()(()()()){}){}){}){})(()(()()()()){}){})[()((((()()()()){}){}){}){}])[()((()()()){}){}])((()((()()()){}){}){}){})((()()()()()){}){})())(()()()()()){})>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})(()()()()()){})>((((()()()()){}){}){})()(()((()(()()()){}){}){}){})()(((()()()){}){}){})[()(()(()()()()){}){}])(()()()){})[()((()(()()()()()){}){}){}])()(((()()()()()){}){}){})((()()()){}){})[()(()()()()()){}])())[(((()(()()()){}){}){}){}])(()((()(()()()){}){}){}){})(()()()()){})[()()()])[(()()()){}])[()(()()()()){}])[()((((()()()){}){}){}){}])[((()()()){}){}])()(()(((()()()()()){}){}){}){})[()()()()])>((((()()()()){}){}){})()(()(((()()()()()){}){}){}){})[()(()()()()()){}])()(()()()){})()()())()())[()(()(()()()){}){}])(()(()()()){}){})())>((((()()()()){}){}){})()(()(((()()()()){}){}){}){})((()()()){}){})[()(()()()()()){}])())>((((()()()()){}){}){})()(((()(()()()()){}){}){}){})()()()()())>((((()()()()){}){}){})(()()()()()){}))(((()(()()()){}){}){}){})()(()(()()()()()){}){})[()()()()()])[()(()(()()()){}){}])(()(()()()){}){})>((()((()()()()()){}){}){}))[(()()()()()){}])(()((()(()()()){}){}){})({}){})[(()(()()()){}){}])()()()()())()()()()())>(()(((()()()()){}){}){})())((()()()){}){})((()((()()()()){}){}){}){})[()((()()()){}){}])()(()()()()()){})[()()()()])[()(()()()()()){}])()())()())[((()(()()()()){}){}){}])()(()((()()()()()){}){}){}))>((((()()()()()){}){}){})[(()()()){}])()((()(()(()()()){}){}){}){})>((()((()()()()){}){}){})(()()()()()){})[(()()()()()){}])()(()((()(()()()){}){}){}){})[((()((()()()){}){}){}){}])(()((()()()()()){}){})({}){})((()()()){}){}))[()()()()])[(()(()((()()()){}){}){}){}])[()(()()()()()){}]))((()((()()()){}){}){}){})((()()()){}){})[()(()()()()()){}])())()())(()()()()){})[()()()])[(()()()){}])[(((()(()()()){}){}){}){}])()((()((()()()()){}){}){}){})())[()(()(()()()()){}){}])()())(()()()()){})[(()()()){}])()(()(()()()()){}){})[()((()()()()()){}){}])()()()()())[()(()()()){}])()((()()()){}){})[()(()()()){}])[()()])>((()(()(()()()()()){}){}){})()((()((()()()){}){}){}){})((()()()){}){})[()()])[(()(()(()(()()()){}){}){}){}])[()((()()()){}){}])()(()()()){})()()()()())((()((()()()()){}){}){}){})[()((()()()){}){}])()(()()()()()){})[()()()()])[()(()()()()()){}])()())()())[((()(()()()()){}){}){}])()(()((()()()()()){}){}){}))>((((()()()()()){}){}){})[(()()()){}])()()())[()()()])(()()()()()){})[(()()()()()){}])()((()((()()()){}){})({}){}){})()()()())[((()()()()){}){}])(()(()()()){}){})())[()(()()()()()){}])(()()()){})[()])>((()((()()()()){}){}){})()(()()()){}))(()(()()()()){}){})(()(((()()()()){}){}){}){})){({}<>)<>}<>

```

Try it online!

This is a bit of a placeholder, since golfing brain-flak is a lot of work and I'd rather not lose all my progress since someone else posted an answer. The current code was generated by this hyper-neutrino answer.

My first answer was:

```
(<({}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}<>(({}<{}>)){{}{}(<(())>)}{}

```

Should present a interesting challenge.

# Answer
> 2 votes
# 7. Wheat Wizard♦, MATLAB/Octave, 94 bytes

```
disp('(<({}<>)>)<>{({}[()])<>(({}()[({})])){{}(<({}({}))>)}{}<>}<>(({}<{}>)){{}{}(<(())>)}{}')

```

Try it online!
Meh, a no-brainer. Didn't find any smarty way to golf it.

My first answer was:

```
ezpolar(@(x)r);s=r+5;axis([-s,s,-s,s])

```

(it was later edited but if I understand correctly we're supposed to do the *original* first answers)

---

Alternative solution, trying to golf, but is longer (**110 bytes**)

```
e='$&\IIEPW0+,H&X*&Y9.W$&XW)I^\OE WF])V^X@!-/W'-32;c='()[]<>{}';disp(c(reshape([floor(e/8);mod(e,8)],1,[])+1))

```

Try it online!
Each character in`$&\IIEPW0+,H&X*&Y9.W$&XW)I^\OE WF])V^X@!-/W` represents two characters to display (more exactly their indices in `()[]<>{}`). Needed to add 32 to chars (and subtract them in the decoding process) to avoid using non-printable characters that render the code unrunnable.

# Answer
> 2 votes
# 9. Nick Kennedy \- JavaScript, 136 bytes

```
function(){return'x=function(){rev(rawToBits(rev(charToRaw(sprintf("x=%s;x()",gsub("\\\\s","",paste(deparse(x),collapse="")))))))};x()'}

```

My first answer was :

```
var isSorted = function(array) { return "" + array == array.sort(function(a, b) { return a - b; }); }

```

# Answer
> 2 votes
# 12. tail spark rabbit ear, Vyxal, 6 bytes

```
kH‛.p+

```

Try it Online!

**Explanation**

```
kH       # Hello, World! pre-defined constant
‛        # Two byte string literal
.p       # Capture next two bytes: .p and push to stack
+        # Concatenate top two items on stack
          (implicit output of top of stack)

```

Prints `Hello, World.p`, couldn't waste the big chance and I am winner until now!!!

My first answer, `1.."$args"-match"2$"`

# Answer
> 2 votes
# 14. SjoerdPennings, JavaScript (Node.js), <sup>~~310~~ ~~302~~</sup> 297 bytes

```
alert(`def f(i):
i=i.split(" ")
print i[0],i[2],
for f in i[0:3]: print f,
print ""
for t in["TT","TF","FT","FF"]:
p,q=t[0],t[1]
y = t[0]+" "+t[1]
if i[1]=="^${a='": r=(False,True)[p'}==q]
if i[1]=="v${a}!=q]
if r: y+="   T"
else: y+="   F"
print y`.replace(/\n/g,(b,i)=>b+' '.repeat(4+(i>90)*4)))

```

Try it online!

### My first answer, 68 bytes

```
l=(a,b,c)=>b.startsWith(a.slice(c=~~c,-1))?a.slice(0,c)+b:l(a,b,++c)

```

# Answer
> 2 votes
# 16. Aaron Miller, AArch64 machine code, 41 bytes

Machine code dump (xxd):

```
00000000: 20 00 80 52 c1 00 00 10 a2 01 80 52 08 08 80 52   ..R.......R...R
00000010: 01 00 00 d4 a8 0b 80 52 01 00 00 d4 3a 2e 5c 21  .......R....:.\!
00000020: 2b 3a 22 64 22 60 23 40 5f                       +:"d"`#@_

```

Assembly source:

```
        .text
        .globl _start
_start:
        // write(1, .Lstr, strlen(.Lstr))
        mov     w0, #1
        adr     x1, .Lstr
        mov     w2, #13
        mov     w8, #64 // SYS_write
        svc     #0
        // exit(dontcare)
        mov     w8, #93 // SYS_exit
        svc     #0
.Lstr:
        .ascii ":.\\!+:\"d\"`#@_"

```

Given how all instructions are 4 bytes long, there isn't any point in doing anything but a direct write.

My first submission (xxd)

```
00000000: e4 03 27 1e 00 44 40 bc 01 58 20 0e 21 38 30 2e  ..'..D@..X .!80.
00000010: 23 3c a4 0e 02 1c a3 2e 24 1c a3 2e 21 04 00 f1  #<......$...!...
00000020: 21 ff ff 54 40 00 26 1e c0 03 5f d6              !..T@.&..._.

```

**You must emit the raw bytes**, not the assembler source or the hexdump.

# Answer
> 2 votes
# 17. EasyasPi, Python 3 2, 110 bytes

*I realised that my first answer was written in Python 2 after I had posted. Here is the updated and golfed version.*

```
import os,base64 as b
os.write(1,b.b64decode("5AMnHgBEQLwBWCAOITgwLiM8pA4CHKMuJByjLiEEAPEh//9UQAAmHsADX9Y="))

```

This was my first answer:

```
n='\n'
p,a='p'*8+n,'rnbqkbnr'+n
print a+p+('.'*8+n)*4+(p+a).upper()

```

# Answer
> 1 votes
# 2. caird coinheringaahing \- Python 3, 13 bytes

```
print("Ißo")

```

Try it online!

My first (code-based) answer is long and high-entropy, so good luck :P

```
import zlib;lambda x:filter(33 .__ne__,zlib.decompress(b'x\x9cKJM-PH\xc2A(\x92\xc7\xa26\x97nb4!\0hm{7')[:x*5])

```

# Answer
> 1 votes
# 3. pxeger, PHP, 110 bytes

```
import zlib;lambda x:filter(33 .__ne__,zlib.decompress(b'x\x9cKJM-PH\xc2A(\x92\xc7\xa26\x97nb4!\0hm{7')[:x*5])

```

Try it online!

My first answer was this:

```
<?php $w=0;foreach(str_split($argv[1])as$v){if($v=='o'){echo$w.' ';}else{$w=$v=='s'?$w**2:($v=='i'?++$w:--$w);}if($w==256||$w<0){$w=0;}}

```

# Answer
> 1 votes
# 4. A username, Scala, 141 bytes

```
_=>"<?php $w=0;foreach(str_split($argv[1])as$v){if($v=='o'){echo$w.' ';}else{$w=$v=='s'?$w**2:($v=='i'?++$w:--$w);}if($w==256||$w<0){$w=0;}}"

```

Try it in Scastie!

My first answer

```
print("N")

```

Simple string replacement can't be done here, as there aren't any patterns. Using `GZIPOutputStream` and stuff gets really long just from the names of the classes involved, and the string's too short for the compression algorithm to work its magic. In contrast to A username's first answer, mine is really short and easily printed.

# Answer
> 1 votes
# 8. elementiro , 45 bytes

```
cat("ezpolar(@(x)r);s=r+5;axis([-s,s,-s,s])")

```

Try it online!

A rather boring program that just `cat`s the previous person’s first answer. My first answer was this one:

```
x=function(){rev(rawToBits(rev(charToRaw(sprintf("x=%s;x()",gsub("\\s","",paste(deparse(x),collapse="")))))))};x()

```

# Answer
> 1 votes
# 11. Ross Long, Pxem, 0 (content) + 17 (filename).

Since it was 15 bytes, terminating LF is also output.

Filename is as follows:

```
#>&:*.@
~2-1??
.p

```

Content is empty.

Try it online!

My first post:

* Filename: `Hello, World!.p`
* Content: empty

# Answer
> 1 votes
# 13.Wasif, Python 2, 27 bytes

EDIT: My sleepy brain didn't notice the "language of your first answer" rule, it has been fixed at the cost of 5 bytes.

Just a simple print. There's not enough of a pattern to try replacements or formatted strings, compressed versions of the strings are longer than the original, and since this is Python 2, using `exit('text')` won't save me a byte. As far as I know, the best way to golf this is to simply print it, and remove the space between `print` and the string.

```
print'1.."$args"-match"2$"'

```

Try it online!

My first answer is:

```
def f(i):
    i=i.split(" ")
    print i[0],i[2],
    for f in i[0:3]: print f,
    print ""
    for t in["TT","TF","FT","FF"]:
        p,q=t[0],t[1]
        y = t[0]+" "+t[1]
        if i[1]=="^": r=(False,True)[p==q]
        if i[1]=="v": r=(False,True)[p!=q]
        if r: y+="   T"
        else: y+="   F"
        print y

```

# Answer
> 1 votes
# Alex bries, Befunge-93, 79 bytes

```
")c++,b,a(l:b+)c,0(ecils.a?))1-,c~~=c(ecils.a(htiWstrats.b>=)c,b,a(=l">,# :# _@

```

Try it online!

### My first answer:

```
:.\!+:"d"`#@_

```

---
Tags: code-golf, kolmogorov-complexity, answer-chaining
---


title: Tips for golfing in Brachylog

text:
# Question
Title: Tips for golfing in Brachylog
Brachylog is a language that's beginning to rise in prominence in code-golfing recently (and just received a major update with a terser syntax). Like Prolog, it has the advantage that it can often solve a problem (typically via brute force) merely from a sufficiently accurate description of what a problem looks like, a feature that means that on the right sort of challenge, it's often comparable to the top golfing languages (and has been known to beat Jelly from time to time).

What tips do you have for golfing (i.e. writing the shortest possible programs in) Brachylog? This is mostly looking for advice that's specific to Brachylog in particular, rather than advice that's applicable to a wide range of languages. (Tips about golfing in declarative languages in general might potentially be appropriate here, depending on how much application they'll have to languages other than Brachylog, although see also Tips for golfing in Prolog.)

# Answer
# Exploit nested predicates to create new variables

Brachylog has lots of special syntax cases to make its two special variables, `?` (input / left parameter) and `.` (output / right parameter), terser to use. This means that if you don't need to access your predicate's `?` and `.`, but do need to use variables, you can often save bytes via creating a nested predicate to use *its* `?` and `.`.

As a simple example, consider a program that looks like this:

```
… A … ∧A … B … B …

```

This is a pretty common shape for a longer program; after all, there are lots of gaps that could contain anything. Suppose we have no need for `?` or `.` inside the centre three gaps. Then we could rewrite it like this:

```
… { … & … . … } …

```

Here, the nested predicate's `?` is serving the role of `A`, and its `.` is serving the role of `B`. We can observe that this is a byte shorter than the original code; changing `AABB` to `{?.}` has no change in terms of bytes, but this allowed us to simplify `∧?` to the abbreviation `&`.

A related trick is to change

```
∧. … ?∧

```

to

```
~{ … }

```

(which is one byte shorter), although note that it's nearly always cheaper to get the caller to exchange the arguments instead (unless the predicate is called from at least three different places in the program, which is rare in Brachylog).
> 7 votes

# Answer
# Split up length-2 predicates inside metapredicates

This is best explained by example. To remove the first and last elements of a list, we behead and knife it:

```
bk

```

If we wanted to perform this operation on every element of a list, we can use a map operation:

```
{bk}ᵐ

```

However, it's a byte shorter to split the predicate into two, and map each part separately:

```
bᵐkᵐ

```

The same trick can be used with quite a few metapredicates:

```
{bk}ᵐ  →  bᵐkᵐ
{bk}ˢ  →  bˢkˢ
{bk}ᶠ  →  bᶠkˢ
~{bk}  →  ~k~b

```

Note that for some metapredicates, like , there's no general-purpose way to split it into two parts, but it may nonetheless be possible to find a decomposition that works for the specific task you're working on.
> 5 votes

# Answer
# We do have an increment builtin... sometimes!

`+₁` is the only *reliable* way to add 1 to something. However, under many circumstances, `<` does the job for a byte less--its output must be strictly greater than its input, so in the absence of external complications, its output will be the integer strictly greater than its input with the least absolute value.

Of course, this substitution can and will fall apart should further logic be employed, as well as in the case of non-integers (which are ceiled) and negative integers (which produce 0).
> 4 votes

# Answer
# `s` isn't longest first, but  is

I wanted to title this "(Ab)use all choice orders at your disposal", but I couldn't think of any other cases of note.

Sometimes choice order is pretty important. Sometimes the choice order your program already has is precisely what you need, just as often it's not; in the case of `s` generating substrings in the order of largest-first prefixes of largest-first suffixes, it's not infrequent that you might wish it was simply largest first instead. Fortunately,  generates its sublists longest first, where every possible substring is included--there's just some other stuff you also don't want. However, `s`'s choice order is no problem at all if you're using it to check substring existence, in a program structured something like `⊇. [...] &s`.
> 4 votes

# Answer
# Casting the empty list to the empty string

Sometimes, when working with strings, the algorithm we use might unify what we want with the empty list `[]`, when we would rather want the empty string `""`.

We can cast the empty list to the empty string using `,Ẹ`, which appends the empty string to its left variable (this is an exploit of the way `,` is implemented).

This also has the benefit that it does not do anything if the left variable is a string. So, if your program is

```
{
   some predicate that should always output a string,
   but actually outputs [] instead of "" in specific cases
}

```

Then

```
{
  some predicate that should always output a string,
  but actually outputs [] instead of "" in specific cases
},Ẹ

```

will work the way you want.
> 3 votes

# Answer
# Single-element runs in a list

Consider this snippet:

```
ḅ∋≠

```

If the input is a list or string, the output is unified with a sublist/substring of length 1 that's not part of a longer run of equal elements. It splits the list into blocks of equal elements and finds a block whose elements are all different. To get the elements themselves instead of singleton lists, tack `h` to the end. I used this construct here with `o` to find a character that occurs only once in the input string.
> 3 votes

# Answer
# Failing on empty lists

Empty lists can come up often, and sometimes you need to fail when you see one. The obvious means to do so may be `¬Ė`, or even `l>0`, but there exist quite a few one-byte alternatives:

* `b`
* `k`
* `h`
* `t`
*
* `z`

just off the top of my head. What inspired me to write this out is actually the discovery of a less obvious failure on an empty list: the metapredicate , which one might expect to be vacuously successful on an empty input, fails instead. Metapredicates which produce failure on an empty list:

*
*
*
* (any list of length other than 2)
* `ʰ`
*

The general idea to take away from this is that a lot of Brachylog's builtins that seem like they're just to produce an output from an input don't necessarily have an output for every conceivable input, which is more to our advantage than it is detrimental, and is (...usually) easy to think about once you're aware of it.
> 3 votes

---
Tags: code-golf, tips
---