# Question
Title: Fastest N times Hello World (Java/C/ C++)
Not a new one:

**Input** N, being n, 0 ≤ n ≤ 5.

**Output** N times "Hello World."

Example:

**Input**

3

**Output**

```
Hello World.
Hello World.
Hello World.

```

These 2 are my best solutions:

**First**

```
public class Out
{
    public static void main(String[] a) throws Exception
    {
            java.io.OutputStream o = System.out;
            byte n = Byte.parseByte(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine());
            for(byte i = 0;i<n;i++){
                o.write("Hola mundo.\n".getBytes());
            }
    }
}

```

**Second**

```
public class Out
{
    public static void main(String[] a) throws Exception{
        byte n = Byte.parseByte(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine());
        while(n>0){switch(n){case 0: w();break;case 1: w();break;case 2: w();break;case 3: w();break;case 4: w();break;case 5: w();break;}n--;}
    }

    static void w() throws Exception{
        System.out.write("Hola mundo.\n".getBytes());
    }
}

```

According to the server it is being tested on ( im not an owner of that server), first attempt gives me 0.006ms and 622 KiB while second attempt gives me same time with 625 KiB.

I am not able to provide the Java version being used but if you want, feel free to use the main site ( spanish language ) https://www.aceptaelreto.com/problem/statement.php?id=116

P.S.: Some peoeple were able to get it on 0.005ms and 88KiB.

edit: -this code is being benchmarked on the link used before. -The point is to get the fastest code ( and if possible, with the least amount of memory used), not the shortest one.

Apparently Im not able to use comments since I do not have the required reputation score.

# Answer
C++11 approach (Time: `3.6 µs` on some Intel i7, File size of `a.out`: 28K) compiled via:

`clang -O3 -march=native -Ofast golf.cpp`: (Clang 6.1)

```
#include <iostream>
#include <chrono>
#include <sstream>

int main(int argc, char** argv) {
  auto t1 = std::chrono::high_resolution_clock::now();
  const int n = 5;
  if (n < 0 || n > 5) return 1;
  std::stringstream ss;
  for (size_t i = 0; i < n; i++) ss << "Hello world\n";
  std::cout << ss.str();
  auto t2 = std::chrono::high_resolution_clock::now();
  auto duration = std::chrono::duration_cast<std::chrono::microseconds>( t2 - t1 ).count();
  std::cout << duration << "µs" << std::endl;
  return 0;
}

```
> 1 votes

# Answer
Using C (size \<12 KiB, time \< 0.001s)

```
$ cat >hola.c <<END_C
#include<unistd.h>
int main(){
  int i,n;
  read(0,&n,1);
  for(i='0';i<n;++i){
    write(1,"Hola mundo.\n",12);
  }
}
END_C

$ gcc hola.c -o hola

$ wc -c hola
11944 hola

$ time ./hola <<<5
[...]
real    0m0.001s
user    0m0.000s
sys     0m0.000s

```
> 1 votes

---
Tags: string, number, fastest-code, java
---


# Question
Title: Consistent Overhead Byte Stuffing (COBS)
I'm surprised this hasn't been posted before!

The Consistent Overhead Byte Stuffing (COBS) algorithm is used to delimit byte streams.

We choose a frame marker (we'll use 0x00) and wherever 0x00 occurs in the stream it is replaced with the number of bytes until the next 0x00 occurs (we'll call this a milestone). This reduces the range of values from 0..255 to 1..255, enabling 0x00 to unambiguously delimit frames in the stream.
At a milestone, if the next 255B does not contain 0x00 this exceeds the maximum milestone length - the algorithm must 'stall' at 255B and put another milestone. This is the 'consistent overhead'.
The first byte will be the first milestone, the final milestone will be the number of bytes until the frame marker.

Some examples from Wikipedia (best to read the article where they are coloured):

```
0x00 as frame marker

Unencoded data (hex)    Encoded with COBS (hex)
00                      01 01 00
00 00                   01 01 01 00
11 22 00 33             03 11 22 02 33 00
11 22 33 44             05 11 22 33 44 00
11 00 00 00             02 11 01 01 01 00
01 02 03 ... FD FE      FF 01 02 03 ... FD FE 00
00 01 02 ... FC FD FE   01 FF 01 02 ... FC FD FE 00
01 02 03 ... FD FE FF   FF 01 02 03 ... FD FE 02 FF 00
02 03 04 ... FE FF 00   FF 02 03 04 ... FE FF 01 01 00
03 04 05 ... FF 00 01   FE 03 04 05 ... FF 02 01 00

```

**Challenge:** to implement this in the shortest program.

* Input is an unencoded byte stream/array, output is an encoded byte stream/array
* Use any sort of binary standard input/output
* The final frame marker is not necessary
* The program can return an oversized array
* A stream ending with 254 non-zero bytes does not require the trailing 0x00

**Notes**

* The worst-case return length is `numBytes + (numBytes / 254) + 1`

**Example**

We have the byte array

```
[0] 0x01
[1] 0x02
[2] 0x00
[3] 0x03
[4] 0x04
[5] 0x05
[6] 0x00
[7] 0x06

```

For each `0x00` we need to state (in a milestone) where the next `0x00` would have been.

```
[0] 0x03   #Milestone. Refers to the original [2] - "The next 0x00 is in 3B"
[1] 0x01   #Original [0]
[2] 0x02   #Original [1]
[3] 0x04   #Milestone. Refers to the original [6] - "The next 0x00 is in 4B"
[4] 0x03   #
[5] 0x04   #
[6] 0x05   # Originals [3..5]
[7] 0x02   #Milestone. Refers to the end frame marker
[8] 0x06   #Original [7]
[9] 0x00   #Optional. End frame marker.

```

# Answer
> 2 votes
# JavaScript (Node.js), 114 bytes

```
a=>(g=([v,...a])=>1/v?[v||a.indexOf(0)+1,...g(a)]:[])([0,...a,0].flatMap((v,j)=>1/a[j]&&(i=v&&i+1)>253?[v,i=0]:v))

```

Try it online!

# Answer
> 2 votes
# Java (JDK), 143 bytes

```
a->{int l=a.length,r[]=new int[l+2],i=0,j=1,x=1,z=0;for(;i<l;){if(a[i]>0)r[j++]=a[i];if(a[i++]<1||++x>254){r[z]=x;z=j++;x=1;}}r[z]=x;return r;}

```

Try it online!

# Answer
> 1 votes
# Python 2, 125 bytes

```
def f(a):
 r=[[]]
 for v in a:r+=[[]]*((len(r[-1])>253)+(v<1));r[-1]+=[v]*(v>0)
 return sum([[len(x)+1]+x for x in r],[])+[0]

```

Try it online!

# Answer
> 1 votes
# Jelly, 27 bytes

```
Oµ=0ks€254Ẏḟ€0L‘;Ɗ€F;Ṫ¬x`ƊỌ

```

Try it online!

A monadic link that takes an unencoded byte array as input and returns the encoded byte array. As per the rules, the final frame marker is omitted.

### Explanation

```
Oµ                          | Convert to integer and start a new monadic chain
  =0k                       | Split after zeros
     s€254                  | Split each list into length 254 lists
          Ẏ                 | Tighten (reduce list depth by 1)
           ḟ€0              | Filter zeros out from each list
              L‘;Ɗ€         | Prepend the list length plus one to each list
                   F        | Flatten
                    ;Ṫ¬x`Ɗ  | Append an additional 1 if the original list ended with zero
                          Ọ | Convert back to bytes

```

# Answer
> 1 votes
# Elixir, 109 bytes

```
&Regex.replace~r/(^|(?<=([^\0]{254}))(?!$)|\0)((?2)|[^\0]*?(?=\0|$))/,&1,fn _,_,_,x-><<1+byte_size x>><>x end

```

Try it online!

# Answer
> 0 votes
# , 103 chars

Notice the result from the last test case is different from wiki and other languages. This is due to this pointer to 254-th zero byte at the boundary. Things get a lot easier, if this isn't treated as a special case.

```
f =: 3 : 0
  k =. I. (y,0)=0
  s =. - 2 (-/) \ k
  (>: y i. 0), s (}:k) } y
 )

 f2 =: 3 : 0
   f each _254 <\ y
 )

```

Try It Online

---
Tags: code-golf, array, algorithm
---


title: Can the maze be solved?

text:
# Question
Title: Can the maze be solved?
## Task

* Print 0 if an `n*m` maze cannot be solved
* Print 1 if an `n*m` maze can be solved (in 1 or more ways)

(so I'm not asking for paths but if it's possible to solve!!!)

## Example

Input array(2d):

```
[[0,0,0,0,0,0,1],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[1,0,0,0,0,0,0]]

XXXXXXXXX
XS     XX
X     X X
X    X  X
XX     FX
XXXXXXXXX

0 = can pass through
1 = can not pass trough
[0][n] is the last block of the first line
[m][0] is the first block of the last line

```

**Rule** The start position is 0,0 and the end position is n,m You can only move horizontally and vertically Shortest code wins

# Answer
# Dyalog APL, 27 characters

`⊃⌽∨.∧⍨⍣≡1≥+/¨|∘.-⍨,(~×⍳∘⍴)⎕`

evaluated input. APL distinguishes between a matrix and a vector of vectors. This program assumes that the input is a matrix.

`(~×⍳∘⍴)A` is a fork equivalent to `(~A) × ⍳⍴A`. It's needed to avoid mentioning  twice or introducing a variable.

`⍴A` is the shape of `A`. For a 4-by-7 matrix the shape is `4 7`.

is the index generator. `⍳4` is `1 2 3 4`. `⍳4 7` is the vectors `(1 1)(1 2)...(4 7)` arranged in a 4-by-7 matrix.

`~A` flips the bits of `A`.

`×` by multiplying `⍳⍴A` by the flipped bits, we preserve the coordinates of all free cells and turn all walls into `0 0`.

`,` ravels the matrix of coordinate pairs, i.e. linearizes it into a vector. In this case the vector will consist of pairs.

`∘.-⍨A` or `A∘.-A` subtracts elements of `A` pairwise. Note that here the elements of `A` are themselves pairs.

`|` absolute value

`+/¨` sum each pair of absolute values. This gives us the grid distances between every pair of cells in the maze, save for walls.

`1≥` we are only intrested in neighbours at a distance no more than 1, this also excludes walls. Now we have a graph's adjacency matrix.

`∨.∧⍨⍣≡` Floyd--Warshall's transitive closure algorithm

`(f⍣n)A` (not used here) where `n` is an integer is the power operator. It applies `f` to `A` `n` times: `f f ... f A`.

`(f⍣g)A` where `g` is a function, is the fixed point operator, a.k.a. "power limit". It keeps on computing the series `A`, `f A`, `f f A`, ... until `((f⍣i)A) g ((f⍣(i+1))A)` returns true for some `i`. In this case we use match () as `g`.

`∨.∧⍨A` or `A∨.∧A` is a step in Floyd's algorithm. `f.g` is a generalisation of matrix multiplication (`+.×`), here we use conjunction () and disjunction () in place of `+` and `×`.

`⊃⌽` After `⍣≡` has applied the step enough times and reached a stable state, we must look up the top-right corner of the matrix to get the result, so we flip it () and take the first, top-left item ().

Visualization of `⍣≡`'s steps
> 8 votes

# Answer
# CJam, 42 41 39 36 35 bytes

```
Wq3>~_s,{{[{_2$+0<{e<_}*}*]}%z}*sW=

```

Based on the ideas in this answer.

4 bytes thanks to Optimizer.

Input format:

```
[[0 0 0 0 0 0 1] [0 0 0 0 0 1 0] [0 0 0 0 1 0 0] [1 0 0 0 0 0 0]]

```
> 7 votes

# Answer
# Python, 164 bytes

```
def s(a):
 d=[(0,0)]
 while d:i,j=d.pop();a[i][j]=2;d+=[(x,y)for x,y in[(i-1,j),(i,j-1),(i+1,j),(i,j+1)]if len(a[0])>y>-1<x<len(a)and a[x][y]<1]
 return a[-1][-1]>1

```

I was reluctant to post this because it's practically how I'd normally do flood fill, just lightly golfed. But here it is anyway.
> 6 votes

# Answer
## Perl, 73 bytes

69 bytes of code + 4 bytes for `-n0E` (not sure how the tags where counted in 2014, so I counted them for 4 instead of 2, but it doesn't matter a lot).

```
/.*/;s/(^0|A)(.{@{+}})?0/A$2A/s||s/0(.{@{+}})?A/A$1A/s?redo:say/A$/+0

```

Try it online! (and if you replace the `1111011` line with `1111111`, the maze isn't solvable anymore, and the output will be `0` instead of `1` : Try it online!)

**Explanations:**

This code will find every reachable cell of the maze (and mark them with a `A`): if a cell touches a cell marked with a `A`, the it's reachable and we mark it with a `A` too; and we do that again (`redo`). That's done thanks to two regex: `s/(^0|A)(.{@{+}})?0/A$2A/s` checks if a space is on the right or the bottom of a `A`, while `s/0(.{@{+}})?A/A$1A/s` checks if a space is on the left or on top of a `A`. At the end, if the last cell contains a `A` it's reachable, otherwise it's not (that's what `say/A$/+0` checks; the `+0` is here to make sure the result will be `0` or `1` instead of *empty string* and `1`).
Note that `/.*/` will match an entire line, thus setting `@+` to the index of the end of the first line, which happens to be the size of a line, which allow use to use `.{@{+}}` to match exactly as many character as there are on a line. (`@{+}` is equivalent to `@+`, but only the former can be used in regex)
> 4 votes

# Answer
# Ruby, ~~133~~ ~~130~~ 129 characters

```
a=eval gets
f=->x,y{a[x][y]=1
[[-1,0],[1,0],[0,-1],[0,1]].map{|o|d,e=x+o[0],y+o[1]
f[d,e]if a[d]&&a[d][e]==0}}
f[0,0]
p a[-1][-1]

```

Input on STDIN, outputs `1` or `0` on STDOUT.

Annoyingly long. It simply does a flood-fill of `1`s from `(0, 0)`, and then checks to see whether the "end" square is a `1`.
> 3 votes

# Answer
### Java, 418 bytes

```
import java.util.Scanner;public class Solvable{static int w,h;public static void main(String[] a){String[]i=new Scanner(System.in).nextLine().split(";");h=i.length+2;w=i[0].length()+2;int[]m=new int[w * h];for(int x=1;x<w-1;x++)for(int y=1;y<h-1;y++)m[y*w+x]=i[y-1].charAt(x-1)<'.'?0:1;f(m,w+1);System.out.println(m[w*h-w-2]>0?0:1);}static void f(int[]m,int i){if(m[i]>0){m[i]--;f(m,i-1);f(m,i+1);f(m,i-w);f(m,i+w);}}}

```

My first code golf. I don't know why I chose Java - it's so bad for golfing xD

Example maze would be inputted via stdin like this:

```
......#;.....#.;....#..;#......

```
> 2 votes

# Answer
## Python 184 ~~188~~

```
def f(a,x=0,y=0,h=[]):s=h+[[x,y]];X,Y=len(a[0]),len(a);return([x,y]in h)==(x>=X)==(y>=Y)==(x<0)==(y<0)==a[y][x]<(x==X-1and y==Y-1or f(a,x-1,y,s)|f(a,x+1,y,s)|f(a,x,y-1,s)|f(a,x,y+1,s))

```

This got much longer than I thought it would be :( Anyway, I'll add an explanation once I can't golf it any longer.
> 1 votes

# Answer
## J, 75 chars

Powering of the adjacency matrix (very time and memory inefficient). *(Is it called powering in English?)*

```
   ({.@{:@(+./ .*.^:_~)@(+:/~@,*2>(>@[+/@:|@:->@])"0/~@,@(i.@#<@,"0/i.@#@|:)))

```

Some test cases:

```
   m1=. 0 0 0 0 0 0 1,. 0 0 0 0 0 1 0,.  0 0 0 0 1 0 0,. 1 0 0 0 0 0 0
   m2=. 0 1 1 ,. 0 0 0
   m3=. 0 1 0 ,. 1 1 0
   m4=. 0 1 1 0 ,. 0 0 1 0
   ({.@{:@(+./ .*.^:_~)@(+:/~@,*2>(>@[+/@:|@:->@])"0/~@,@(i.@#<@,"0/i.@#@|:))) every m1;m2;m3;m4
1 1 0 0

```
> 1 votes

# Answer
# Python 3, 136 bytes

```
def f(g,x=0,*p):w=len(g[0])+1;l=w*len(g);return~x%w*(-1<x<l)*~-(x in p)and any(g[x//w][x%w]and f(g,x+a,*p,x)for a in(1,-1,w,-w))or-~x==l

```

Try it online!

Uses `0` for wall, `1` for free space.

Port of my answer to Find the shortest route on an ASCII road.
> 1 votes

# Answer
# Python 3, 184 bytes

```
f=lambda m,x=0,y=0,n=0:n<len(m)*len(m[0])and m[x][y]<1and((x,y)==(len(m)-1,len(m[0])-1)or any(0<=i<len(m)and 0<=j<len(m[0])and f(m,i,j,n+1)for i,j in[(x-1,y),(x,y-1),(x+1,y),(x,y+1)]))

```

Try it online!
> 0 votes

---
Tags: code-golf, decision-problem, graph-theory, path-finding, maze
---


# Question
Title: Implement the Max-Pooling operation from Convolutional Neural Networks
In convolutional neural networks, one of the main types of layers usually implemented is called the **Pooling Layer**. Sometimes, the input image is big (and therefore time consuming especially if you have a big input set) or there is sparse data. In these cases, the objective of the Pooling Layers is to reduce the spatial dimension of the input matrix (even though you would be sacrificing some information that could be gathered from it).

A Max-Pooling Layer slides a window of a given size \\$k\\$ over the input matrix with a given stride \\$s\\$ and get the max value in the scanned submatrix. An example of a max-pooling operation is shown below:

In the example above, we have an input matrix of dimension 4 x 4, a window of size \\$k=2\\$ and a stride of \\$s=2\\$.

# Task

Given the stride and the input matrix, output the resulting matrix.

# Specs

* Both the input matrix and the window will always be square.
* The stride and the window size will always be equal, so \\$s=k\\$.
* The stride is the same for the horizontal and the vertical direction
* The stride \\$s\\$ will always be a nonzero natural number that divides the dimension of the input matrix. This guarantees that all values are scanned by the window exactly once.
* Input is flexible, read it however you see fit for you.
* Standard loopholes are not allowed.

# Test Cases

```
Format:
s , input, output

2, [[2, 9, 3, 8], [0, 1, 5, 5], [5, 7, 2, 6], [8, 8, 3, 6]] --> [[9,8], [8,6]]
1, [[1, 2, 3], [4, 5, 6], [7, 8, 9]] --> [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
4, [[12, 20, 30, 0], [8, 12, 2, 0], [34, 70, 37, 4], [112, 100, 25, 12]] --> [[112]]
3, [[0, 1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53], [54, 55, 56, 57, 58, 59, 60, 61, 62], [63, 64, 65, 66, 67, 68, 69, 70, 71], [72, 73, 74, 75, 76, 77, 78, 79, 80]] --> [[20, 23, 26], [47, 50, 53], [74, 77, 80]]

```

This is , so shortest answers in bytes wins!

# Answer
> 9 votes
# Python 3, 101 ~~108~~ bytes

```
def f(m,w):r=range(0,len(m),w);return[[max(sum([x[i:i+w]for x in m[j:j+w]],[]))for i in r]for j in r]

```

Thanks to Jo King and Jonathan Allan for some more bytes off!

Try it online!

Alternate (longer) version as a single Lambda expression:

Try it online!

# Answer
> 8 votes
# Jelly, 6 bytes

```
»⁹/Z$⁺

```

A dyadic Link accepting the matrix (list of lists) on the left and the window size on the right which yields a matrix (list of lists).

**Try it online!**
Or see all windows of a 24\*24 grid pooled at each possible granularity

### How?

```
»⁹/Z$⁺ - Link: M, k
    $  - last two links as a monad - i.e. f(X) where X is initially M
  /    -   reduce (X)...
 ⁹     -     ...in chunks of: chain's right argument (k)
»      -     ...by: (left) maximum (right) (this vectorises across the k rows)
   Z   -   transpose the resulting matrix
     ⁺ - repeat the last link - i.e. f(that result)

```

# Answer
> 7 votes
# Octave with Image Package, 38 bytes

```
@(M,s)blockproc(M,[s s],@(b)max(b(:)))

```

Try it online!

# Answer
> 7 votes
# , ~~15~~ 14 bytes

*-1 byte, thanks @Bubbler*

The left argument is the matrix and the right argument is the stride.

```
>./@,;.3~2 2&$

```

Try it online!

# Answer
> 6 votes
# , <sub>~~13~~</sub> 12 bytes

```
>./\&|:^:2~-

```

Try it online!

... When I said "`;.3` is the right tool for the job", I was wrong. This challenge is so simple that an alternative method can get to fewer bytes.

### How it works

```
>./\&|:^:2~-  Left argument: matrix, Right argument: stride (s)
           -  Negate the right argument
       ^:2~   Run the thing twice, with flipped arguments:
              (now the left is -s, right is matrix)
    &|:         Transpose both the matrix and -s
                (transpose on -s is no-op)
>./\            Run "reduce by max" on each of non-overlapping intervals of
                length s, in the primary dimension
              By running this twice, we achieve max pooling in two dimensions

```

# Answer
> 5 votes
# Python 2, 68 bytes

```
lambda M,k:eval("map(lambda*l:map(max,zip(*[iter(l)]*k)),*"*2+"M))")

```

Try it online!

---

**74 bytes**

```
lambda M,k:eval("zip(*map(lambda*N:map(max,*N*2),*k*[iter("*2+"M)])))]))")

```

Try it online!

I can't even ...

# Answer
> 5 votes
# APL (Dyalog Unicode), 20 bytes

```
{⌈⌿⍤2⌈/⍵}⊢⍴⍨4⍴÷⍨∘≢,⊣

```

Try it online!

I'm pretty sure converting the dfn part into an atop `(⌈⌿⍤2⌈/)` should work (and save a byte), but there seems to be an anomaly that prevents me from running multiple test cases with that version.

### How it works

```
{⌈⌿⍤2⌈/⍵}⊢⍴⍨4⍴÷⍨∘≢,⊣  left: stride (s), right: matrix
              ÷⍨∘≢    a = size of matrix divided by stride
                  ,⊣  Concatenate a with s
            4⍴        Create a length-4 array (a s a s)
         ⊢⍴⍨          Reshape the matrix into a 4-dimensional array with shape a,s,a,s
{       }             Pass the result into the dfn...
     ⌈/⍵              Take the max through the 4th axis (shape: a,s,a)
 ⌈⌿⍤2                 Take the max through the 2nd axis (shape: a,a)

```

APL also has an operator called "Stencil"  that is similar to J's "Subarrays" `;.3`, but it has a weird starting location, making it clunky to use for this challenge.

# Answer
> 3 votes
# , 23 bytes

```
(#@];~@$1{.~[)>./@,;.1]

```

Try it online!

# Answer
> 3 votes
# 05AB1E, ~~8~~ 7 bytes

```
ôεø¹ôεZ

```

-1 byte thanks to *@Grimy*.

Stride as first input and matrix as second input.

Try it online or verify all test cases.

**Explanation:**

```
ô        # Split the rows of the (implicit) input-matrix into
         # the (implicit) input-integer amount of groups
         #  i.e. [[12,20,30,0],[8,12,2,0],[34,70,37,4],[112,100,25,12]] and 2
         #   → [[[12,20,30,0],[8,12,2,0]],[[34,70,37,4],[112,100,25,12]]]
 ε       # Map each group of rows to:
  ø      #  Zip/transpose; swapping rows/columns
         #   i.e. [[12,20,30,0],[8,12,2,0]] → [[12,8],[20,12],[30,2],[0,0]]
   ¹ô    #  Split the columns into the input-integer amount of groups as well
         #   i.e. [[12,8],[20,12],[30,2],[0,0]] → [[[12,8],[20,12]],[[30,2],[0,0]]]
     ε   #  Inner map over each block:
      Z  #   And get the flattened maximum of the block
         #    i.e. [[12,8],[20,12]] → 20
         # (after which the result is output implicitly)

```

# Answer
> 3 votes
# Wolfram Language (Mathematica), 23 bytes

```
BlockMap[Max,#2,{#,#}]&

```

Try it online!

# Answer
> 3 votes
# dzaima/APL, ~~14~~ 12 bytes

```
⊣t¨t←⌈/⍬∘⍮⍛⍴

```

Try it online!

# Answer
> 2 votes
# Python 3, ~~275~~ ~~196~~ ~~184~~ ~~163~~ ~~159~~ 111 bytes

```
def f(s,m):r=range(len(m)//s);return[[max(b for k in range(s)for b in m[i*s+k][j*s:][:s])for j in r]for i in r]

```

Try it online!

Thanks to:
\- @randomdude999 for saving me 12 bytes
\- @Jitse for saving 48 bytes

# Answer
> 2 votes
# JavaScript (ES6), 85 bytes

Takes input as `(s)(matrix)`.

```
s=>m=>m.map((r,y)=>r.map((v,x)=>(r=M[Y=y/s|0]=M[Y]||[])[x=x/s|0]>v?0:r[x]=v),M=[])&&M

```

Try it online!

# Answer
> 2 votes
# Charcoal, 24 bytes

```
ＮθＩＥ⪪ＥＡＥ⪪ιθ⌈λθＥ§ι⁰⌈Ｅι§νμ

```

Try it online! Link is to verbose version of code. Outputs each maximum on its own line, with matrix rows double-spaced. Explanation:

```
Ｎθ                          Input the stride
      Ａ                     Input matrix
     Ｅ                      Map over rows
         ι                  Current row
        ⪪ θ                 Split (horizontally) into windows
       Ｅ                    Map over windows
            λ               Current window
           ⌈                Take the maximum
    ⪪        θ              Split vertically into windows
   Ｅ                        Map over windows
              Ｅ§ι⁰          Map over horizontal maxima
                   Ｅι       Map over windowed rows
                     §νμ    Get windowed cell
                  ⌈         Take the maximum
  Ｉ                         Cast to string for implicit print

```

`Ｅ§ι⁰Ｅι§νμ` is effectively the nearest Charcoal has to a transpose operation, although obviously I can at least take the maximum of the transposed column in situ.

# Answer
> 1 votes
# Stax, 11 bytes

```
ó╚←XF«≡ûÖçx

```

Run and debug it at staxlang.xyz!

### Unpacked (13 bytes) and explanation

```
X/{Mx/{:f|Mmm
X                Save window size to register X
 /               Take groups of X rows
  {         m    Map block over groups:
   M               Transpose (gets list of column segments)
    x/             Take groups of X column segments (our windows)
      {    m       Map block over windows:
       :f|M          Flatten and take maximum

```

Leaves the result on the stack, since arrays print as strings. That makes the output hard to determine. Here's a pretty version.

# Answer
> 1 votes
# Ruby, 57 bytes

```
->m,w{g=->r{r.transpose.each_slice(w).map &:max};g[g[m]]}

```

Try it online!

# Answer
> 1 votes
# Japt, 24 bytes

```
mòY=UÊzV)Õc òYp)®rwÃòV y

```

Try it

```
U.m("ò", // split each row by..
 Y = U.l().z(V)) // input size / s
.y() // transpose
.c() // flatten
.ò(Y.p()) // split in Y*Y chunks
.m(function(Z) { return Z.r("w") }) // max of each
.ò(V) // rematrix
.y() // retranspose

```

---
Tags: code-golf, matrix, neural-networks
---


title: Currency exchange

text:
# Question
Title: Currency exchange
You are starting up a cryptocurrency exchange website which supports conversion from USD to two currencies, foo-coin and bar-coin. Write a program that takes the exchange rate for each coin to USD as arguments and outputs the maximum value of USD that cannot be completely divided into the two currencies (assuming these crypto-coins can only be purchased as full coins):

e.g. If the two exchange rates are $23 and $18, then 41 dollars could be split into 1 foo-coin and 1 bar-coin, but there is no way to completely split 42 dollars between the two coins. The output of the program for these two values is 373, as that is the largest dollar amount that CANNOT be divided into whole values of foo-coin and bar-coin.

Winner is the program with the fewest characters.

edit: You may assume the GCD of the two rates is 1

# Answer
> 4 votes
# 05AB1E, 3 bytes

```
<P<

```

Try it online!

This is of course only assuming that the greatest common denominator of the inputs (exchange rates) is 1, because otherwise this number is not well-defined.

**Explanation:**

The number we want to compute is called the Frobenius Number and can be calculated with the formula \\$\operatorname{Frob}(a,b) = (a-1)(b-1) - 1\\$.

```
<    | Subtract 1 from each input
 P   | Take their product
  <  | Subtract 1

```

# Answer
> 1 votes
# Pyth, 7 bytes

```
t*thQte

```

Try it online!

As @Wisław pointed out, this is simply the Frobenius Number. Also uses `(a-1)(b-1)-1`, as the alternate `ab-a-b` is a bit longer.

## How it works

```
 *thQ   - Multiply the first number minus one
     te - By the second number (the Q is implicit) minus one
t       - Minus one

```

# Answer
> 1 votes
# Swift, 42 bytes

```
func d(f:Int,b:Int)->Int{return f*b-(f+b)}

```

Try it online!

---
Tags: code-golf
---


title: Can you handle the pub?

text:
# Question
Title: Can you handle the pub?
## Background

It's late Friday afternoon and you and your friends decide to hit the pub later that evening, but before going to the pub you figure you should have a few beverages. However, things escalate quickly; your friend Shaddock Pamplemousse won the lottery earlier this week and decided to bring crates upon crates with different beverages. The security at the pub is very strict, and if you overconsume before trying to enter the premises you are not allowed inside. You are all programmers though - so you figure things will turn out great anyway.

## Challenge

You need to program an alcohol meter which outputs truthy/falsy if you're above/below the reasonable pub limit. Before you go down to the pub you enter the amount and beverage type you've consumed during the evening to `stdin` which your measurement program reads. If it outputs truthy, you are above the pub limit and stay at home. If it outputs falsy, you're good to go.

## Input

One integer greater than `0` which represents your body weight in kilograms followed by a newline. This input is followed by a series of one digit amounts and beverages on the following form:

```
<amount><amount type>o<beverage type>

```

For one bottle of beer this will look like:

```
1Bob

```

Each input is separated by a space.

**Input specification**

Each beverage has a unit which correspond to the impact caused by it. If you consume more units than your weight divided by two the pub is not an option anymore.

*(This may or may not reflect reality)*

The following are valid beverages and the corresponding alcoholic units of the beverage:

* Beer: `b`, `1` unit
* Energy drink: `e`, `0` units
* Hot sauce: `h`, `2` units (strong stuff)
* Juice (made of organic fruits etc): `j`, `0` units
* Rum: `r`, `6` units
* Tequila: `t`, `7` units
* Vodka: `v`, `6` units
* Wine: `w`, `3` units

There are different amount types:

* Bottle: `B`
* Crate: `C`
* Glass: `G`
* Keg: `K`
* Sip: `S`

Each amount type has a multiplier which multiplies the alcoholic units of the beverage contained in it:

* Bottle: `3`
* Crate: `25`
* Glass: `2`
* Keg: `50`
* Sip: `0.2`

## Output

Your program shall output truthy/falsy to `stdout` if the amount consumed is above/below your body weight divided by 2. If the amount consumed is equal to your weight divided by 2, you should output falsy.

## Samples of possible input and output

**Input**

```
70
1Bob 3Soj

```

**Output**

```
False

```

**Input**

```
2
1Cov

```

**Output**

```
1

```

**Input**

```
50
1Cob

```

**Output**

```
0

```

**Input**

```
100
4Gow 1Koe 1Bov 1Gow 2Sot

```

**Output**

```
True

```

The shortest program in bytes wins!

# Answer
> 5 votes
# CJam, 53 bytes

```
6:B50:C2*:K4:G.4:S];q"behjrtvwo ""10206763*"er~*]:-U<

```

Try it online in the CJam interpreter.

### How it works

```
6:B          e# Push 6 and save it in B.
50:C         e# Push 50 and save it in C.
2*:K         e# Multiply by 2 to push 100 and save it in K.
4:G          e# Push 4 and save it in G.
.4:S         e# Push 0.4 and save it in S.
             e#
             e# The letters representing the types will now push its doubled
             e# (to avoid diving the weight by 2) associated multiplier.
];           e# Clear the stack.
q            e# Read all input.
"behjrtvwo " e# Push the string of beverages, concatenated with "o ".
"10206763*"  e# Push the string of associated units of alcohol and '*'.
er           e# Transliterate. This replaces each beverage letter with the
             e# associated units of alcohol, and each 'o' and ' ' with '*'.
             e#
             e# For example, the input
             e# 70
             e# 1Bob 3Soj
             e# is transformed into
             e# 70
             e# 1B*1*3S*0
             e#
~            e# Evaluate the resulting string.
             e#
             e# For the example this does the following:
             e#   + Push 70.
             e#   + Push 1, push 6, multiply, push 1, multiply.
             e#   + Push 3, push 0.4, multiply, push 0.
             e#
*            e# Multiply the last two (for the lack of a trailing space).
]            e# Collect all results in an array.
:-           e# Reduce by subtraction; subtract all other elements from the
             e# first element (body weight).
U<           e# Compare the result with 0.

```

# Answer
> 9 votes
# Python 3, 131

Now we're golfing with snakes!

Saved 18 bytes thanks to shebang.
Saved 4 more bytes thanks to DSM.
Saved a lot of bytes thanks to tzaman.

Many thanks to tzaman for his brilliant trick of abusing `.find()` returning `-1` if it doesn't find a value.

Currently this assumes this drink format is exactly the way it's stated in the challenge, eg, only 1 digit worth of each drink.

```
w=input()
print(sum([6,50,4,100,.4]['BCGKS'.find(b)]*int(a)*int('1267730'['bhrtvw'.find(v)])for a,b,_,v in input().split())>int(w))

```

# Answer
> 5 votes
## Minkolang 0.11, 59 bytes

```
126763355*25l*2l$:"SKGCBwvtrhb"m(0pI)n(no0qoxo0q**2*-$I)`N.

```

Try it here.

### Explanation

```
126763355*25l*2l$:    Pushes the values of the characters
"SKGCBwvtrhb"         Pushes the characters themselves
m                     Merge; interleaves the first and second halves of the stack
(                     Open while loop
 0p                   Put character's value in character's place in the codebox
   I)                 Close while loop when stack is empty
n                     Read in integer (weight)
(                     Open while loop
 n                    Read in integer, ignoring any non-numeric characters
  o0q                 Read in character and get its value from the codebox
     ox               Read in character and dump it
       o0q            Read in character and get its value from the codebox
          **          Multiply the three numbers together
            2*-       Multiply by 2 and subtract from weight
               $I)    Close while loop when input is empty
`                     1 if less than 0, 0 otherwise
 N.                   Output as integer and stop.

```

# Answer
> 4 votes
## CJam, 54 bytes

```
ldlS/{A,s"CbretjvwSBK"+f#A,[25X6T7T6Z.2Z50Y]+f=:*-}/0<

```

Bit fiddly and probably suboptimal, but I think this works okay. Try it online.

### Explanation

```
ld             Read first line, convert to double
lS/            Read second line, split by space
{...}/         For each item in the second line...
  A,s"..."+f#    Get index in "0123456789CbretjvwSBK", or -1 if not found
  A,[...]+f=     Index into [0 1 2 3 4 5 6 7 8 9 25 1 6 0 7 0 6 3 0.2 3 50 2]
  :*             Take product
  -              Subtract from weight
0<             Check if < 0

```

Note that the numeric array has 2 at the end, meaning that `Gho`, which are missing from the first string, get mapped to 2.

# Answer
> 3 votes
# CJam, 77

```
qN%~S%{:BW="behjrtvw"\#10206773s:~\=[3 25 2 50 .2]"BCGKS"B-3=#=*1mO}%:+\~2/\>

```

# Answer
> 3 votes
# VBA, 251 bytes

```
Function k(x) As Boolean:q=Split(x):g="b1e0h2j0r6t7v6w3":h="B03C25G02K50S.2":For i=1 To UBound(q):j=j+Left(q(i),Len(q(i))-3)*Mid(h,InStr(h,Mid(Right(q(i),3),1,1))+1,2)*Mid(g,InStr(g,Mid(Right(q(i),3),3,1))+1,1):Next i:If q(0)/2<j Then k=1
End Function

```

> Using `:` rather then Newline doesn't make it shorter, But it does look more golfy!

Readable Format

```
Function b(x) As Boolean
q = Split(x)
g = "b1e0h2j0r6t7v6w3"
h = "B03C25G02K50S.2"
For i = 1 To UBound(q)
j = j + Left(q(i), Len(q(i)) - 3) * _          'Left most digits would be the Quantity
Mid(h, InStr(h, Mid(Right(q(i), 3), 1, 1)) + 1, 2) * _  'Find the Container value in h
Mid(g, InStr(g, Mid(Right(q(i), 3), 3, 1)) + 1, 1)      'Find the Drink value in g
Next i
If q(0) / 2 < j Then b = 1 'Checks if Drunk or not
End Function

```

Pretty Sure this can be golfed. my String Manipulation with `Mid(Right())` seems excessively wordy, But running the array though `StrReverse` makes it longer. If we assume you only drink 0-9 of any particular drink at a time we can save a handful of bytes

Take input as one string with weight separated by a space as `VBA` dose not support multi line input

# Answer
> 3 votes
# Ruby, 153 bytes

I need to get rid of the gsubs somehow

```
w=gets.to_i;$><<(eval(gets.chars{|c|c[/[0-9]/]!=p ? ($_[c]+='*'):0}.tr('behjrtvwo BG','10206763*+32').gsub('C','25').gsub('K','50').gsub('S','0.2'))>w/2)

```

# Answer
> 3 votes
# JavaScript, 131 ~~134~~ ~~139~~ bytes

This is a full program and basically an adaption of my PHP answer:

```
for(c=prompt,b=c(a=c(s=i=0));b[i];i+=2)s+=b[i++]*{B:3,C:25,G:2,K:50,S:.2}[b[i++]]*{b:1,h:2,r:6,t:7,v:6,w:3}[b[++i]]||0;alert(s>a/2)

```

It reads two values using `prompt` and `alert`s the result as `[true|false]`.

---

**Edits**

* *Saved* **5 bytes** by using a logical expression `||0` instead of declaring the beverages with `0` units. Thanks to user81655.
* *Saved* **3 bytes** by storing `prompt` in a variable and shortening the initialization. Thanks to Stefnotch.

# Answer
> 2 votes
# bash (+ bc + GNU sed), ~~200~~ ~~196~~ 194 bytes

```
read x
read y
y="$(sed 's/^/((/;s/$/))/;s/ /)+(/g;s/o/*/g;s/b/1/g;s/[ej]/0/g;s/h/2/g;s/[rv]/6/g;s/w/3/g;s/t/7/g;s/B/*3/g;s/C/*25/g;s/G/*2/g;s/K/*50/g;s/S/*0.2/g'<<<"$y")"
echo "$y>$x/2"|bc -l

```

# Answer
> 2 votes
# PHP, 163 ~~169~~ bytes

```
for($a=fgets(STDIN),$b=fgets(STDIN),$v=[b=>1,h=>2,r=>6,t=>7,v=>6,w=>3,B=>3,C=>25,G=>2,K=>50,S=>.2];$b[$i];$i+=2)$s+=$b[$i++]*$v[$b[$i++]]*$v[$b[++$i]];echo$s>$a/2;

```

Outputs `1` or nothing, works for all test cases.

---

I still wonder what this *hot sauce* is, having *2 units*.

---

**Edits**

* *Saved* **6 bytes** by merging the two arrays for drinks and multiplier and by removing `0` from `0.2`.

# Answer
> 2 votes
## Javascript, 159 bytes

```
function b(t){return a={B:3,C:25,G:2,K:50,S:.2,b:1,h:2,w:3,r:6,v:6,t:7},t.split(/\W/).reduceRight(function(t,n,r){return r?n[0]*a[n[1]]*a[n[3]]+t||t:t>n/2},0)}

```

Since Javascript requires a library to access STDIN, this code is just a function that accepts the entirety of the input, i.e. `b("100\n4Gow 1Koe 1Bov 1Gow 2Sot")`

# Answer
> 2 votes
## Python 3, 157 bytes

```
n,l,d,u=int(input()),input(),"behjrtvwBCGKS",[1,0,2,0,6,7,6,3,3,25,2,50,.2]
print(sum(map(lambda x:int(x[0])*u[d.find(x[1])]*u[d.find(x[3])],l.split()))>n/2)

```

# Answer
> 1 votes
# Keg, 165 bytes (SBCS)

```
¿®w?(: =[_]")0®u(!4/|\0-&:B=[&3*&|:C=[&55**&|:G=[&2*&|:K=[&\2*&|&15/*&]]]]__:b=[&1*&|:e=[&0&|:h=[&2*&|:j=[&0&|:r=[&6*&|:t=[&7*&|:v=[&6*&|&3*&]]]]]]]_©u&+®u)©w2/:©u<.

```

Try it online!

I feel as if though a Keg answer has never been more appropriate! This could probably be golfed, but I don't think it can.

## Explained

```
¿®w                                                                         #Take the weight and store it in a variable
?(: =[_]")                                                                  #Take the second line and remove spaces
0®u                                                                         #Store the units in a variable
(!4/|                                                                       #For every part in the input
\0-&                                                                        #Store the amount of drink in the register
:B=[&3*&|:C=[&55**&|:G=[&2*&|:K=[&\2*&|&15/*&]]]]__                         #Determine the beverage multiplier
:b=[&1*&|:e=[&0&|:h=[&2*&|:j=[&0&|:r=[&6*&|:t=[&7*&|:v=[&6*&|&3*&]]]]]]]_   #Determine the drink
©u&+®u)                                                                     #Add the amount to units
©w2/:©u<.                                                                   #Check the condition and print

```

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


title: Identify the Eeveelutions

text:
# Question
Title: Identify the Eeveelutions
Gah! It's a shame that Pokémon Sword and Shield won't introduce a new eeveelution. Let's mourn them with a code golf.

The objective is to, when given a type name as the input, output the name of the corresponding eeveelution.

* When given `Water`, output `Vaporeon`.
* When given `Electric`, output `Jolteon`.
* When given `Fire`, output `Flareon`.
* When given `Psychic`, output `Espeon`.
* When given `Dark`, output `Umbreon`.
* When given `Grass`, output `Leafeon`.
* When given `Ice`, output `Glaceon`.
* When given `Fairy`, output `Sylveon`.
* All other input falls in *don't care* situation.

No other rules. Enjoy!

# Answer
# Pyke, 29 bytes

```
EF 73 77 59 25 54 25 75 09 60 84 58 22 23 61 82 73 82 72 00 24 52 40 7E 5F 39 39 73 EF

```

Try it here!, Ungolfed with full tests

```
.o                                           -      map(ord, input)
  s                                          -     sum(^)
   wY%T%                                     -    (^ % 57) % 10     // wY is 57
                                   R@        -    v[^]
        u\t`\x84X"#a\x82s\x82r\x00$          -   [96, 600, 34, 35, 97, 371, 370, 0, 36]
                                     ~_99s   -  ^ + 333333 + 99
                                          .o - dictionary_lookup(^)

```

We start off by converting the input to a list of integers corresponding to the ascii characters and then summing them. This produces the following set of numbers for `["Water", "Electric", "Fire", "Psychic", "Dark", "Grass", "Ice", "Fairy"]`: `[515, 811, 390, 723, 386, 512, 273, 507]`. We then perform a magic operation (`(x % 57) % 10`) to get the following list of offsets: `[2, 3, 8, 9, 4, 6, 5, 1]`.

The bytes below correspond to the following compressed list: `[96, 600, 34, 35, 97, 371, 370, 0, 36]`, and we index into it based on the offsets we had previously. There's a 0 in there due to my inability to get it not to wrap.

```
75 09 60 84 58 22 23 61 82 73 82 72 00 24

```

Try it here!

This list of numbers corresponds to the location in the Pokedex, minus 100. Pyke's dictionary handily contains the Pokedex starting from index 333333 (0 indexed). It also comes with a convenient default variable, `~_`, for getting that particular number. We then add 99 to it to take an offset to Pyke's dictionary, and then use `.o` to look up that particular word.
> 5 votes

# Answer
# Python 2, ~~77~~ 76 bytes

```
lambda s:'VFULJSGEalmeoylspaballaporrftvc'[hash(s)%3695%8::8]+'reon'[s<'V':]

```

Try it online!

In Python 2, the `hash` function consistently (across runs and also on different platforms) converts any immutable value into a 64-bit integer. By taking that integer first mod `3695`, then mod `8`, we get an integer `0<=i<8` (`3695` was found by brute force checking all possible values upto `10000`).

A common trick is used to encode a list of same-size strings into a single string and then using slicing via `[i::8]`to extract the strings without using `.split` or similar strategy. Only two options are not of length 4: `Esp` and `Vapor`. The former is handled by making it the last of the 8 strings encoded; and `Vapor` is handled using the final slicing `'reon'[s<'V':]`.
> 16 votes

# Answer
# Perl 6, ~~72 67 65~~ 64 bytes

```
{<Sylv Esp Glac Jolt Leaf Umbr Flar Vapor>[:36($_)%537%8]~'eon'}

```

Try it online!

A golf to all unique indexes by parsing the string as base 36 and moduloing it. I've left a version that just uses the sum below so other answer that may not have the same short base converting code that Perl 6/Raku does. There is also base 35 with modulo 51 and 10, but that comes out to the same byte count.

# Perl 6, 67 bytes

```
{<Leaf Esp Umbr Vapor 0 Sylv Flar Jolt Glac>[.ords.sum%64%9]~'eon'}

```

Try it online!

Differentiates between inputs by the sum of the ordinal values, modulo 64 modulo 9, leaving one extra spot to be filled in. Unfortunately, my brute force script couldn't find any pairs of moduli that led to no empty spaces, and adding a third would cost more than it gained.
> 14 votes

# Answer
# Ruby `-p`, ~~89~~ 67 bytes

Direct port of Jo King's Perl answer. ~~By sheer coincidence, the byte count is even the same.~~ The byte counts are no longer the same as Jo King has switched to using a technique that cannot be tersely replicated in Ruby.

```
$_=%w"Leaf Esp Umbr Vapor 0 Sylv Flar Jolt Glac"[$_.sum%64%9]+'eon'

```

Try it online!

### Original Version, Ruby `-p`, 89 bytes

Basic lookup checking the first letter of the input (or first 2 if the second letter is `i`, which is only present in `Fire`).

```
$_=%w"WVapor EJolt PEsp DUmbr GLeaf IGlac FSylv FiFlar".find{|e|e.sub!$_[/.i?/],''}+'eon'

```

Try it online!
> 7 votes

# Answer
# ink, ~~111~~ 110 bytes

```
=e(t)
{
-t?"W":Vapor
-t?"E":Jolt
-t?"P":Esp
-t?"y":Sylv
-t?"D":Umbr
-t?"G":Leaf
-t?"I":Glac
-1:Flar
}<>eon->->

```

Try it online!

## Explanation

```
=e(t)          // Define a stitch e which takes a parameter t
{              // An if block - finds the first condition that is true and doeses the associated thing
-t?"W":Vapor   // If "W" is a substring of our parameter, we print "Vapor"
-t?"E":Jolt    // otherwise, if "E" is a substring of our parameter, we print "Jolt"
-t?"P":Esp     // "P" is for "Psychic"
-t?"y":Sylv    // We can't check "F" for "Fairy" because that'd also match "Fire", but since we got past "Psychic", "Fairy" is the only option that contains "y"
/* et cetera */
-1:Flar        // If we get here, we check if 1 is truthy (it is) and if so, we print "Flar"
}<>eon->->     // Append "eon" to the last line printed, and return.

```
> 4 votes

# Answer
# 05AB1E, ~~47~~ ~~40~~ 38 bytes

```
.•‡ιÏSnÛ@¥I´4óÈ¬–[и)h‘j"õújв•#ć«™sÇ<Oè

```

-7 bytes by porting *@JoKing*'s `ord-sum % 64` trick.
-2 bytes thanks to *@JonathanAllan* by using the `ord-sum - length` on the input-type instead.

Try it online or verify all test cases.

**Explanation:**

```
.•‡ιÏSnÛ@¥I´4óÈ¬–[и)h‘j"õújв•
            "# Push compressed string "eon glac  jolt leaf umbr esp vapor sylv flar"
  #          # Split it on spaces:
             #  ["eon","glac","","jolt","leaf","umbr","esp","vapor","sylv","flar"]
   ć         # Extract head; pop and push remainder-list and the first item
    «        # Concat this first item "eon" to each string in the remainder-list
     ™       # Titlecase each Eeveelution
      sÇ     # Get the input, and convert it to a list of unicode values
        <    # Decrease each value by 1
         O   # Sum these integers
          è  # And use this to (0-based) index into the list (with automatic wrap-around)
             # (after which the result is output implicitly)

```

See this 05AB1E tip of mine (section *How to compress strings not part of the dictionary?*) to understand why `.•‡ιÏSnÛ@¥I´4óÈ¬–[и)h‘j"õújв•` is `"eon glac jolt leaf umbr esp vapor sylv flar"`.
> 4 votes

# Answer
# Charcoal, 50 bytes

```
§⪪”↶2'⧴mＢ⁼“↷⁻o⊟ＨtωhJ№↘Tθ⁼σ4Þχ℅)Zh” ⌕rtFhDscy§Ｓ⁴eon

```

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

```
§⪪”↶2'⧴mＢ⁼“↷⁻o⊟ＨtωhJ№↘Tθ⁼σ4Þχ℅)Zh”

```

Split the compressed string `Vapor Jolt Flar Esp Umbr Leaf Glac Sylv` on spaces and index into it using...

```
⌕rtFhDscy§Ｓ⁴

```

... the index of the fourth character of the input (taken cyclically) in the string `rtFhDcsy`.

```
eon

```

Output the shared suffix.
> 3 votes

# Answer
# Java 8, 84 bytes

```
t->"Leaf Esp Umbr Vapor  Sylv Flar Jolt Glac".split(" ")[t.chars().sum()%64%9]+"eon"

```

Port of *@JoKing*'s Perl answer.

Try it online.
> 3 votes

# Answer
# Jelly, 43 bytes

```
“ȦF³ḢẎŻṣ>[ɲ$Ɱ'⁻⁹ḋm¿:ṪœeḂɲẆy$\»Ḳ;€“°9»ŻɓO’Sị

```

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

### How?

First makes the list `['Jolt', 'Leaf', 'Umbr', 'Esp', 'Vapor', 'Sylv', 'Flar', 'Glac']`, adds `'eon'` to each, and prepends a zero to the list. Then gets the ASCII code-points of the characters in the input list, subtracts one from each, sums those up and indexes into the created list (using 1-based, modular indexing - i.e. gets the value at index `i%9`).
> 2 votes

# Answer
# Julia 1.0, ~~85~~ ~~83~~ 75 bytes

```
f(s)=strip("VUEJGSFLamsolylepbplalaaor tcvrfr"[6hash(s)%47%8+1:8:33])*"eon"

```

Try it online!
> 1 votes

# Answer
# Perl 5 `-p -MList::Util=pairfirst`, 84 bytes

```
$_=(pairfirst{/$a/}D,Umbr,E,Jolt,Fa,Sylv,Fi,Flar,G,Leaf,I,Glac,P,Esp,W,Vapor)[1].eon

```

Try it online!
> 1 votes

# Answer
# C (gcc), 103 bytes

I hash the first four bytes of the string to determine the index into the array (the hash function is not optimal, but works well enough: there's probably a more efficient one, but it would likely be bigger!) After the index is computed, I then print the four (or five) characters of the prefix and end with "eon". It's more compact than a string array, and by keeping the five-character string at the end I simplify the indexing.

I used some quirks in the language and implementation to save some length:

* Due to operator precedence, I use `4|j>7` to give me 4 or 5, as bitwise operators have a lower precedence than relational ones.
* Strings have to have `int`-appropriate alignment and `int` has to be a 32-bit, little-endian value so I can use type punning on the input string; fortunately this is the case for the test environment.

```
j;f(int*i){(j=(*i-2)%12%10)&&j--;printf("%.*seon",4|j>7,"SylvEsp\0JoltFlarLeafUmbrGlac    Vapor"+4*j);}

```

Try it online!
> 1 votes

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


title: Symbol Search Deleter [rephrased]

text:
# Question
Title: Symbol Search Deleter [rephrased]
Your challenge is to parse nonsensical text and output a "congruous phrase" - which I shall define here to be text with any contiguous characters in between, and including, a given set of like symbols removed.

The given set of **like symbols** (*ignore all brackets and commas here, they're only for notation*) are: {(\< \>), (^ ^), (' '), (: :), (% %)}

---

\[NOTE: This question has been heavily refined after several critical errors were identified.\]

EXAMPLE 1:

> Thi'inquit Caecilius's qu % est provocationem %h^ ad howe et^s \[ben\] heavilede ^citi:ssim:e^\< rn^\> ^quolibe doetiguis^dited %inger 'ingenia'%! S\__o:esse: rr %^umd^%y...

OUTPUT 1:

> This qu hs \[ben\] heavilede dited ! S\__o rr y

.

*Be wary of the nested like symbol parts* \- e.g **^citi:ssim:e^** and **\< rn^\>** from above, where the pair **: :** are sandwiched between another pair **^ ^**, and a *half-pair* **^** in between **\< \>**. Both of these non-congruous phrases must be removed.

EXAMPLE 2:

> W%cd'fuf'dc%at\<\>ch^'o'^out!

OUTPUT 2:

> Watchout!

.

EXAMPLE 3: **Special Case** (partial nested like symbols)

> aaa^bbb%ccc'ddd^eee%ddd'fff

OUTPUT3: The first occurence of the given like symbol is the dominant; in this case **^**

> aaaeee%ddd'fff

---

The code must apply to the general case, so any text of your choosing, of length \>= 30 characters, may be used as test cases.

The shortest code, in bytes, that completes this challenge successfully, is the winning code.

# Answer
# C# .NET, 162 bytes

```
using System;class A{static void Main(string[] s){Console.Write(System.Text.RegularExpressions.Regex.Replace(s[0],String.Format("([{0}]{{1}}).*?\\1",s[1]),""));}}

```

Try it online!

Er, the OP's test case is faulty. Either you remove all text between any two symbols, or you remove all text only between like symbols. OP does both in his test case... So I'm doing only between like symbols.

Takes as input the string to search and the character set to use. OP is incorrect about the output, though. It reads,

```
, Howarm y congruum dor ingqussld...

```
> 2 votes

---
Tags: code-golf, fastest-code, word-search, pattern-matching
---


# Question
Title: Print all the ways to aquire specific number using only specific numbers
Let's say we have some arbitrary number:

For example 25. We also have some "tokens" (poker chips, money, something similar) with different values.

Values of tokens are `2; 3; 4; 5.`

"Tokens" are limitless

You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so.

Fragment of example expected output (25 with 8 tokens):

```
3 '5' tokens, 5 '2' tokens
2 '5' tokens, 1 '4' token, 1 '3' token, 4 '2' tokens
....
1 '4' token, 7 '3' tokens

```

You may output in any reasonable, non-ambiguous format. For instance, **3 '5' tokens, 5 '2'** tokens can be represented as a single list \[5,0,0,3\] or as a list of tuples \[\[3,5\],\[5,2\]\]. And if there's no solution, you can provide empty output (or state `no solution found` or something among the lines)

Standard code golf rules apply, so winner is decided by shortest byte count (though you have to also provide "commented" version of your code, especially for languages such as Brainfuck, Jelly, Piet and so on)

Edit: I intended this challenge as challenge with fixed tokens, but I like universal answers more then "niche" ones even if it's not specified in challenge itself initially. As long as making tokens "third input parameter" still provides correct answer for tokens provided it's accepted for this challenge. If you are willing to rewrite your code - go on, save those precious bytes/chars.

# Answer
> 5 votes
# Jelly, 10 bytes

```
ŒṗfƑƇL=¥Ƈ⁵

```

Try it online!

A full program that takes the total, token values and number of arguments as its arguments. Returns a list of lists of token values.

## Explanation

```
Œṗ          | Integer partition (of first argument)
    Ƈ       | Keep only those which:
   Ƒ        | - are invariant when:
  f         |   - filtered to only include the (implicit) second argument.
       ¥Ƈ   | Keep only those for which:
     L      | - the length
      =  ⁵  |   - is equal to the third argument

```

# Answer
> 3 votes
# , <sup>~~35~~</sup> 32 bytes

```
~.@((=1&#.)#])2+#&4/:~@#:[:i.4^]

```

Try it online!

* Count in base 4 from 0 up to `4 ^ num_tokens` to generate all the raw possibilities: `#&4/:~@#:[:i.4^]`
* Add 2 to all numbers so the tokens will have 2 3 4 5 labels instead of 0 1 2 3 labels: `2+`
* Sort each possibility in preparation for removing dups: `/:~@`
* Filter the raw possibilities to include only those with the correct sum: `((=1&#.)#])`
* Take the uniqs: `~.@`

# Answer
> 2 votes
# Perl 6, 64 bytes

```
{grep(*.sum==$_,|($/=2..5),|(+<<[\X] $/xx$_)[*;*])>>.Bag.unique}

```

Try it online!

Fails for inputs above 7 due to `Too many arguments in flattening array.`This is because we are generating a list of every possible combination with repetition of numbers up to length n (where n is the same as the input), and not just that, but every possible ordering as well. Ah well, the price of being golfy...

This takes a number and returns a Bag, which is an unordered list of numbers and the amount in the bag.

# Answer
> 2 votes
# Haskell, 63 bytes

```
n%k=[l|l<-mapM(\_->[0..n])"xnor",sum l==k,sum(scanr(+)0l)==n-k]

```

Try it online!

A cute trick is used to check the list sum. We're looking for for elements `l=[a,b,c,d]` with `a+b+c+d=k` (right number of tokens) and `2*a+3*b+4*c+5*d==n` (right total value). Subtracting the first equation from the second gives `a+2*b+3*c+4*d==n-k`. To get `a+2*b+3*c+4*d`, we do `scanr(+)0 l` to get the reversed cumulative sum `[a+b+c+d,b+c+d,c+d,d,0]` and take the sum of its elements.

The solution brute-forces using `mapM` to generate all possible quadruples of token counts.

---

**71 bytes**

```
n%k=filter(all(>=0))[[a,4*k-n-2*a+d,n-3*k+a-2*d,d]|a<-[0..n],d<-[0..n]]

```

Try it online!

A longer direct solution. We try all `a` and `d`, and for each possibility we solve for `b` and `c` and check if they are non-negative positive.

---

**68 bytes**

```
(%)2
6%t=[[]|t==(0,0)]
x%(v,c)=do y<-[0..c];(y:)<$>(x+1)%(v-x*y,c-y)

```

Try it online!

Golfing Joseph Sible's solution. Takes input uncurried like `(25,8)`.

# Answer
> 1 votes
# JavaScript (V8),  ~~94~~  82 bytes

Takes input as `(sum)(n)`. Prints the solutions, as lists of token values.

```
s=>(g=(n,t=0,u=[])=>n?[2,3,4,5].map(v=>v>u[0]||g(n-1,t+v,[v,...u])):t-s||print(u))

```

Try it online!

### Commented

```
s => (              // s = expected sum
  g = (             // g is a recursive function taking:
    n,              //   n   = expected number of tokens
    t = 0,          //   t   = current sum, initialized to 0
    u = []          //   u[] = list of tokens
  ) =>              //
    n ?             // if n is not equal to 0:
      [2, 3, 4, 5]  //   for each allowed token value v:
      .map(v =>     //
        v > u[0] || //     abort if u[] is non-empty and v is greater than the last
                    //     token value (which is actually stored at the beginning)
        g(          //     otherwise, do a recursive call:
          n - 1,    //       decrement n
          t + v,    //       add v to t
          [v, ...u] //       prepend v to u[]
        )           //     end of recursive call
      )             //   end of map()
    :               // else:
      t - s ||      //   if t = s:
        print(u)    //     this is a solution: print it
)                   //

```

# Answer
> 1 votes
# Pyth, 21 20 bytes

```
{mSdfqhQsT.c*hQr2 6e

```

Try it online!

Saved a byte because the last Q is implicit

Returns a list of token combinations (e.g. `[3, 3, 4]` for 2 '3' tokens and 1 '4' token) which seems like a reasonable, non-ambiguous format, so I'll leave it unless the rules are changed. Takes input as `value, n`. Return an empty list if there are no valid combinations (I think)

Also hopelessly slow, so dont pick a value thats too high.

## How it works

```
{mSdfqhQsT.c*hQr2 6e (Q)
            *hQ        - Multiply the first input by...
               r2 6    - The range 2,6 (2..5)
          .c       e(Q)- All combinations of the above that are the length of the
                        second input (Q is implicit)
    fqhQsT             - Filter to elements where the sum is equal to the first input
 mS                    - Sort all elements
{                      - Remove duplicates

```

# Answer
> 1 votes
# 05AB1E, 11 bytes

```
ÅœIùʒ5L¦ÃyQ

```

Try it online!

Outputs list of token values.

**Explanation**

```
Åœ            | Take all integer partitions of the target number
  Iù          | Only keep those of length n
    ʒ         | Filter by:
     5L¦      | Push [2,3,4,5]
        ÃyQ   | Check if partition is equal to its intersection with [2,3,4,5]
              | Filter it out if not

```

# Answer
> 1 votes
# Wolfram Language (Mathematica), 36 bytes

Not really golfed. There is a built-in for this in Mathematica.

```
IntegerPartitions[#,{#2},{2,3,4,5}]&

```

Try it online!

# Answer
> 1 votes
# Charcoal, 30 bytes

```
ＮθＮηΦＥＸ⊕θ⁴⭆⮌↨ι⊕θ⭆λ⁺²μ∧⁼Ｌιθ⁼Σιη

```

Try it online! Link is to verbose version of code. Outputs a list of strings each of `n` tokens sorted in ascending order (if they had been sorted in descending order then the list itself would be in ascending order). Explanation:

```
ＮθＮη

```

Input `n` and the target.

```
ΦＥＸ⊕θ⁴

```

Loop over the range `0..(n+1)⁴`.

```
⭆⮌↨ι⊕θ

```

Convert each value to base `(n+1)` as an array with least significant digit first.

```
⭆λ⁺²μ

```

Convert each array to a string of tokens `2..5` and concatenate the results.

```
∧⁼Ｌιθ⁼Σιη

```

Only output those strings with a length of `n` and the correct digital sum.

# Answer
> 1 votes
# Haskell, ~~75~~ 67 bytes

```
f(x:l)v c=do y<-[0..c];(y:)<$>f l(v-x*y)(c-y)
f[]0 0=[[]]
f[]_ _=[]

```

Try it online!

-8 bytes by taking the tokens as input

The last two lines could be replaced with either `f[]v c=[[]|v==0,c==0]` or `f n v c=[n|v==0,c==0]`, both keeping the same byte count. Perhaps there's a way to golf one of those variants further that I'm not seeing though.

# Answer
> 0 votes
# Python 3, 97 bytes

```
lambda s,n:{(*sorted(i),)for i in product([2,3,4,5],repeat=n)if sum(i)==s}
from itertools import*

```

Try it online!

---

# Python 3, 106 bytes

```
lambda s,n,r=range:{(i,j,k,n-i-j-k)for i in r(n+1)for j in r(n-i+1)for k in r(n-i-j+1)if 5*n==s+3*i+2*j+k}

```

Try it online!

This function iterates over 3 variables `i`, `j` and `k`. The fourth variable follows from the difference between the number of tokens `n` and `ijk`. A combination is valid if `2*i+3*j+4*k+5*(n-i-j-k)==s`. This condition rearranges to `5*n==s+3*i+2*j+k`.

# Answer
> 0 votes
# Julia 1.0, 67 bytes

```
f(s,n,q=0:n)=[[a b c d] for a=q,b=q,c=q,d=q if[a b c d]*(2:5)==[s]]

```

Generates values representing how many tokens there are, then uses matrix multiplication to calculate the total. It seems like there should be a way to avoid typing `[a b c d]` twice, but I'm not aware of it.

Try it online!

# Answer
> 0 votes
# Japt, 22 bytes

```
V*4 o î6o2)àV â f_x ¥U

```

Try it

```
Returns arrays of tokens.
Not really efficent though.

(V * 4).o() // create an array of 4 times every token
.î(6 .o(2)) // repeat 2 to 5 inside it
.à(V).â() // all unique combinations
.f(function(Z) { return Z.x() == U }) // remove the wrong combinatons

Flag -Q to pretty print the result

```

---
Tags: code-golf, math
---


# Question
Title: Proportion of strings with ascending letters
## Challenge

* Construct `n` strings, each with three distinct letters, chosen randomly with equal probability.
* Print the proportion `k/n` where `k` is the number of strings such that all three characters are in ascending order. Print also those `k` strings.

## Input

* The only input is `n` (and thus it must be a positive integer).

## Outputs

* The proportion `k/n` must be truncated to two decimal places.
* The strings that are in ascending order of letters.

## Requirements

* The letters must come from the English alphabet.
* You cannot print the value of `k`.

## Examples

* Input: `6`, Output: `0.16 agh`
* Input: `1`, Output: `1.00 suv`
* Input: `9`, Output: `0.22 hls jqr`

## How to Win

* Fewest number of bytes wins.

# Answer
# Jelly, 31 bytes

13 bytes to cater for the truncation requirement!

```
ØaẊ⁸Ð¡Ḋḣ€3ṢƑƇðL÷+⁵×ȷ2ḞṾs2j”.Ḋṭ⁸

```

A monadic link which, given an integer, yields a list.

**Try it online!** (footer joins the list with spaces)

---

If (1) we remove the truncation requirement and (2) "The letters must come from the English alphabet" implies that we may choose any subset of three or more such letters then this 16 works:

```
“ḃ»Ẋ⁸Ð¡⁼ƇḢ$ðL÷;⁸

```

Try this one (only uses A, B, and C)

---

If we may also avoid the unobservable creation of all the strings as part of of our code. then this 15 works:

```
6ẋX€ỊƇ“ḃ»ẋðL÷;⁸

```

Try this one (only uses A, B, and C, and does not create any unordered strings)
> 3 votes

# Answer
# Japt, 25 bytes

```
;ÆBö3Ãf_¶ñ
u»UÊ/N)h2)ú0,4

```

Try it
> 3 votes

# Answer
# Python 3, 131 bytes

It seems like having to print the string complicates the program...

```
from random import*
n=int(input())
o=[]
a=['a','b','c']
x=0
for i in range(n):
 o+=[sample(a,3)]
 x+=a==o[-1]
print('%.2f'%(x/n),o)

```

Try it online!
> 2 votes

# Answer
# Pyth, 26 bytes

```
FNQKO.PG3IqKSK=ZhZK;.RcZQ2

```

Try it online!

Does what OP wants, +4 bytes due to truncation requirement.

## How it works

```
FNQKO.PG3IqKSK=ZhZK;.RcZQ2
FNQ                        - For N in Input
   K                       - K is equal to
    O.P 3                  - A random permutation length 3 of...
       G                   - The lowercase alphabet
         IqKSK             - If K is sorted
              =ZhZ         - Increment Z (which is autoinitialized to 0)
                  K        - Implicitly print K
                   ;  cZQ  - End loop, float division of Z by the input
                    .R   2 - Round to 2 decimal points

```

# Pyth, 24 bytes

```
FNQI!O6=ZhZSO.PG3;.RcZQ2

```

Try it online!

Cheat answer but since it only saves two bytes im not gonna bother. Also +4 due to truncation
> 2 votes

# Answer
# , 44 bytes

```
((4j2":%~),@,~[:u:97+26/:~@?~]#3:)1#.0=?@$&6

```

Try it online!

Note: This one does not actually construct the strings (the one below does) but its output has an identical probability distribution. I agree with Nick Kennedy on this point.

---

# , 48 bytes

```
(];~4j2":(%~#))[:<@u:"1[:(97+(-:/:~)"1#])26?~#&3

```

Try it online!

Note: Because the required output does not have a homogeneous data type, J requires us to box it.
> 1 votes

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


title: 1D Shikaku Validation

text:
# Question
Title: 1D Shikaku Validation
Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains exactly one number which is the number of grid squares in that component.

This challenge involves a 1D simplification of this: it is a line of N squares with K numbers \\$\\{a\_1, a\_2, \cdots, a\_K\\}\\$, and a solution would be a division of the line into K partitions such that each partition contains \\$a\_i\\$ squares. However, in this simplification, *not all squares need to be used*.

# Challenge

Given a list of N numbers (where 0 is an empty square), determine if a valid solution to that problem exists.

# Truthy Cases

(\_ is a blank; it will be given as 0 in the input. you may not take the input as an index:element mapping)

```
 _ _ 3 _ _ 5 _ _ 3 _ _
([   ] [       ] [   ])

 2 _ _ _ _ 6 _ _ _ 4 _ _
([ ] [         ] [     ])

 _ 5 _ _ _ 3 _ _ _ _ _ 4
([       ] [   ] [     ])

 _ _ 2 _ _ _ _ 4 _ _
(  [ ]       [     ])
(    [  ]  [     ]  ) just to give 2 examples

```

# Falsy Cases

```
_ _ 2 _ 4 _
_ 3 _ _ 5 _ _ 3 _
_ _ 5 _ _ _ 3
_ 2 _ 2 _ 2 _ 3

```

# Rules and Specifications

Input can be taken as any convenient way to take a list of numbers. You can input it as a string with `_` for blanks as well; etc. Any reasonable method; however, you may not change the general structure of the input as a list.

Output is a true/false value. Any truthy/falsy value is acceptable. The true/false value does not have to be consistent across cases, but your program must give the same exact answer for the same test case every run, and please specify how truthy/falsy is distinguished if it's not conventional. For example, you can output 1 for a true case and 2 for another, and 0 for false cases, but the first case must always yield 1 every time, and the second must give 2 every time.

To prevent a loophole brought up thanks to @xnor, your output must be successful / failed completion as a result, numbers, booleans, or other similar "primitive-like" datatypes (basically, you cannot submit the identity function and say that the Truthy/Falsy sets are divided by this problem's specifications).

* Standard loopholes are forbidden.
* This is , therefore the shortest answer in each language wins. No answer will be accepted.

# Answer
# JavaScript (ES6),  ~~56~~  52 bytes

Returns a Boolean value.

```
a=>![...a,1].some(x=>t>0/x?1:(t+=x-1)*x<0?t=0:0,t=0)

```

Try it online!

### Commented

The accumulator \\$t\\$ is decremented whenever an empty slot is encountered. For each non-zero value \\$x\\$, we update \\$t\\$ to \\$max(t+x-1,0)\\$. The test fails if we reach a non-empty slot (or the end of the list) with \\$t\>0\\$.

```
a =>               // a[] = input
  ![...a, 1]       // append a '1' at the end of a[] to force a last test
  .some(x =>       // for each value x in the updated array:
    t > 0 / x ?    //   if x = 0, this test is always falsy (0 / 0 -> NaN)
                   //   if x ≠ 0 and t is greater than 0:
      1            //     failed: yield 1
    :              //   else:
      (t += x - 1) //     add x - 1 to t
      * x < 0 ?    //     if t is negative and x ≠ 0:
        t = 0      //       we have accumulated more empty slots than
                   //       we can consume here: set t to 0
      :            //     else:
        0,         //       do nothing
    t = 0          //   start with t = 0
  )                // end of some(); return the opposite result

```
> 5 votes

# Answer
# Python 3, ~~96~~ ~~87~~ 85 bytes

```
def f(a):
	c=p=0
	for x in a:
		if p*x:return
		p|=x;c+=1
		if c>=p>0:c=p=0
	return p

```

Try it online!

-5 bytes thanks to 79037662.

-6 bytes thanks to HyperNeutrino.

None and positive are falsy, 0 is truthy.
> 2 votes

# Answer
# Python 2 via exit code, 52 bytes

```
n=0
for x in input()+[1]:x*n<0>_;n+=x<1or-max(x-1,n)

```

Try it online!

Successful completion for True, error for False.

*-1 byte thanks to Arnauld.*
> 2 votes

# Answer
# PowerShell, ~~56~~ ~~55~~ ~~54~~ 47 bytes

*inspired by Arnauld's one accumulator code.*

```
!($args+1|?{$_;$t+=$_-1}|?{$t-ge$_;$t*=$t-ge0})

```

Try it online!
> 2 votes

# Answer
# Retina 0.8.2, 34 bytes

```
^
,
\d+
$*
\b
;
+1`,;1|1;,
;
^\W*$

```

Try it online! Explanation:

```
^
,

```

Prepend a `,` so that there's one `,` for each square.

```
\d+
$*

```

Convert the entries to unary.

```
\b
;

```

Surround each non-empty square with `;`s.

```
+1`,;1|1;,
;

```

Each `;` in turn starts eating away at the adjacent empty squares.

```
^\W*$

```

Check that there were no `1`s left.

After adding the prefix and the unary conversion, .NET is actually able to solve the problem in a single regex, although it weighs in at a massive 58 bytes:

```
^
,
\d+
$*
^(,*(,)*(?<-2>1)*(?(2)^)(1)*(?<-3>,)*(?(3)^))*$

```

Try it online!
> 1 votes

# Answer
# , 47 bytes

```
[:*/2(>+.0>:[)/\[:(++(0>.0-+)*0<+-])/@|.\<:@,&1

```

Try it online!

Credit to Arnauld for the high-level idea.

I'll add explanation and golf more soon.
> 1 votes

# Answer
# Jelly, 20 bytes

```
ŒṖT€ẈỊẠƲƇðẈẋ`€F⁹a⁼ðƇ

```

A monadic Link accepting a list of non-negative integers which yields a list. An empty list is falsey, a non-empty list is truthy. (The list is actually all ways which work).

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

### How?

```
ŒṖT€ẈỊẠƲƇðẈẋ`€F⁹a⁼ðƇ - Link: list, S
ŒṖ                   - all partitions (of S)
        Ƈ            - filter keep those for which:
       Ʋ             -   last four links as a monad:
   €                 -     for each:
  T                  -       truthy indices
    Ẉ                -     length of each
     Ị               -     insignificant (for our purposes: is in (0,1)?)
      Ạ              -     all truthy?
                   Ƈ - filter keep those for which:
         ð        ð  -   the dyadic link - i.e. f(partition, S)
          Ẉ          -     length of each
             €       -     for each:
            `        -       use left as both arguments of:
           ẋ         -         repeat (i.e. 5 -> [5,5,5,5,5])
              F      -     flatten
               ⁹     -     chain's right argument (S)
                a    -     logical AND (vectorises)
                 ⁼   -     is equal to (S)?

```
> 1 votes

# Answer
# , 28 bytes

```
[:*/1>1&,*([0&>.<:@+)/\.@,&0

```

Try it online!

Inspired by Arnauld's algorithm. 1 if a solution exists, 0 otherwise.

### How it works

In order to retain intermediate values of `t`, I chose to use "Reduce on suffixes" `/\.` with the initial value appended. Given a function `f`, the result of `f/\.` looks like this:

```
Input array: 0 0 2 2 2 0 0 0
Index 0: 0 f 0 f 2 f 2 f 2 f 0 f 0 f 0 (right-assoc for everything)
Index 1:     0 f 2 f 2 f 2 f 0 f 0 f 0
Index 2:         2 f 2 f 2 f 0 f 0 f 0
...
Index 6:                         0 f 0
Index 7:                             0

```

Explanation of full code:

```
[:*/1>1&,*([0&>.<:@+)/\.@,&0  Right argument: 1D Shikaku grid
                              ex. 0 0 2 2 2 0 0 (expected: falsy)
                         ,&0  Append the starting value of t=0
                              ex. 0 0 2 2 2 0 0 0
                     /\.@     Reduce from right and keep intermediate values...
          (         )           (left: x, right: t, output: t')
                <:@+            Compute y = x + t - 1
           [0&>.                Compute max(0, y) x times; simply y if x = 0
                              ex. 0 1 2 1 0 -2 -1 0
      1&,*                    For each element, match the current value of x with
                              the previous value of t (including the finish),
                              counting from the right
                              ex. 0 0 0 2 0 -4 0 0
[:*/1>                        Check if all of them are zero or less

```

### Golfing the next-`t` algorithm

```
If x is empty, decrement t; otherwise compute max(t+x-1, 0)
->
If x is empty, compute t+x-1; otherwise compute max(t+x-1, 0)
->
Compute t+x-1; if x is nonempty, apply (y => max(y, 0))
->
Compute t+x-1; apply (y => max(y, 0)) x times (assume x >= 0)

```
> 1 votes

---
Tags: code-golf, math, array, decision-problem
---


title: Draw a fuzzy grid

text:
# Question
Title: Draw a fuzzy grid
Print the ASCII version of a random grid.

```
################################################################################
#    #   #  #    #   #   #     #     #   #  #    #   #     #   #   #   #  #   #
#    #   #  #    #   #   #     #     #   #  #    #   #     #   #   #   #  #   #
#    #   #############   #     #     #   #  #    #   #     #   #   #   #  #   #
##########   #   #   #####################  #    #   #     #   #####   ########
#    #   #   #   #   #   #   #   #       #######################   #####   #  ##
#    #   #   #   #   #   #   #   #       #  #   #     #   #    #   #   #   #  #
#    #   #   #   #   #   #####   #       #  #   #     #   #    #   #   #########
##########################   #######################################   #    #  #
#    #    #   #   #  #   #   #    #      #   #   #   #   #     #   #####    #  #
#    #    #   #   #  #   #   #    #      #   #   #   #   #     #   #   #    ####
###############   #  #   #####    #      #   #   #   #   #     #   #   #    #  #
#    #   #    ########   #   ###################################   #   ######  #
#    #   #    #   #  #####   #     #    #  #    #   #   #      #########    #  #
######   #    #   #  #   #   #     #    #  #    #   #   #      #   #   #    #  #

```

The picture should illustrate the constraints:

* `#` is solid,  is empty.
* Print 80 columns, at least 80 rows.
* On the first and last columns and first and last rows there is some freedom, but at least the printout must be extendible to a legal grid.
* Boxes contain `empty` areas between 1x1 and 7x7.
* Constraints: Boxes are rectangular, no lonely corners (1), no empty boxes (2), no broken lines(3) or gaps (4), when in doubt refer to the image above.
* A grid is considered "random", if the first 80 rows contain: 1.) 60 unique rows and 60 unique columns. 2.) At least one box with inner area of size (2, 2), (3, 2), (4, 2), (5, 2), (2, 3), (3, 3), (4, 3), (5, 3), (2, 4), (3, 4), (4, 4), (5, 4), (2, 5), (3, 5), (4, 5), (5, 5) *each*. You can verify the randomness and some constraints with this julia script.
* The program should nondeterministically produce a minimum number of 1000 grids fulfilling the constraints with different first 80 rows, where rotations, circular shifts and reflections counted as same and the majority of produced grids should be "random" as specified above.

```
    #####4########################
    #                #   #    #
    #    #       #   #   #    3
    #    #       #########   #
    #########1   #   #   #########
    #    #   #   #   ##2##   #   #
    #    #   #   #   #####   #   #
    #    #   #   #   #   #   #####

```

Code golf!

# Answer
# Julia, 254 bytes

Not very golfed, just to keep it going;

```
l=length
function f(M,r,s)
l(r)<7&&return l(s)>6&&g(M,r,s)
h,j=rand([f,g],2)
a,c=extrema(r)
b=rand(a+1:c-1)
M[b,s].=2
h(M,b+1:c,s)
j(M,a:b-1,s)
end
g(M,r,s)=f(M',s,r)
n=80
M=fill(1,n,n)
f(M,1:n,1:n)
for i∈1:n
print.(getindex.(" #",M[i,:]))
println()
end

```

Verification, try it yourself
> 1 votes

---
Tags: code-golf, ascii-art, random, grid
---


title: Expand a recursive pattern

text:
# Question
Title: Expand a recursive pattern
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps.

More specifically: Let the following be an example:

```
##..
##..
..__
..__

```

Where `#` is filled, `.` is empty, and `_` is recursive.

This describes a pattern wherein the top left quarter is filled, the top right and bottom left are empty, and the bottom right repeats the current pattern.

More rigorously, the pattern is a grid containing some number of `#`, `.`, and `_`. The grid will always be rectangular, and there will be at least one `_` and all `_` will be in a rectangular sub-grid such that the overall grid's `(width, height)` is an integer multiple of the sub-grid's `(width, height)`.

Your task is, given such a pattern and a number of steps, build up an expanded form of this pattern. That is, each step, expand the grid by `n` times (where `n` is the ratio between the recursive sub-grid and the overall grid), and fill the `_` sub-grid with the pattern. At the end, fill the base-state `_` all with `#` or `.` \- you choose which, but it must all be the same, and it must be consistently one or the other no matter the input.

To be VERY rigorous, `f(g, n)` where `f` is this challenge, `g` is the pattern grid, and `n` is the number of steps, then `f(g, 0) == g` (with the `_` replaced by `#` OR `.`), and `f(g, n)` is the grid scaled up by `r ** n` times (where `r` is the ratio of the pattern to the recursive sub-grid), with `_` replaced by `f(g, n - 1)`.

Let's do an example:

```
#.
._

3

```

At 0 steps, the grid is this:

```
#.
._

```

At 1 step, the grid is this:

```
##..
##..
..#.
..._

```

At 2 steps, the grid is this:

```
####....
####....
####....
####....
....##..
....##..
......#.
......._

```

At 3 steps, the grid is this:

```
########........
########........
########........
########........
########........
########........
########........
########........
........####....
........####....
........####....
........####....
............##..
............##..
..............#.
..............._

```

Then, your output can either replace the `_` with `.` or `#`, but again, all `_` must become the same in the final output, and you must always fill it with `.` or `#` no matter the input.

# Examples

The `_` are shown in this output - you are to replace them with `#` or `.`, by choice. They are simply shown as `_` just to reduce confusion as to where the `_` were and where pre-filled `#` and `.` are meant to be.

```
#.#.
.__#
#__.
.#.#

2

```

becomes

```
####....####....
####....####....
####....####....
####....####....
....##..##..####
....##..##..####
......#.#.######
.......__#######
#######__.......
######.#.#......
####..##..##....
####..##..##....
....####....####
....####....####
....####....####
....####....####

```

(Just gonna put this out there - this is NOT what I thought it would look like AT ALL)

A non-square non-double example:

```
##.
##.
##.
##.
.#_
.#_

2

```

becomes

```
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
##################.........
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........###############...
.........#########...#####.
.........#########...#####.
.........#########...#####.
.........#########...#####.
.........#########...###.#_
.........#########...###.#_

```

Last example.

```
#__#
.##.

3

```

becomes

```
###############__###############
##############.##.##############
############..####..############
############..####..############
########....########....########
########....########....########
########....########....########
########....########....########
........################........
........################........
........################........
........################........
........################........
........################........
........################........
........################........

```

# Rules and Specifications

Input requires a grid and an integer. This grid can be taken in any reasonable, convenient format, and you can replace the characters with any three consistent, distinct values. These can be integers too, for example.

Output requires a grid. This grid can be given in any reasonable, convenient format, and you can replace the characters with any two consistent, distinct values. These do not have to be the same as the ones corresponding to the inputs (why???).

Standard loopholes apply.

This is a challenge, so the shortest program in bytes for each language wins. No answer will be accepted.

Happy golfing!

# Answer
# MATL, ~~33~~ ~~30~~ ~~27~~ 26 bytes

```
ii:"l1G1=aYm/t&Y"1Gy1=(]Zc

```

Input is a numerical matrix with `0` for empty, `9` for filled and `1` for recursive.

Replaces recursive by filled at the end.

Output is a character matrix with  (space) for empty and `#` for filled.

Try it online! Or verify all test cases.

### Explanation

```
i      % Take first input: matrix, M. This will be grown recursively
i      % Take second input: number, n
:      % Range [1 2 ... n]
"      % For each
  l    %   Push 1
  1G   %   Push first input, M
  1=   %   Compare with 1
  a    %   Any. This gives a vector with 1 for columns that contain
       %   at least a 1 in input M, and 0 otherwise
  Ym   %   Mean. This gives the proportion of columns with 1
  /    %   Divide 1 by that. This gives the ratio r referred to in the challenge
  t    %   Duplicate
  &Y"  %   Repeat elements. This enlarges the current matrix by r along each dimension
  1G   %   Push input M again
  y    %   Puesh a copy of the current enlarged matrix
  1=   %   Compare with 1. Gives a logical mask
  (    %   Write M into the positions indicated by that mask
]      % End
Zc     % Convert nonzeros to character '#' and zeros to space. Implicitly display

```
> 7 votes

# Answer
# Jelly, ~~32~~ 28 bytes

```
³,Z¬ÆmṀ$€İḞ¤xZ¥ƒYṣ0ż³F¤FỴµ¡!

```

Try it online!

A full program that takes two arguments, a matrix of integers (0-2) and the number of steps and returns a matrix of integers (1-2). 0 is used for the recursive bit.

Thanks to @JonathanAllan for saving two bytes!

## Explanation (outdated)

```
                           µ¡ | Repeat the following the number of times indicates by the right argument
             ¤                | - Following as a nilad:
³                             |   - Original left argument (matrix of integers)
 ,Z                           |   - Paired with itself transposed
           Ɗ€                 |   - For each of the pair, do the following as a monad:
   ¬                          |     - Not
    ẸƇ                        |     - Keep only those with any True values
      F                       |     - Flatten
          Ɗ                   |     - Following as a monad:
       L                      |       - Length
        :                     |       - Divided by (integer)
         S                    |       - Sum
                ¥ƒ            | - Reduce using the argument to this iteration as the initial argument and the following as a dyad:
              x               |   - Repeat that many times
               Z              |   - Transpose
                  Y           | Join with newlines
                   ṣ0         | - Split at zeros
                     ż  ¤     | - Zip with the following as a nilad:
                      ³       | - Original left argument
                       F      | - Flattened
                         F    | - Flatten
                          Ỵ   | - Split at newlines
                             !| Factorial (0 becomes 1)

```
> 6 votes

# Answer
# Python 2, ~~250~~ ~~249~~ ~~280~~ ~~266~~ ~~250~~ 248 bytes

```
def f(p,n):
 s=p;Q=L(p[0])
 for z in R(n):u,y=[(Q/r.count('_'),y)for y,r in enumerate(s)if'_'in r][0];s=[''.join(s[j/u][i/u]for i in R(u*L(s[0]))).replace('_'*Q,p[(j-y*u)%L(p)])for j in R(u*L(s))]
 return[c.replace('_','#')for c in s]
R=range;L=len

```

Try it online!

Input and output are both lists of strings.
> 3 votes

# Answer
# Japt, 35 bytes

```

Ê/Uèø0
NÌÆ=c@VÇXmpV r0@NÎ¬gT°
®r0Q

```

Try it
> 3 votes

---
Tags: code-golf, ascii-art, matrix
---


title: Horizontally mirror a brainflak program

text:
# Question
Title: Horizontally mirror a brainflak program
Your task is to write a program or function which takes a pure brainflak program as input (assume it contains only balanced `()[]{}<>`), and output a visually mirrored copy of it.

If you reversed a brainflak program as a string, say `({}())` (add one to an input), you would get `))(}{(`, which is not valid.

Instead, you should mirror it, by reversing the direction of the parentheses/brackets/braces/angle-brackets, like what you would see if the program was placed in front of a mirror: `((){})`.

Test cases (`???` means anything is okay):

```
()               -> ()
({}[{}])         -> ([{}]{})
()[]             -> []()
<(){}[]>         -> <[]{}()>
([{<()[]{}<>>}]) ->([{<<>{}[]()>}])
(a)              -> ???
{>               -> ???
))(}{(           -> ???
()↵[]            -> ???

```

This is a code golf challenge, shortest answer per language wins.

# Answer
# Charcoal, 3 bytes

```
Ｓ‖Ｔ

```

Try it online! Link is to verbose version of code. Explanation:  reads the input and implicitly echos it, while  is the mirroring operator, which normally just reverses the input, but the  modifies it to mirror the characters at the same time.
> 10 votes

# Answer
# JavaScript (Node.js),  ~~51 47~~  44 bytes

*Saved 3 bytes thanks to @xnor*

```
s=>Buffer(s).map(c=>c^68%c/3%8).reverse()+''

```

Try it online!

### How?

For each pair of characters, we can switch from the 1st to the 2nd character (and vice versa) by XOR'ing the ASCII code with \\$1\\$, \\$2\\$ or \\$6\\$.

```
 char 1 | code | XOR | code | char 2
--------+------+-----+------+--------
   '('  |   40 |  1  |   41 |  ')'
   '<'  |   60 |  2  |   62 |  '>'
   '['  |   91 |  6  |   93 |  ']'
   '{'  |  123 |  6  |  125 |  '}'

```

Given an ASCII code \\$c\\$, we can turn it into the correct XOR value by using the following function:

$$f(c)=\left\lfloor((68 \bmod c)/3)\bmod 8\right\rfloor$$

```
   c  | 68 mod c |   / 3  | mod 8 | floor
------+----------+--------+-------+-------
   40 |    28    |  9.333 | 1.333 |   1
   41 |    27    |    9   |   1   |   1
------+----------+--------+-------+-------
   60 |     8    |  2.667 | 2.667 |   2
   62 |     6    |    2   |   2   |   2
------+----------+--------+-------+-------
   91 |    68    | 22.667 | 6.667 |   6
   93 |    68    | 22.667 | 6.667 |   6
  123 |    68    | 22.667 | 6.667 |   6
  125 |    68    | 22.667 | 6.667 |   6

```
> 7 votes

# Answer
# Python 3, 47 bytes

```
lambda x:x[::-1].translate('>]<[)('*20+'}_{'*2)

```

Try it online!

Python has a convenient string method `translate` that accepts a translation string `s`, and maps each character `c` to `s[ord(c)]`. So, we just need to make a translation string with the right characters at the positions of ASCII values `[40, 41, 60, 62, 91, 93, 123, 125]` of `()<>[]{}`.

The ideal would be to make the table like `'????????'*16`, putting the correct character for each ASCII value modulo 8. Unfortunately, the values `[40, 41, 60, 62, 91, 93, 123, 125]` are not distinct modulo 8, and the first modulus making them distinct is 18, which would mean something like `'??????????????????'*6`.

However, conveniently, the lowest 6 ASCII values `[40, 41, 60, 62, 91, 93]` are distinct modulo 6. That lets us handle them with `'>]<[)('*20`, translating ASCII values 0 through 119. For the remaining two, 123 and 125, we use `'}_{'*2` to hit the next 6 ASCII values 120 to 125. Python 3 lets us stop there, unlike Python 2, which requires the translation string to be length 256 exactly.
> 7 votes

# Answer
# Jelly,  ~~13~~  12 bytes

*Saved 1 byte thanks to @JonathanAllan*

```
O&80%15‘^OỌṚ

```

Try it online!

### How?

The idea here is to XOR the ASCII codes to turn each character into its mirrored counterpart, like I did in my JS answer. But we use a formula that is bit golfier in Jelly:

$$f(c)=((c\text{ & }80)\bmod 15)+1$$

where \\$\text{&}\\$ is a bitwise AND.

```
 char | code | and 80 | mod 15 |  + 1 | XOR code | new char
------+------+--------+--------+------+----------+----------
  '(' |   40 |    0   |    0   |   1  |    41    |   ')'
  ')' |   41 |    0   |    0   |   1  |    40    |   '('
------+------+--------+--------+------+----------+----------
  '<' |   60 |   16   |    1   |   2  |    62    |   '>'
  '>' |   62 |   16   |    1   |   2  |    60    |   '<'
------+------+--------+--------+------+----------+----------
  '[' |   91 |   80   |    5   |   6  |    93    |   ']'
  ']' |   93 |   80   |    5   |   6  |    91    |   '['
  '{' |  123 |   80   |    5   |   6  |   125    |   '}'
  '}' |  125 |   80   |    5   |   6  |   123    |   '{'

```

### Commented

```
O&80%15‘^OỌṚ - a monadic link taking a string, e.g. "(<>[])"
O            - convert the input to ASCII codes --> [40, 60, 62, 91, 93, 41]
 &80         - bitwise AND with 80              --> [ 0, 16, 16, 80, 80,  0]
    %15      - modulo 15                        --> [ 0,  1,  1,  5,  5,  0]
       ‘     - increment                        --> [ 1,  2,  2,  6,  6,  1]
         O   - input to ASCII codes again       --> [40, 60, 62, 91, 93, 41]
        ^    - bitwise XOR                      --> [41, 62, 60, 93, 91, 40]
          Ọ  - convert back to characters       --> ")><][("
           Ṛ - reverse                          --> "([]<>)"

```
> 6 votes

# Answer
# 05AB1E, 4 bytes

```
º2äθ

```

Try it online! or verify all test cases

**Explanation**

```
º    | Mirror (i.e. "({}[{}])" -> "({}[{}])([{}]{})"
 2ä  | Split into two pieces
   θ | Take the last piece

```
> 5 votes

# Answer
# Canvas, 1 byte

Try it here!

Surprised that this is the first 1-byte answer.
> 5 votes

# Answer
# , 24 bytes

```
|.rplc(;"0|.)@'([{<>}])'

```

Try it online!

Test cases by Jonah.
> 4 votes

# Answer
# , <sup>~~32~~</sup> 25 bytes

```
'([{<)]}>'|.@([{~8|4+i.)]

```

Try it online!

Quick explanation:

* Find the index of each input char within the string `'([{<)]}>'`.
* Add 4 to it to get its mirror
* Take that mod 8 to handle wrapping around to the beginning
* Use the result to index back into `'([{<)]}>'`
* And reverse that result
> 2 votes

# Answer
# Retina 0.8.2, 20 bytes

```
O^$`.

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

```

Try it online! Link includes test cases. Explanation:

```
O`.

```

Sort individual characters...

```
$

```

... by substitution value (constant empty string, therefore keeps original order)...

```
^

```

... with reversed sort order (i.e. reversing the string).

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

```

Substitute each character of `([{<>}])`...

```
`Ro

```

... with the matching character from the reverse of that string, thus mirroring those characters.
> 2 votes

# Answer
# Japt, 12 bytes

Blatant port of Arnauld's JS solution so go upvote him.

```
ÔcÈ^68%X/3%8

```

Try it
> 2 votes

# Answer
# Python 3, 61 bytes

```
lambda x,s="([<{}>])":"".join(s[7-s.find(c)]for c in x[::-1])

```

Try it online!
> 1 votes

# Answer
# Icon, 67 bytes

```
procedure f(s)
r:="reverse"
return map(r(s),d:="([{<>}])",r(d))
end

```

Try it online!
> 1 votes

# Answer
# Jelly, 13 bytes

This approach has many 13-byte solutions, although I can golf Arnauld's 13 byter to 12 bytes.

```
QṢiⱮịQṢṭ2/FƲṚ

```

**Try it online!**

### How?

```
QṢiⱮịQṢṭ2/FƲṚ - Link: list of characters, P
Q             - de-duplicate (P)
 Ṣ            - sort (call this X)
   Ɱ          - map across (p in) P with:
  i           -   first index of (p) in (X)
           Ʋ  - last four links as a monad - i.e. f(P):
     Q        -   de-duplicate (P)
      Ṣ       -   sort
        2/    -   2-wise reduce with:
       ṭ      -     tack
          F   -   flatten (i.e. pair-wise reversal of sorted unique values)
    ị         - (left) index into (right)
            Ṛ - reverse

```
> 1 votes

# Answer
# Brain-Flak, 302 bytes

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

```

Try it online!

This is (currently) very poorly golfed, but I thought there ought to be at least one Brain-Flak answer to this question.
> 1 votes

# Answer
# Red, 56 bytes

```
func[s][foreach c reverse s[prin select"[][()({}{<><"c]]

```

Try it online!
> 0 votes

# Answer
# Jelly, 15 bytes

```
“[({})]”©iⱮUịUɼ

```

Try it online!

A monadic link that reverses the input and input brackets of all their types.
> 0 votes

# Answer
# Perl 5 `-p`, 32 bytes

```
$_=reverse y/(){}[]<>/)(}{][></r

```

Try it online!
> 0 votes

# Answer
# C (gcc), ~~85~~ ~~84~~ ~~64~~ 60 bytes

60 bytes thanks to Neil

```
p;f(char*s){for(p=strlen(s);p--;)putchar(s[p]^68%s[p]/3%8);}

```

Try it online!
> 0 votes

---
Tags: code-golf, brain-flak
---