title: The XOROR sequence

text:
# Question
Title: The XOROR sequence
Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. Ternary CAs are more interesting, but we have all of ASCII to consider! What fun could that be!

Instead of deciding a ruleset for each character, I will use a simple deciding rule which I will talk about soon. To decide the next generation, we look at the three "top" cells, much like a cellular automata. Observe an example:

```
QWERTY
X Y Z

```

The "top" of `Y` is `WER`, being the cells above-and-right, above, and above-and left. Y will be the result of the function I'm about to define, which is a function on three-char strings. The "top" of `X` is  `QW`, **or a space filling in the non-existent/missing cell**.

Now, for the ~~fun~~ function! I call this sequence the XOROR sequence for a reason. Let `A` be the top-left cell charcode, `B` be the above cell charcode, and `C` be the top-right cell charcode. Then, the resulting cell is the character whose charcode is `(A XOR B) OR C`, that is, `(A^B)|C`. (If a resulting value is greater than 126, then it is set to `(CHARCODE % 127) + 32`. Nothing is done if a value is less than 32.) Here is an example of the seed `Hello, World!`:

```
S: Hello, World!
0: mmmo/c_ z}~)e
   m = ( )^(H)|(e) = (32^72)|101 = 104|101 = 109 (m)
    m = (H)^(e)|(l) = (72^101)|108 = 45|108 = 109 (m)
    etc.
1: mmo/c_<   +wl
2: mo/c_<c< + |;
3: o/c_<c  ?+  g
4: oc_<c c??4+gg
5: 0_<c c  4+ o
6: _<c ccc4??ooo
7:  c ccc4 ?o o
8: ccccc4w? pooo
9: cccc4w h   o
A: ccc4wc hh ooo
B: cc4wc4kh ooo
C: c4wc4  #ooo o
D: wwc4w4#ooo oo
E: wc4wwc oo oo
F: w4wwc4oo oo o
G: wwwc4   oo oo
H: wwc4w4 oo oo
I: w4wwc4oooo oo
J: wwwc4  oo oo
K: wwc4w4oo oo o
L: wc4wwo  oo oo
M: w4wwo8ooo oo
N: wwwo8  o oo o
O: wwo8w8oooo oo

```

And we can proceed on for a while hereafter. This modification of the string is called the XOROR sequence.

**Objective** You are to write a program or function that does one of the following tasks:

1. Given a string `s` and a number `n >= 0`, output the `n`th string on the XOROR sequence with seed `s`, with `n = 0` being the first transformation of the string.
2. Given a string `s`, output (for programs) or generate (for functions/generators) an infinite stream of the XOROR sequence with seed `s`. You may choose to stop if the sequence repeats, but this is not necessary.

`s` will always only consist of printable ASCII characters, from space to tilde plus tabs (no newlines.)

This is a , so the shortest program in bytes wins.

# Answer
# MATL, ~~33~~ 31 bytes

```
Q:"32XKhKwh3YCPo2$1Z}Z~Z|127KYX

```

This works in release 13.1.0 of the language/compiler, which predates the challenge.

The first input is the number, the second is the string.

**Try it online!**

```
Q           % take input (number) implicitly and add 1
:"          % repeat that many times
  32XK      %   push 32 (space). Copy to clipboard K.
  h         %   concatenate. Takes input (string) implicitly the first time
  Kwh       %   push space, swap, concatenate
  3YC       %   overlapping blocks of length 3 as columns of 2D array
  P         %   flip upside-down
  o         %   convert to numbers
  2$1Z}     %   separate the three rows and push them
  Z~        %   bitwise XOR (note the rows are in reverse order)
  Z|        %   bitwise OR
  127KYX    %   replace 127 by space using regexprep, which converts to char
            % end loop
            % implicitly display

```
> 5 votes

# Answer
# Mathematica, 133 bytes

```
FromCharacterCode@Nest[BlockMap[If[#>126,#~Mod~127+32,#]&[BitXor[#,#2]~BitOr~#3]&@@#&,ArrayPad[#,1,32],3,1]&,ToCharacterCode@#,#2+1]&

```

It would be nice to make a `CellularAutomaton[]` solution work, but I kept coming up short. Anyone?

Edit: some pretty pictures (click to enlarge)

```
plotCA[str_, n_] := ArrayPlot[NestList[foo[str],n], ColorFunction -> "Rainbow"]

```

`plotCA["Hello, World!", 60]`:

`plotCA[bXORnotb, 100]`:

`plotCA[raven, 100]`:
> 21 votes

# Answer
## Java, ~~193~~ 185 bytes

Because Java.

*-8 bytes by switching to looping rather than recursing to make it an anonymous function*

Returns the n'th iteration of XOROR on s.

```
(s,n)->{String o=s;for(;n-->=0;){o="";for(int i=0;i<s.length();i++){char c=(char)((i>1?s.charAt(i-1):' ')^s.charAt(i)|(i<s.length()-1?s.charAt(i+1):' '));o+=c>126?' ':c;}s=o;}return o;}

```

Readable version:

```
static BiFunction<String, Integer, String> f = (s,n)->{
    String o=s;
    for(;n-->=0;) {
        o = "";
        for (int i=0;i<s.length();i++) {
            char c=(char)((i>1?s.charAt(i-1):' ')^s.charAt(i)|(i<s.length()-1?s.charAt(i+1):' '));
            o+=c>126?' ':c;
        }
        s=o;
    }
    return o;
};

public static void main(String[]a) {
    System.out.println(f.apply("Hello, World",1));
}

```

Pretty much a literal implementation of the spec, with a recursive loop to apply the operation n times. Some bytes were saved, however, with my observation that the CHARCODE\>126 clause will only ever happen with CHARCODE==127, which results in saving `SPACE` instead of `DEL`.

I ran my code over a few arbitrarily chosen strings and found this wonderful cycle:

```
oook$ok$ok$ok$
ook$ok$ok$ok$o
oo$ok$ok$ok$ok
oook$ok$ok$ok$

```
> 6 votes

# Answer
## CJam, 38 bytes

```
lri){2S*\*3ew{)\:^|_'~>{i127%' +}&}%}*

```

Test it here.

### Explanation

```
l                e# Read string.
ri               e# Read n.
){               e# Run this block n+1 times...
  2S*\*          e#   Wrap in two spaces.
  3ew            e#   Get all (overlapping) substrings of length 3.
  {              e#   Map this block over all those substrings...
    )\           e#     Pull off the third character and put it below the other two.
    :^           e#     Take XOR of the other two.
    |            e#     OR with the third one.
    _'~>         e#     Duplicate and check if it's greater than '~'.
    {i127%' +}&  e#     If so, mod 127, add to space.
  }%
}*

```
> 5 votes

# Answer
## Haskell, 123 bytes

```
import Data.Bits
f s=toEnum.a<$>zipWith3(((.|.).).xor)(32:s)s(tail s++[32])
a x|x>126=32|1<2=x
tail.iterate(f.map fromEnum)

```

This returns an infinite stream of the XOROR sequence. Usage example (print the first 5 elements of the seed `"Hello, World!"`):

```
*Main> mapM_ print $ take 5 $ (tail.iterate(f.map fromEnum)) "Hello, World!"
"mmmo/c_ z}~)e"
"mmo/c_<   +wl"
"mo/c_<c< + |;"
"o/c_<c  ?+  g"
"oc_<c c??4+gg"

```

How it works:

```
tail.iterate(f.map fromEnum)               -- repeat forever: convert to ASCII
                                           -- value and call f, discard the first
                                           -- element (the seed).

                                           -- one iteration is:
  zipWith3(   )(32:s) s (tail s++[32])     -- zip the elements from the three lists
                                           -- (space:s), s and tail of s ++ space,
                                           -- e.g. s = "Hello!":
                                           --   | Hello|
                                           --   |Hello!|
                                           --   |ello! |
                                           -- (shortest list cuts off)

         ((.|.).).xor                      -- the function to zip with is a
                                           -- point-free version of (x xor y) or z

toEnum.a<$>                                -- adjust every element >126 and convert
                                           -- back to characters

```
> 5 votes

# Answer
# PHP, 186 bytes (with n) | 177 bytes (infinite)

It turned out that infinite printing is shorter...

```
// With n
function x($s,$n){while($n-->=0){for($i=0,$r='';$i<strlen($s);$i++){$b=ord($s[$i-1])or$b=32;$a=ord($s[$i+1])or$a=32;$t=($b^ord($s[$i]))|$a;$r.=chr($t>126?($t%127)+32:$t);}$s=$r;}echo$s;}

// Infinite
function i($s){while(true){for($i=0,$r='';$i<strlen($s);$i++){$b=ord($s[$i-1])or$b=32;$a=ord($s[$i+1])or$a=32;$t=($b^ord($s[$i]))|$a;$r.=chr($t>126?($t%127)+32:$t);}echo$s=$r;}}

```

Ungolfed with n:

```
function x($s, $n) { // $s - string to process; $n - which string to output
  while ($n-- >= 0) {
    for ($i = 0, $r = ''; $i < strlen($s); $i++) {
      $b = ord($s[$i - 1]) or $b = 32;
      $a = ord($s[$i + 1]) or $a = 32;
      $t = ($b ^ ord($s[$i])) | $a;
      $r .= chr($t > 126 ? ($t % 127) + 32 : $t);
    }
  $s = $r;
  }
  echo $s;
}

```

Ungolfed infinite:

```
function x($s) { // $s - string to process
  while (true) {
    for ($i = 0, $r = ''; $i < strlen($s); $i++) {
      $b = ord($s[$i - 1]) or $b = 32;
      $a = ord($s[$i + 1]) or $a = 32;
      $t = ($b ^ ord($s[$i])) | $a;
      $r .= chr($t > 126 ? ($t % 127) + 32 : $t);
    }
    echo $s = $r;
  }
}

```
> 3 votes

# Answer
# Perl, 47 bytes

Includes +2 for `-lp`

Run with the input on STDIN, e.g. `perl -lp xoror.pl <<< "Hello, World!" | head -26`

`xoror.pl`:

```
/./s;$_=$_.chop^" $_"|"$' ";y/\x7f/ /;print;redo

```

This works as is, but replace the `\x7f` by the corresponding binary value to get the given score
> 3 votes

# Answer
# C++

## Nth-Sequence (212)

```
void x(char*s,int l,int n){for (;n-->0;) {char*t=new char[l-1](),w;for(int i=0;i<l-1;i++)t[i]=((w=(((i-1>= 0)?s[i-1]:32)^s[i])|((i+1<l-1)?s[i+1]:32))>126)?((w%127)+32):w;for(int i=0;i<l-1;i++)s[i]=t[i];delete[]t;}}

```

Un-Golfed

```
void x(char*s, int l, int n){
    for (;n-- > 0;) {
        char*t=new char[l-1](),w;
        for(int i = 0;i < l-1; i++)
            t[i] = ((w = (((i-1>= 0) ? s[i-1] : 32)^s[i]) | ((i+1 < l-1) ? s[i+1] : 32)) > 126) ? ((w % 127) + 32) : w;

        for(int i = 0; i < l-1; i++)
            s[i] = t[i];
        delete[]t;
    }
}

```

Nth-Sequence using pointer syntax instead of array syntax to make this all the more confusing: (231)

```
void x(char*s,int l,int n){for(int x=0;x++<n;) {char*t=new char[l-1](),w;for(int i=0;i<l-1; i++)*(t+i)=((w=(((i-1>= 0)?*(s+i-1):32)^*(s+i))|((i+1<l-1)?*(s+i+1):32))>126)?((w%127)+32):w;for(int i=0;i<l-1;i++)*(s+i)=*(t+i);delete[]t;}}

```

Un-Golfed

```
void x(char* s, int l, int n){
    for (;n-- > 0;) {
        char*t = new char[l-1](),w;
        for(int i = 0; i < l-1; i++)
            *(t+i) = ((w = (((i-1>= 0) ? *(s+i-1) : 32)^ *(s+i)) | ((i+1<l-1) ? *(s+i+1) : 32)) > 126) ? ((w%127)+32) : w;

        for(int i = 0;i < l-1; i++)
            s[i] = t[i];
        delete[]t;
    }
}

```

Debug Function (For Fun)

```
void d(char* seed, int len, int nth) {
    for (int n = 0; n++ < nth;) {
        char* tout = new char[len - 1]();
        for (int i = 0; i < len - 1; i++) {
            char x, y, z;
            x = ((--i >= 0) ? seed[i] : 32);
            y = seed[++i];
            z = ((++i < len - 1) ? seed[i] : 32);
            char w = (x ^ y) | z;
            tout[--i] = (w > 126) ? ((w % 127) + 32) : w;

            cout << "[" << x << " " << y << " " << z << "] " << w << endl;
        }

        for (int i = 0; i < len - 1; i++)
            seed[i] = tout[i];
        delete[] tout;
        cout << endl;
    }
}

```
> 2 votes

# Answer
**JAVA** *240/280 Bytes*

The popular Java version at the time I wrote this claimed to be 185 bytes, but there are two significant fudge points. First, the measurement is presumably only for the function, not for the complete working source. Maybe not such a problem. Second, it uses BiFunction without either an import or a fully qualified name. Adding the required bits to run it as-is (then minimizing it, fairly) brought it to 348 bytes. Adding only the fully qualified name of the BiFunction class brings it to 248 bytes.

In contrast, I believe mine is 240 bytes when playing by the same rules (no class, no actual output, just the meat). The full runnable class is 280 bytes, and looks like this (unminified):

```
class z{
  public static void main(String[] s){
    int L=s[0].length();
    for(int G=Integer.valueOf(s[1]);G-->0;){
      s[1]="";
      for(int N=0;N<L;N++){
        char C=(char)((N>0?s[0].charAt(N-1):' ')^(s[0].charAt(N))|(N<L-1?s[0].charAt(N+1):' '));
        s[1]+=C>126?' ':C;
      }
      System.out.println(s[1]);
      s[0] =s[1];
    }
  }
}

```

Or, minified:

```
void m(String[] s){int L=s[0].length();for(int G=Integer.valueOf(s[1]);G-->0;){s[1]="";for(int N=0;N<L;N++){char C=(char)((N>0?s[0].charAt(N-1):' ')^(s[0].charAt(N))|(N<L-1?s[0].charAt(N+1):' '));s[1]+=C>126?' ':C;}s[0]=s[1];}return s[0];}

```
> 2 votes

# Answer
## Swift: 273 Characters

Wow, Swift is worse than Java! (All those APIs with long names! :P)

```
func c(s:String,n:Int=0-1){var a=[UInt8](s.utf8);for i in 0...(n>=0 ?n:Int.max-1){var z="";for i in 0..<a.count{let A=i-1<0 ?32:a[i-1],B=a[i],C=i+1<a.count ?a[i+1]:32;var r=A^B|C;r=r<32 ?32:r>126 ?32:r;z+=String(UnicodeScalar(r))};if n<0||i==n{print(z)};a=[UInt8](z.utf8)}}

```

Ungolfed:

```
func cellularAutoma(s: String,n: Int = -1)
{
    var array = [UInt8](s.utf8)
    for i in 0...(n >= 0 ? n : Int.max - 1)
    {
        var iteration = ""
        for i in 0..<array.count
        {
            let A = i - 1 < 0 ? 32 : array[i - 1], B = array[i], C = i + 1 < array.count ? array[i + 1] : 32
            var r = A ^ B | C
            r = r < 32 ? 32 : r > 126 ? 32 : r
            iteration += String(UnicodeScalar(r))
        }
        if n < 0 || i == n
        {
            print(iteration)
        }
        array=[UInt8](iteration.utf8)
    }
}

```

Thanks to @CAD97 for mentioning that (A^B)|C can only be greater than 126 when it's 127.

I also realized that you don't need parenthesis around A^B|C because XORing is done before ORing, so that saved me a few bytes.
> 1 votes

# Answer
# Vyxal, 23 bytes

```
(ðpǏ3lƛC÷∇꘍⋎:₇⇩>[32];C∑

```

Try it Online!

```
(                       # N times..
 ðpǏ                    # Enclose in spaces
    3l                  # Get overlapping substrings of length 3
      ƛ             ;   # Map...
       C÷               # Iterate out charcodes
         ∇꘍⋎            # XOROR
            :₇⇩>[  ]    # If greater than 126
                 32     # Push 32
                     C∑ # Stringify and concatenate

```
> 1 votes

---
Tags: code-golf, string, bitwise, cellular-automata
---


title: Orthogonal Orientation

text:
# Question
Title: Orthogonal Orientation
**Task:** Given an input consisting of exactly one of the characters `<>^v`, output a second input consisting of the printable ASCII characters (from space to tilde), oriented with the arrow.

Let's assume the second input to the program is `ABC`. This is what it should do:

* Input `>`: print `ABC`.
* Input `<`: print `CBA`.
* Input `^`: print `C\nB\nA`, or the input rotated -90°.
* Input `v`: print `A\nB\nC`, or the input rotated 90°.

## Test cases

```
input => \n output
---
">", "thanks!" =>
thanks!
---
"<", "Hello, World!" =>
!dlroW ,olleH
---
"^", "This is text." =>
.
t
x
e
t

s
i

s
i
h
T
---
"v", "Tokyo" =>
T
o
k
y
o
---
"<", ">>>" =>
>>>

```

This is a , so the shortest program in bytes wins.

# Answer
# MATL, ~~10~~ 6 bytes

*4 bytes saved thanks to Martin!*

```
19\qX!

```

**Try it online!**

```
19\            % implicitly take input (a character) and compute mod-19 of its ASCII code
   q           % subtract 1. Gives 17, 2, 3, 4 for the characters '^<v>' respectively.
               % These numbers correspond to 1, 2, 3, 4 modulo 4, and so are the numbers
               % of 90-degree rotations required by each character
    X!         % implicitly take input (string). Rotate the computed number of times
               % in steps of 90 degrees. Implicitly display

```

---

Old version, without modulo operations: 10 bytes

```
'^<v>'=fX!

```

Try it online!

```
'^<v>'         % push string
      =        % implicitly take input (a char) and test for equality
       f       % find index of matching character
        X!     % implicitly take input (string). Rotate that number of times
               % in steps of 90 degrees. Implicitly display

```
> 14 votes

# Answer
## Python 3, ~~64~~ ~~51~~ 48 bytes

Saved 6 bytes thanks to xnor.

Saved 7 bytes thanks to Lynn.

Saved 3 bytes thanks to DSM and Morgan from **so**python.

```
lambda c,s:'\n'[c<'?':].join(s[::1|-(c in'<^')])

```

The function accepts one of the characters from `<>^v` as the first argument and the string that needs to be rotated as the second argument.

---

Here's a more readable version:

```
lambda c, s: ('\n' if c in '^v' else '').join(s[::-1 if c in'<^' else 1])

```
> 12 votes

# Answer
## Haskell, 57 bytes

```
f">"=id
f"<"=reverse
f"v"=init.((:"\n")=<<)
f _=f"<".f"v"

```

Usage example: `f "v" "ABC"` -\> `"A\nB\nC"`.

Direction `>` is the idendity function, `<` reverses it's argument, `v` appends a newline to each character in the string and drops the last one and `^` is `v` followed by `<`.
> 8 votes

# Answer
# Japt, 9 bytes

```
VzUc %B+1

```

Inspired by @DonMuesli's answer, although I just noticed the CJam one uses exactly the same technique. Test it online!

### How it works

```
           // Implicit: U = arrow char, V = text
  Uc %B    // Take the char code of U, mod 11.
           // This converts ">", "v", "<", and "^" to 7, 8, 5, and 6, respectively.
Vz     +1  // Add one and rotate V by 90° clockwise that many times.

```
> 6 votes

# Answer
# Pyth, ~~17~~ 15

```
jWgz\^_W}z"<^"w

```

Try it here or run the Test Suite

2 bytes saved thanks to Jakube!

Alternatively using mod tricks:

```
@s_MBjBz)h%Cw11

```

Try it here.
> 4 votes

# Answer
## CJam, 13 bytes

```
l(iB%{W%z}*N*

```

Input is the orientation character followed directly by the string to be rotated.

Test it here.

### Explanation

Yay for modulo magic. Taking the four characters modulo 11 maps them to:

```
> 7
v 8
< 5
^ 6

```

These are all distinct modulo 4 and more importantly they are neatly increasing: `3, 0, 1, 2`. That means we can just use the result of the `mod 11` to determine how often to rotate (without needing an explicit `mod 4`, since four rotations are a no-op anyway). We'd normally have to offset these numbers by 1, such that `>` actually yields `8` and becomes a no-op, but the way I'm rotating them, actually reverses the string on the first application such that we always get one rotation for free.

```
l    e# Read input.
(i   e# Pull off the first character and convert to its character code.
B%   e# Modulo 11.
{    e# That many times...
 W%  e#   Reverse... on the first iteration this reverses the string. Afterwards
     e#   we'll have an Nx1 or 1xN grid of characters on the stack, where
     e#   this reverses the rows instead.
 z   e#   Transpose. On the first iteration, this simply wraps the string in
     e#   array, turning it into a grid without changing its orientation further
     e#   beyond the reversal that just happened. On subsequent iterations, a
     e#   transpose combined with reversing the rows rotates the grid 90 degrees
     e#   clockwise.
}*
N*   e# Join with linefeeds.

```
> 4 votes

# Answer
# Julia, 51 bytes

```
f(d,s)=join(d∈"<^"?reverse(s):s,d∈"^v"?"\n":"")

```

This is a function that accepts a `Char` and a string and returns a string.

Let `d` be the character denoting the direction and `s` be the string. If `d` is left or up, we use the reverse of `s`, otherwise we use `s` as given. We construct a separator as the empty string if `d` is left or right, or a newline if `d` is up or down. The pass the string and the separator to `join`, which will insert the separator between each character of the string and return a string.

Verify all test cases online
> 3 votes

# Answer
## JavaScript (ES6), ~~76~~ ~~67~~ 65 bytes

```
(a,b)=>(/v|>/.test(a)?[...b]:[...b].reverse()).join(a>`>`?`
`:``)

```

Port of @Alex A.'s Julia answer. Edit: Saved 9 bytes thanks to @ETHproductions. Saved two bytes separately thanks to @edc65.
> 3 votes

# Answer
# Bash + GNU Utilities, 67

```
(egrep -q '>|v'<<<$1&&cat||rev)|(egrep -q '<|>'<<<$1&&cat||fold -1)

```
> 3 votes

# Answer
# Perl, ~~54~~ 51 + 1 = 52 bytes

```
@.=<>=~/./g;@.=reverse@.if/[<^]/;$,=$/x/[v^]/;say@.

```

Requires the `-n` flag and the free `-M5.010`|`-E`. Takes input as the following: `direction\nline`:

```
$ perl -nE'@.=<>=~/./g;@.=reverse@.if/[<^]/;$,=$/x/[v^]/;say@.' <<< $'^\nhello'
o
l
l
e
h

```

I like that `$/x/[v^]/` looks like a substitution.

How it works:

```
                                                    # -n read first line into $_
@.=<>=~/./g;                                        # Read next line and split
            @.=reverse@.if/[<^]/;                   # Reverse `@.` if matches
                                                    # `<` or `^`
                                 $,=                # An array will be concatena-
                                                    # ted with the value of
                                                    # `$,` when printed.
                                     $/             # Contains a newline
                                        /[v^]/      # boolean
                                       x            # "\n" x 1 -> "\n"
                                                    # "\n" x 0 -> ""
                                              say@. # Print the array

```
> 3 votes

# Answer
# Retina, 60 bytes

Needs golfing...

```
$
¶
+`^([<^].*)(.)(¶.*)
$1$3$2
¶

.
$&¶
+`([<>].*)¶
$1
^.¶?

```

Input is all as one string, e.g. `^ABC`.

* If `^` or `<`, reverse the string
* Insert newlines after every character
* If `<` or `>`, remove the newlines

Try it online.
> 2 votes

# Answer
## PowerShell, 84 bytes

```
param([char]$a,$b)($b[($c=$b.length)..0],$b[0..$c])[$a%7-eq6]-join("","`n")[90-lt$a]

```

This is going to be complete gibberish to people not familiar with PowerShell. Let's go through it.

Takes input `param([char]$a,$b)`, with an explicit cast to character for `$a`. The rest of the program is one statement. We'll start with the first half, up to the `-join`.

We're creating a new dynamic array `(...,...)` and indexing into it with `$a%7-eq6`. The ASCII values for `v` and `>` are `116` and `62`, respectively, and `116%7 = 62%7 = 6`, and those are the two directions that "increase" down and to the right. So, if that `-eq` is `$true`, we'll take the second value, which is `$b[0..$c]`, or *an array of the characters of `$b` up to the end*. We get the value `$c` from the first value, `$b[($c=$b.length)..0]`, which gets selected if the input char is `^` or `<` (i.e., so it goes through the string backwards). Important to note is that even if the second value is selected, the `$c` value is still calculated and stored, so we can re-use it as a shortcut like this.

So, we've now got an array of characters either going forwards or backwards. We then `-join` those characters together with the result of another dynamic array index. This time we're selecting based on whether the ASCII value for `$a` is below `90` (really lots of values would work, I selected this one just because). Since `>` and `<` both have a value below `90`, the `-lt` is `$false`, so we select the empty string `""`, and thus the char-array is simply concatenated. Otherwise, we select the newline character `"`n"` to join the char-array together with newlines.

This resultant string is left on the pipeline, and output is implicit.

**Example**

```
PS C:\Tools\Scripts\golfing> .\orthogonal-orientation.ps1 "^" "TimmyD"
D
y
m
m
i
T

```
> 2 votes

# Answer
# Dyalog APL, 15 bytes

```
⌽∘⍉⍣(11|⎕UCS⍞)⍪

```

make string into 1-column table
`⍣(``)` repeat (*n*) times  get string input
`⎕UCS` convert to UCS code point
`11|` division rest when divided by 11
`⌽∘⍉` rotate -90° (flip-transpose)

Alternate method (same length):

```
⌽∘⍉⍣('<^>v'⍳⎕)⍪

```

get evaluated input (so one must input, e.g. '^' or the name of a program/variable that returns the desired character)
`'<^>v'⍳` index into the string
> 2 votes

# Answer
# C, ~~123~~ ~~119~~ ~~117~~ 114 bytes

Golfed:

```
f(char*d,char*a){char*b=a,c=*d%21,s[3]={0,c&8?10:0};while(*++b);while(*s=c&4?*a++:*--b)printf(s);if(c&16)puts(b);}

```

Test program, with explanations & somewhat ungolfed code:

```
#include <stdio.h>
#include <stdlib.h>

// c     c%21
// <    10010     => if(c&8), vertical; if(c&16), horizontal
// >    10100     => if(c&4), backwards
// ^    01010
// v    01101
int f(char*d,char*a){
    char *b=a,c=*d%21,s[3]={0,c&8?10:0};
    while(*++b);     // b = a + strlen(a) - 1; this is shorter
    while(*s=c&4?*a++:*--b)printf(s);
    if(c&16)puts(b); // single trailing newline if horizontal
}

int main() {
    char *c="<>^v";
    for(;*c;c++) {
        printf("--- %c ---\n", *c);
        f(c,"hello world!");
    }
    return 0;
}

```

Tips welcome!
> 2 votes

# Answer
# Japt, 7 bytes

```
zVc %BÄ

```

Try it here
> 2 votes

# Answer
# JavaScript ES6, ~~91~~ ~~83~~ 84 bytes

```
(a,b)=>[b,(c=[...b].reverse()).join``,[...b].join`
`,c.join`
`]["><v^".indexOf(a)]

```

Constructs the necessary strings and obtains the index of which `a` lies in. `indexOf` is used because `^` is a regex token. Thanks to ETHproductions for the bug fix and shaved bytes!
> 1 votes

# Answer
# Jolf, 22 bytes

Try it here! You should replace `ƒ` with `\x9f`. Takes the sting, then the directional character.

```
.‘I_IγƒGIE_γ’ i"><v^"i
 ‘                      golfy array
  I                     the input
   _I                   input reversed
      ƒGIE              split by "" and join by newlines
     γ                  γ = that
          _γ            gamma reversed
.            _i"><v^"i  get the respective index

```
> 1 votes

# Answer
# Perl 5, 67 bytes

66 plus one for `-p`

```
$_=reverse if/^[<^]/;$&?s/.$//:s/.//;$&=~/[v^]/&&s/(.)(?=.)/$1\n/g

```

The input is a single string whose first character defines the orientation.
> 1 votes

# Answer
# JavaScript (ES6) 71

```
(a,b)=>([...b].map(c=>(a>'A'?c+=`
`:0,r=/v|>/.test(a)?r+c:c+r),r=''),r)

```

**Test**

```
F=(a,b)=>([...b].map(c=>(a>'A'?c+=`
`:0,r=/v|>/.test(a)?r+c:c+r),r=''),r)

console.log=x=>O.textContent+=x+'\n';

for(d of '<>^v') console.log(d+'\n'+F(d,'ABCDE')+'\n')
```

```
<pre id=O></pre>
```
> 1 votes

# Answer
# D, 198 bytes

```
import std.stdio,std.array,std.algorithm;void main(string[]a){auto x=a[2].split("");char[]y;if(canFind(["^","<"],a[1]))x.reverse;if(canFind(["v","^"],a[1]))y=x.join("\n");else y=x.join("");y.write;}

```

:c

---

Less golfed:

```
import std.stdio;
import std.array;
import std.algorithm;

void main(string[]a) {

  auto x=a[2].split("");
  string y;

  if(canFind(["^","<"],a[1]))
    x.reverse;

  if(canFind(["v","^"], a[1]))
    y=join(x,"\n");

  else
    y=join(x,"");

  y.write;
}

```
> 1 votes

# Answer
# DUP, 48 bytes

```
[`5/%$$a:4<&[1$][1_]?\1-[$;$][,^+a;2>['
,][]?]#]

```

`Try it here.`

Anonymous lambda that takes both argument and STDIN input. Usage:

```
0"asdf"[`5/%$$a:4<&[1$][1_]?\1-[$;$][,^+a;2>['
,][]?]#]! {make sure to put one of <>^v in STDIN}

```

# Explanation

```
[                                               ] {lambda}
 `5/%$$a:                                         {store STDIN char (mod 5) to a}
         4<&                                      {is 0<a<4?}
            [  ][  ]?                             {conditional}
             1$                                     {if so, push 2 1's}
                 1_                                 {otherwise, push -1}
                                                    {determines whether to output in reverse or not}
                     \1-                          {swap, -1}
                        [   ][                ]#  {while loop}
                         $;$                        {if there is a char at index}
                              ,                     {output that char}
                               ^+                   {increment/decrement index}
                                 a;2>               {check if a>2}
                                     [    ][]?      {conditional}
                                      '\n,          {if so, output newline}

```
> 1 votes

# Answer
## Seriously, 41 bytes

```
,' 9uc#;+"? R #'{}j #R'{}j"fs,"><v^"í@E£ƒ

```

Takes the string as the first input and the direction (`><v^`) as the second input.

Try it online!
> 1 votes

# Answer
# Vyxal, 16 bytes

```
C:½›₃[√⌈₂ßṘ⁋|₃ßṘ

```

Try it Online!

```
C:               # Get charcode, dupe for later use
  ½›₃[           # If C/2 + 1 %  3 == 0 (`^v`)...
      √⌈₂        # Is ceil(√C) is even?
         ßṘ      # If so, reverse
           ⁋     # Join by newlines
            |    # Else...
             ₃   # Is C divisible by 3?
              ßṘ # If so, reverse

```
> 0 votes

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


title: Help Alice fix her text!

text:
# Question
Title: Help Alice fix her text!
When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so `q` became `w`, `w` became `e`, etc. (`p` became `[`). Spaces were not affected because the space bar was quite big.

Your task is to help her fix her message using the shortest number of bytes, i.e. undo the shifting of her hand positions. More precisely, you will be given a string consisting of spaces as well as characters from `wertyuiop[sdfghjkl;xcvbnm,` and you need to map the characters to `qwertyuiopasdfghjklzxcvbnm` and leave spaces untouched.

Here are some testcases for you to test your program:

```
input      output
----------------------
s[[;r      apple
s gom      a fin
werty      qwert
uiop[      yuiop
sdfgh      asdfg
jkl;       hjkl
xcvb       zxcv
nm,        bnm
 ;p;;o[p[   lollipop
[2 spaces] [2 spaces]

```

(the `lollipop` testcase starts with a space)

Figure 1: Alice's QWERTY keyboard

This is . Shortest answer in bytes wins.

# Answer
# Jelly, 15 bytes

```
ØqḊ€ż“[;,”F,Fyɠ

```

Try it online!

Takes input via STDIN

## How it works

```
ØqḊ€ż“[;,”F,Fyɠ - Main link. Takes no arguments
Øq              - Set the return value to ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']
  Ḋ€            - Dequeue each; ['wertyuiop', 'sdfghjkl', 'xcvbnm']
    ż“[;,”      - Zip with "[;,"; [['wertyuiop', '['], ['sdfghjkl', ';'], ['xcvbnm', ',']]
          F     - Flatten; "wertyuiop[sdfghjkl;xcvbnm,"
            F   - Flatten the return value; "qwertyuiopasdfghjklzxcvbnm"
           ,    - Pair; ['wertyuiop[sdfghjkl;xcvbnm,', 'qwertyuiopasdfghjklzxcvbnm']
              ɠ - Read a line from STDIN
             y  - Translate. Map w -> q, e -> w, etc.

```
> 12 votes

# Answer
# , 43 bytes

```
'qwertyuiop[asdfghjkl;zxcvbnm,  '(<:@i:{[)]

```

Try it online!

* `'qwertyuiop[asdfghjkl;zxcvbnm, '` The full keyboard, including the shifted away left-most chars and the extra chars `[;,`, as well as two extra spaces at the end.
* `<:@i:` Find the index of the input within that, searching from the right, and substract one.
* `{[` Pull those shifted indexes from the string in step 1.
> 10 votes

# Answer
# C++ (Windows MSVC), 92 bytes

```
#include<Windows.h>
void f(PCH s){for(;*s;)*s++=MapVirtualKey(OemKeyScan(*s)-(*s>32),1)|32;}

```

Take input as a `char*` (`PCH` is typedef of `char*`), output by modify the string in-place.

Trying to make use of some built-ins. But seems not quite short. Maybe some one may take this idea and make a shorter one in other languages.

`OemKeyScan` convert key to its scancode, `'q' -> 16`, `'w' -> 17`, `'e' -> 18`, ..., `'p' -> 25`, `'a' -> 30`, ..., `'l' -> 38`, `'z' -> 44`, ..., `'m' -> 50`. `MapVirtualKey` convert scancode back to (uppercase) character.

Saved 1 byte by ErikF.
> 10 votes

# Answer
# Vyxal, ~~16 13~~ 12 bytes

```
k•`[;,`Y∑:ǔĿ

```

Try it Online!

```
k•           # Qwerty keyboard (array of rows)
  `[;,`Y     # Interleave with `[;,`
        ∑    # Concatenate all of that
         :ǔĿ # Shift each character 1 right relative to this in the input.

```
> 8 votes

# Answer
# Python 3, 61 bytes

```
lambda s:s.translate('p?ml ??'*14+'vxswdfguhjknbio?earycqzt')

```

Try it online!

### Explanation

A naive implementation with `str.translate` would use the following translation table:

```
???????????????????????????????? ???????????m??????????????l???????????????????????????????p??????vxswdfguhjknbio?earycqzt

```

To optimize for size, notice that the characters `' mlp'` all have different positions, modulo 7. As such, we can replace the first 98 characters of the table with `'p?ml ??'*14`. The rest of the table is the same.
> 7 votes

# Answer
# Bash, 34 bytes

```
tr snvfrghjokl\;,mp[wtdyibecux a-z

```

Try it online! Using `bash` because I don't know how to score this as a `tr` answer.
> 6 votes

# Answer
# Haskell, 65 bytes

```
a#(c:d)|a==c=d!!0|1>0=a#d
map(#",mnbvcxz;lkjhgfdsa[poiuytrewq  ")

```

Try it online!

`(#)` takes a character and a string and returns the character after the first match in the string. Our implementation then just maps this across the string with `,mnbvcxz;lkjhgfdsa[poiuytrewq`  as the preset string.
> 6 votes

# Answer
# JavaScript (ES6), 66 bytes

I/O format: array of characters.

```
a=>a.map(c=>(S="  ,mnbvcxz;lkjhgfdsa[poiuytrewq")[S.indexOf(c)+1])

```

Try it online!

---

# JavaScript (ES6), 57 bytes

If taking an array of ASCII codes as input and returning an array of characters is acceptable, we can do:

```
b=>b.map(c=>"rjbwgtvacnofh_spzleykidumx_q "[c*19%116%30])

```

Try it online!
> 5 votes

# Answer
# C# (Visual C# Interactive Compiler), 64 bytes

```
x=>x.Select(t=>" mlpvxswdfguhjknbio?earycqzt"[t%94%88%57%43%32])

```

Try it online!
> 5 votes

# Answer
# C (gcc), 79 bytes

I combined the source and destination strings so that I can take the character after the match. By inverting the list of characters, I could avoid -1 indexes and having to special-case spaces.

```
f(char*s){for(;*s;putchar(strchr(",mnbvcxz;lkjhgfdsa[poiuytrewq  ",*s++)[1]));}

```

Try it online!
> 4 votes

# Answer
# Ruby -p, 40+1 bytes

```
$_.tr!"snvfrghjokl;,mp[wtdyibecux","a-z"

```

Try it online!
> 4 votes

# Answer
# Retina 0.8.2, 36 bytes

```
T`snvfrg\hj\ok\l;,m\p[\wt\dyibecux`l

```

Try it online! Link includes test cases. Explanation: Simply a transliteration, although Retina's built-in classes need to be escaped on the source string (obviously the built-in class `l` is desired on the target string).

Alternative solution, also 36 bytes:

```
T`\wertyuio-p[as\df-hj-l;zxcvbnm,`qo

```

Try it online! Link includes test cases. Transliterates the letters in keyboard order. This costs bytes because `a` and `z` have to be included in the source list and `q` in the destination list but then bytes can be saved by using character ranges to avoid quoting the `o`, `p`, `h` and `l` character classes.
> 3 votes

# Answer
# Japt `-m`, 29 bytes

```
;D+S ·¬v gD·mÅí"[;,"¬'+ ¬v bU

```

Try it

```
; -> use second set of predef. Vars
-m flag -> map input by the program  (U)->

     g   - take from
D+S·¬v     [ QWERTY +' ' split on (\n),rejoined, to lowercase ]
Dxxx bU  - at index of input in[WERTY..]

D·   - QWERTY split on \n
mÅ   - remove 1st char on each
í    - pair with :
"[;,"¬  - ..splitted
'+   - and join
¬v   - join all and to lowercase

```
> 3 votes

# Answer
# Charcoal, 36 bytes

```
≔”⧴3�⁷Ｒrηs⟲θ]⁺L÷↗¹Ｔ“[～↓TφF”η⭆Ｓ§η⊕⌕ηι

```

Try it online! Link is to verbose version of code. Explanation: Port of @ErikF's C answer, except putting the spaces at the beginning because that compresses better.

```
≔”⧴3�⁷Ｒrηs⟲θ]⁺L÷↗¹Ｔ“[～↓TφF”η

```

Assign the compressed string  `,mnbvcxz;lkjhgfdsa[poiuytrewq` to a variable.

```
⭆Ｓ§η⊕⌕ηι

```

Find each input character in the string and print the character that follows it.
> 2 votes

# Answer
# Perl 5, 57 bytes

```
s/./",mnbvcxz;lkjhgfdsa[poiuytrewq  "=~m|\Q$&\E(.)|;$1/ge

```

Try it online!

```
s/.                                  #replace one char at a time from input
 /
   ",mnbvcxz;lkjhgfdsa[poiuytrewq  " #...with its next char in this string
     =~ m| \Q$&\E (.)|x;             #found by searching for current char in $&
                                     #which must be escaped by \Q and \E
                                     #since [ has a special meaning in regexes.
   $1                                #Return next char captured into $1 by (.)
 /gex                                #g = global search: all chars
                                     #e = treat replacement string as eval code
                                     #x = allow white-space, improve readability

```
> 2 votes

# Answer
# , ~~68~~ 55 bytes

```
function(x)chartr("snvfrghjokl;,mp[wtdyibecux","a-z",x)

```

Try it online!

Abusing laconic `Ranges are supported in the specifications` in `chartr` documentation (forced to work by try and error).

Inspired by @Neil's answer.
> 2 votes

# Answer
# Haskell, 59 bytes

```
mapM(`lookup`(zip<*>tail)",mnbvcxz;lkjhgfdsa[poiuytrewq  ")

```

Try it online!

A function `String -> Maybe String`; it maps `"s gom"` to `Just "a fin"`.
> 2 votes

# Answer
# Common Lisp, 102 bytes

```
(defun f(i &aux(s",mnbvcxz;lkjhgfdsa[poiuytrewq  "))(map'string(lambda(c)(elt s(1+(position c s))))i))

```

Try it online!

Test cases included in TIO.
> 2 votes

# Answer
# Excel, 93 bytes

```
=CONCAT(IFERROR(CHAR(FIND(MID(A1,SEQUENCE(LEN(A1)),1),"snvfrghjokl;,mp[wtdyibecux")+96)," "))

```

Link to Spreadsheet
> 2 votes

# Answer
# PHP, 80 bytes

```
str_replace($a=str_split('wertyuiop[asdfghjkl;yxcvbnm,'),[-1=>'q']+$a,$argv[1]);

```

Avoids string repetition and double str\_split().

Try it online!
> 2 votes

# Answer
## PHP, 186 114 Bytes

```
$W=str_split(",mnbvcxz;lkjhgfdsa[poiuytrewq");for(;$c=$argv[1][$p++];)echo($c!==" ")?$W[array_flip($W)[$c]+1]:" ";

```

Try it online! Definitely not the shortest answer on here, but I'm not sure how I could handle this in PHP without using a big array. Any input would be greatly appreciated!

-72 bytes by changing a large keyed array into one small one. Just iterates over every character, find it in the array, then prints the next element in the array.
> 1 votes

# Answer
# Pyth, ~~45~~ 35 bytes

```
.rQ"[poiuytrewq;lkjhgfdsa,mnbvcxz

```

Try it online!

~~```
sm?gJtxK.",zcVÖzùwÔ\"Ã?4‰ØÝ”gR¹³3"dZ@KJ\ Q

```~~

Try it online!

***Edit:** Improved solution is rather boring...
`"[poiuytrewq;lkjhgfdsa,mnbvcxz`  is a string of every possible char followed by the char it's meant to be (i.e. ytrewq) with two spaces on the end (space is meant to be space);

This is all surrounded with `.r` which will translate each element of `Q`(Input) into the next element.

**Previous solution**
Haven't golfed in a while so this feels pretttty rusty...

Maps through qwerty string, shifting char to the left unless it's a space.
> 1 votes

# Answer
# 05AB1E, 13 bytes

```
žV€¦…[;,øSžW‡

```

Try it online.

**Explanation:**

```
žV            # Push builtin ["qwertyuiop","asdfghjkl","zxcvbnm"]
  €¦          # Remove the first character from each: ["wertyuiop","sdfghjkl","xcvbnm"]
    …[;,ø     # Zip/transpose with string "[;,":
              #  [["wertyuiop","["],["sdfghjkl",";"],["xcvbnm",","]]
         S    # Convert it to a flattened list of characters:
              #  ["w","e","r","t","y","u","i","o","p","[","s","d","f","g","h","j","k",
              #   "l",";","x","c","v","b","n","m",","]
          žW  # Push builtin "qwertyuiopasdfghjklzxcvbnm"
            ‡ # Transliterate all characters in the (implicit) input
              # (after which the result is output implicitly)

```
> 0 votes

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


title: Passwordify the string

text:
# Question
Title: Passwordify the string
Your challenge is to passwordify the string! What is passwordifying, you ask?

Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces.

You must replace all spaces with underscores and move all numbers to the end of the string in the order that they appear from left to right. Then, for every letter in the string, randomly change it to uppercase or lowercase.

Examples (case of characters should vary every time):

```
Input
Hello world
Output
HElLo_wORld

Input
pa55 w0rd
Output
pA_Wrd550

Input
14 35
Output
_1435

Input
0971
Output
0971

Input
[space]
Output
_

```

## Shortest code in bytes wins!

Whoever asks on Information Security SE if this is a good hashing algorithm wins!--Don't worry SE overlords, I'm just kidding.

# Answer
> 12 votes
# Pyth, 15 bytes

```
s}D`MTrRO2Xzd\_

```

Demonstration

```
s}D`MTrRO2Xzd\_
                   Implicit: z = input(), d = ' '
          Xzd\_    In z, replace ' ' with '_'.
      rR           To each character, apply r-function
        O2         Randomly 0 or 1. r 0 is lowercase, r 1 is uppercase.
 }D                Order the characters based on presence in
   `MT             The strings of the numbers 0 to 9.
s                  Concatenate into a string.

```

# Answer
> 27 votes
## Labyrinth, 76 bytes

```
 `:_64/"32}
,`    (3  :=-{
"`{"; _v2$  ;`3
"`".:@ ; ".5(`3.
<       "" `^`;>

```

Another collab with @MartinBüttner and on the more insane side of the Labyrinth spectrum – for the first time we have all four of `^>v<` in the one program. Try it online!

### Explanation

The general algorithm, which runs in a loop, is as follows:

```
 1.   Read a char
 2.   If EOF:
 3.     Move all digits from auxiliary stack to main
 4.     Output all digits on main stack
 5.     Halt
      Otherwise:
 6.     If char is a letter (c >= 64):
 7.       If random turns left:
 8.         Output char XOR 32
          Otherwise:
 9.         Output char
        Otherwise:
10.       Shift char to auxiliary stack
11.       If char is space (c-32 == 0):
12.         Pull char back from auxiliary stack
13.         Output underscore
          Otherwise:
14.         Continue loop

```

To keep the explanation compact, here's roughly how each part of the program corresponds to the pseudocode above:

Here are the interesting parts.

### Getting randomness in Labyrinth

There's only one way to get randomness in Labyrinth, and it's when the IP tries to go forwards but 1) there's neither a path forwards nor backwards and 2) there's paths available left and right. In this case, the IP randomly chooses between the left and right routes.

This is only possible using the`^>v<` operators, which pop `n` and shift the row/column `n` away by 1. For example, the program (Try it online!)

```
" 1
""v!@
  2
   !@

```

outputs either 1 or 2 randomly, since the `v` shifts the column with offset 0 (i.e. the column the IP is on) by 1, yielding

```
"
""1!@
  v
  2!@

```

The IP is facing rightward and tries to go forwards (top of stack is zero) but can't. It also can't move backwards, so it randomly chooses between left or right.

### Golf tricks

* The program starts from the first char in reading order, which you'll notice is actually step 6. However, popping from an empty Labyrinth stack yields 0, so steps 10 and 14 occur, shifting a zero to the auxiliary stack, which is effectively a no-op.
* The main stack is effectively empty after every iteration, which allows us to golf the code layout by using `>` and `<` on the implicit zeroes at the bottom. The `>` wraps the bottom row around so that the IP moves from the bottom right to the bottom left, and the `<` shifts the row back. The IP then happily moves up the left column to continue the loop.
* Digits in Labyrinth pop `n` and push `10*n + <digit>`. In addition, chars are taken modulo 256 before being output. Putting these two together lets us output 95 (underscore) by doing ``33` to 32 (space), which works because `-3233 % 256 = 95`. Even though there are other ways to turn 32 into 95 (`;95` being the easiest), working with a negative number here allows us to compact the code a bit with left turns.

# Answer
> 8 votes
# 05AB1E, ~~22~~ ~~21~~ 20 bytes

Code:

```
þ¹žh-s«ð'_:vyždÈiš}?

```

Uses **CP-1252** encoding.

Try it online!

# Answer
> 8 votes
## Python, 107 bytes

```
from random import*
lambda s:''.join([choice(c+c.swapcase()),'_'][c<'!']for c in sorted(s,key=str.isdigit))

```

An improvement on the other two Python answers because:

* `[...,'_'][c<'!']` is used instead of `s.replace(' ','_')`, and
* `choice(c+c.swapcase())` is used instead of `choice([c.upper(),c.lower()])`

# Answer
> 7 votes
# MATL, 27 bytes

```
k32'_'XEt58<2$S"@rEk?Xk]]v!

```

**Try it online!**

```
k         % implicit input. Make lowercase. Non-lettters are not affected
32'_'XE   % replace spaces by underscores
t58<      % duplicate. Create logical index: true for digits, false otherwise
2$S       % sort first string according to second. Sort is stable
"         % for each character in that string
  @       %   push that character
  rEk     %   generate 0 or 1 with 1/2 probability each
  ?       %   if it's a 1
    Xk    %     make uppercase. Non-letters are not affected
  ]       %   end if
]         % end for each
v         % vertically concatenate all stack contents
!         % transpose into a row char array, i.e. a string. Implicit display

```

# Answer
> 7 votes
# CJam, 25 bytes

```
lelS'_er{58<}${2mr{eu}&}%

```

**Try it online!**

### Explanation

Translation of my MATL answer.

```
l                            e# read line as a string
 el                          e# make lowercase
   S'_er                     e# replace spaces by underscores
        {58<}$               e# (stable) sort with key "is digit"
              {        }%    e# map block over the string
               2mr           e# generate 0 or 1 equiprobably
                  {eu}&      e# if it's 1, make uppercase

```

# Answer
> 7 votes
## CJam, 23 bytes

```
lS'_er{60<}${eu_el+mR}%

```

Test it here.

### Explanation

```
l       e# Read input.
S'_er   e# Turn spaces into underscores.
{60<}$  e# Sort (stably) by whether the character is a digit or not. This moves digits
        e# to the end, without changing the relative order within digits or non-digits.
{       e# Map this block over the characters...
  eu    e#   Convert to upper case.
  _el   e#   Make a copy and convert to lower case.
  +     e#   Join them into one string.
  mR    e#   Randomly choose one of the characters. Of course, this entire block is a
        e#   no-op for non-letter characters.
}%

```

# Answer
> 7 votes
## JavaScript (ES6), ~~114~~ 101 bytes

```
s=>s.replace(/./g,c=>c>'9'?c[`to${Math.random()<.5?"Low":"Upp"}erCase`]():c>' '?(s+=c,''):'_',s='')+s

```

47 bytes just to randomise the case of a character...

Edit: Saved a massive 13 bytes thanks to @edc65.

# Answer
> 5 votes
# Python 3, ~~128 122~~  118 chars

```
from random import*
s=lambda x:''.join(choice(i.upper()+i.lower())for i in sorted(x.replace(' ','_'),key=str.isdigit))

```

Thanks to xnor for shaving off 6 bytes.

# Answer
> 5 votes
# Perl 6, ~~77~~ ~~75~~ 61 bytes

```
{[~] |S:g/' '/_/.comb(/\D/)».&{(.lc,.uc).pick},|.comb(/\d/)}

```

`S///` is like `s///` except it doesn't modify `$_` in place

# Answer
> 4 votes
# Pyth, 17 bytes

```
smrdO2o}N`UT:zd\_

```

Try it here!

## Explanation

```
smrdO2o}N`UT:zd\_   # z = input

            :zd\_   # replace spaces with underscores
      o             # Sort ^ with key function(N)
       }N`UT        # N in "0123456789", gives 1 for numbers so they get sorted to the right
 m                  # map every character d of ^
  rdO2              # Convert d randoms to upper- or lowercase
s                   # join list back into one string

```

# Answer
> 4 votes
## Mathematica, 86 bytes

*Thanks to Sp3000 for saving 1 byte.*

```
RandomChoice[{ToLowerCase,Capitalize}]@#/." "->"_"&/@Characters@#~SortBy~{DigitQ}<>""&

```

Ahhh, string processing Mathematica... isn't it lovely. This is an unnamed function that takes and returns a string.

Due to all the syntactic sugar, the reading order is a bit funny:

```
Characters@#

```

Split the string into characters, otherwise we can't really do anything at all with it.

```
...~SortBy~{DigitQ}

```

Sorts the digits to the end. By wrapping the test function in a list, we make the sorting stable.

```
...&/@...

```

Maps the left-hand function over each character in the list.

```
RandomChoice[{ToLowerCase,Capitalize}]

```

Chooses a random case-changing function for the current character.

```
...@#...

```

Applies it to the current character.

```
.../." "->"_"

```

Replaces spaces with underscores.

```
...<>""

```

Finally joins all the characters back together into a string.

# Answer
> 3 votes
# PowerShell, 113 Bytes

```
-join([char[]]$args[0]-replace" ","_"|%{if($_-match"\d"){$d+=$_}else{"'$_'.To$("Low","Upp"|random)er()"|iex}})+$d

```

---

PowerShell stands for horrible golfing language. Split into char array and replace spaces with underscores. Take each character and process. Collect numbers into variable $d for later output. Each other character is randomly make into uppercase or lowercase by invoking an expression using `'char'.ToLower()` or `'char'.ToUpper()`. If any digits were collected append them on the end.

# Answer
> 3 votes
# Julia, ~~88~~ ~~87~~ 78 bytes

```
s->join([c<33?'_':rand([ucfirst,lcfirst])("$c")for c=sort([s...],by=isdigit)])

```

This is an anonymous function that accepts a string and returns a string. To call it, assign it to a variable.

First we break the input string into an array of its characters, and sort the array according to whether each character is a digit. This maintains order in the text and digits but pushes digits to the end. Then, for each character in the array, we check whether it's a space. If so, replace with an underscore, otherwise randomly choose one of `ucfirst` or `lcfirst` to apply to the character, thereby converting it to upper- or lowercase, respectively. Join the array into a string and we're done!

Try it here

Saved 9 bytes thanks to Sp3000!

# Answer
> 3 votes
# Perl, ~~51~~ 48 bytes

Includes +2 for `-lp`

Run with the input on STDIN:

```
perl -lp passwordify.pl <<< "Hel1lo wo4rld"

```

`passwordify.pl`:

```
s%\pL%$&^$"x rand 2%eg;$_=y/ 0-9/_/dr.s/\D//gr

```

# Answer
> 2 votes
# Ruby, 84 bytes

Anonymous function. Removing the space before `c.downcase` causes a syntax error for some reason and I'm not sure why.

```
->s{q="";s.gsub(/./){|c|c=~/\d/?(q+=c;p):c==" "??_:rand<0.5?c.upcase: c.downcase}+q}

```

# Answer
> 1 votes
# Factor, 154 bytes

or 222 with importing `kernel splitting sequences ascii combinators.random regexp`

```
: f ( x -- y ) R/ \d/ R/ \D/ [ all-matching-subseqs ] bi-curry@ bi [ { [ >upper ] [ >lower ] } call-random ] map [ "" join ] bi@ " " "_" replace prepend ;

```

I'm not too good at golfing in factor, and I'm not sure if I took the best approach here, but thought I'd give it a go

# Answer
> 1 votes
## Lua, 125 Bytes

When object meets functional, you can do some pretty things, even in lua! I don't think I can golf this down, it's already quite a huge mess, and I'm already happy to beat most of the python answers :D.

```
s=""print((...):gsub("%d",function(d)s=s..d return""end):gsub("%s","_"):gsub("%a",1<math.random(2)and s.upper or s.lower)..s)

```

### Ungolfed and explanations

```
s=""                       -- Initialise the string that will contains the digits
print((...)                -- apply the following to the argument then print it
  :gsub("%d",function(d)   -- iterate over the digits
    s=s..d                 -- concatenate them in s
    return""               -- remove them from the arg
   end)
  :gsub("%s","_")          -- replace spaces by underscores
  :gsub("%a",              -- iterate over letters
    1<math.random(2)       -- pick a random integer between 1 and 2
      and s.upper          -- if it is 2, use the function upper() of object s
      or s.lower)          -- else, use the function lower() of object s
  ..s)                     -- concatenate with s

```

# Answer
> 1 votes
## Seriously, 25 bytes

```
,`'_' (Æ≈"ûù"J£ƒ`M;ì;(-+Σ

```

Try it online!

Explanation:

```
,`'_' (Æ≈"ûù"J£ƒ`M;ì;(-+Σ
,`              `M         map over input:
  '_' (Æ                     replace spaces with underscores
        ≈                    cast to int (does nothing if cast fails)
         "ûù"J£ƒ             randomly upper- or lowercase it (does nothing if not letter)
                  ;ì;(-+   move ints to back
                        Σ  join

```

# Answer
> 1 votes
# IPOS \- non competing, 14 bytes

```
S'_RE`N-`dE!k?

```

Yes, I added builtins for this challenge, but those are not especially targeted at this problem.

This works with version 0.1 of the interpreter.

## Example run

```
> python IPOS.py S'_RE`N-`dE!k? -i "pa55 w0rd"
Pa_WrD550

```

## Explanation

```
     # Implicit: place input on the stack (C)
S    # Push a space to the stack (B)
'_   # Push an underscore to the stack (A)
R    # In C replace B with A -> replace underscores with spaces
     # the stack contains now only the replaced string (C)
E    # Push an empty string (B)
`    # Start a command literal,
     # the stack for this gets initialized with a single character (B) later
N    # Push the digits 0-9 as string to the stack (A)
-    # Remove every character from B that is in A
`    # End command literal (A)
d    # split C on B, sort the parts descending with the key A and join back on B.
     # The key function A transforms each character of the string to an empty string if it is a digit.
     # Since the resulting char does not contain a digit, it's key value is it's length.
     # This maps the key 0 to digits and the key 1 to non-digits. Sorting this in descending
     # order moves the digits to the right and leaves non-digits in the order they were before.
E    # Push an empty string
!k   # Push the command k (=swapcase)
?    # Apply ^ to every character randomly
     # Implicit: Output stack contents

```

# Answer
> 1 votes
# PHP, 368 bytes

```
$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$output AND $numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<strlen($str);$i++){
    in_array($str[$i],$numArray)?($numStr = $numStr.$str[$i]):((rand(10,100)%2==0)?$str[$i] = strtoupper($str[$i]) AND $output = $output.$str[$i]:$output = $output.$str[$i]);
}
echo $output = $output.$numStr;

```

Ungolfed Code:

```
$str = "pa55 w0rd";
$str = str_replace(" ","_",$str);
$len = strlen($str);
$output = "";
$numStr = "";
$numArray = ['0','1','2','3','4','5','6','7','8','9'];
for($i=0;$i<$len;$i++){
  if(in_array($str[$i],$numArray)){
    $numStr = $numStr.$str[$i];
  }else {
      if(rand(10,100)%2==0)
      {
        $str[$i] = strtoupper($str[$i]);
      }
      $output = $output.$str[$i];
  }
}
$output = $output.$numStr;
echo $output;

```

# Answer
> 0 votes
## Python 2, 179 bytes

```
from random import*
f=lambda s,a=[str.upper,str.lower],n='0123456789':''.join(map(lambda x:choice(a)(x),filter(lambda x:x not in n,s).replace(' ','_')))+filter(lambda x:x in n,s)

```

There's probably a lot of room for improvement here that I'll work out later.

# Answer
> 0 votes
## AWK, 128 Bytes

```
{srand();for(;++i<=split($0,a,"");){s=a[i];if(s!=s+0){o=s==" "?"_":rand()>0.5?tolower(s):toupper(s);A=A o}else{N=N s}}print A N}

```

The `srand()` is needed to give us different random numbers each time it runs.
For this to work properly with multi-line input, we'd need to put something like `A=N=""` before the `for` loop.

# Answer
> 0 votes
# Python 3.5 - 118 bytes:

```
from random import*
lambda y:''.join(choice([q.upper(),q.lower()])for q in sorted(y.replace(' ','_'),key=str.isdigit))

```

As you can see, I am basically using the random module's `choice` function to choose a random function (either .upper() or .lower()) for each letter in the sorted version of the string given, in which all the digits go to the end. Also, every space is replaced with an underscore in the sorted string.

# Answer
> 0 votes
## Python 3, 151 bytes

```
import random as r
x=input();s="";n=""
for c in x:
 if c.isdigit():n+=c
 else:s+=c.upper() if r.randint(0,1) else c.lower()
print(s.replace(" ","_")+n)

```

# Answer
> 0 votes
# PHP, 164 158 chars/bytes

This is better than the other PHP golf, because:

* It takes inputs
* It's shorter

# Script

```
<?$a=$b='';foreach(str_split(strtolower($argv[1]))as$c){if($c==' ')$c='_';if(preg_match("/[0-9]/",$c))$a.=$c;else$b.=(rand(0,1)?$c:strtoupper($c));}echo$b.$a;

```

# Example

```
php password.php 'thats some 1337 shit'

```

> ThATs\_Some\__sHiT1337

# Answer
> 0 votes
# \>\<\>, 73 bytes

```
 i:"@")?v:" ")?v0) ?\rl?!;o01!.<
 v8<    8>00.! <o"_"/
8<>x<%*4/^o+*
 ^c<

```

Nothing crazy here, it :

* prints `_` when it encounters
* takes the mod 32 of letters, then randomly adds 8\*8 or 12\*8 before printing them
* stacks the number and print them once the end of the input is reached

You can try it here !

# Answer
> 0 votes
# Vyxal `s`, 19 bytes

```
kd$F?kd↔+ð\_Vƛk≈℅ßN

```

Try it Online!

```
  $F                # Filter out
kd                  # Digits
    ?               # Take input
       ↔         # Filter out
     kd             # Non-digits
        +           # Concatenate
         ð\_V       # Replace spaces with underscores
             ƛ      # Map...
              k≈℅ß  # If random bit
                  N # Swap case

```

# Answer
> 0 votes
# PowerShell, 86 bytes

```
-join$(switch -r($args){' '{'_'}'[A-Z]'{"$_"|%('*per','*wer'|random)}\d{$n+="$_"}})+$n

```

Try it online!

# Answer
> 0 votes
# Japt v2.0a0, 16 bytes

```
v rS'_ ñ§9 Ëpu ö

```

Try it

```
v rS'_ ñ§9 Ëpu ö     :Implicit input of string
v                    :Lowercase
  r                  :Replace
   S                 :  Space
    '_               :  with underscore
       ñ             :Sort by
        §9           :  <=9
           Ë         :Map
            p        :  Append
             u       :    Uppercase
               ö     :  Random character

```

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


title: Compute the Fibonacci product

text:
# Question
Title: Compute the Fibonacci product
## Background

We've had challenges before on Fibonacci coding and Zeckendorf representation. These representations follow naturally from Zeckendorf's theorem, which states that every positive integer can be represented uniquely as the sum of one or more distinct, non-consecutive Fibonacci numbers. For example:

$$ \begin{aligned} 64 &= 55 + 8 + 1 \\ &= F\_{10} + F\_6 + F\_2 \\ 171 &= 144 + 21 + 5 + 1 \\ &= F\_{12} + F\_8 + F\_5 + F\_2 \\ \end{aligned} $$

where \\$F\_i\\$ is the \\$i\\$-th Fibonacci number.

## What is Fibonacci multiplication?

Extending this concept, Donald Knuth defined "circle multiplication" (the Fibonacci product) on two postive integers \\$a\\$ and \\$b\\$ as follows. First assume

$$ \begin{align} a &= \sum\_{i=0}^n F\_{c\_i} \text{ where } c\_i \ge 2 \\ b &= \sum\_{i=0}^m F\_{d\_i} \text{ where } d\_i \ge 2 \end{align} $$

Then we define the Fibonacci product like so:

$$ a \circ b = \sum\_{i=0}^n \sum\_{j=0}^m F\_{c\_i + d\_j} $$

See Knuth's original article (pdf) or the Wikipedia entry for more.

Here is a worked example from the Wikipedia page:

$$ \begin{align} 2 &= F\_3 \\ 4 &= F\_4 + F\_2 \\ 2 \circ 4 &= F\_{3 + 4} + F\_{3 + 2} \\ &= F\_7 + F\_5 \\ &= 13 + 5 \\ &= 18 \end{align} $$

As an interesting aside not directly related to the challenge, it has been shown that the Fibonacci product:

> can be interpreted as the usual multiplication in a multiplicatively closed subset of the ring \\$\mathbb{Z}\[\phi\]\\$ of algebraic integers generated by the "golden ratio".

## Task

Given two positive integers as input, return their Fibonacci product as defined in the section above.

This is code-golf and standard site rules apply.

## Test Cases

```
1 1 -> 3
1 2 -> 5
1 5 -> 13
2 1 -> 5
2 4 -> 18
4 1 -> 11
4 4 -> 40
4 9 -> 87
7 1 -> 18
7 2 -> 29
7 9 -> 141
9 9 -> 189

```

# Answer
# Jelly, ~~9~~ 8 bytes

A port of att's answer and -1 byte thanks to them. Takes input as a pair of integers `[a, b]`.

```
‘:ØpḋṚ+P

```

Try it online!

```
‘          increment each value          [a+1, b+1]
 :Øp       integer divide by phi         [(a+1):phi, (b+1):phi]
    ḋṚ     dot product with the reverse  (a+1):phi×b + (b+1):phi×a
       +P  add the product of the input  (a+1):phi×b + (b+1):phi×a + a×b

```
> 10 votes

# Answer
# Wolfram Language (Mathematica), ~~39~~ ~~34~~ 33 bytes

```
1##+{#2,#}.⌊+++{##}2/++√5⌋&

```

Try it online!

Uses the formula in the linked Arnoux paper: \\$m\circ n=m n+p\_m n+m p\_n\\$, where \\$p\_x\\$ is defined as the integer such that \\$p\_x-\frac x\phi\in(\frac1\phi-1,\frac1\phi)\\$. A little bit of manipulation gets us \\$p\_x=\left\lfloor\frac{x+1}\phi\right\rfloor\\$.

```
1##                         m n
   +{#2,#}.                 + (n,m) .
           ⌊+++{##}2/++√5⌋  ⌊(1+(m,n)) / ϕ⌋

```
> 14 votes

# Answer
# Jelly, 18 bytes

```
ŒP‘ÆḞS=ɗƇ¹Ḣ)p/§ÆḞS

```

Try it online!

-1 byte thanks to caird coinheringaahing

---

I have posted a video explanation of this answer and how to approach this problem as well as the mathematical observation below to my YouTube channel. You can see the video here.

---

Assume that there is a sequence of Fibonacci numbers where two are consecutive. Select the largest two such terms and them be \\$F\_n\\$ and \\$F\_{n+1}\\$. Then, \\$F\_{n+2}\\$ cannot be in the sequence because then it would be consecutive with \\$F\_{n+1}\\$ and thus contradict the definition. Therefore, we replace \\$F\_n,F\_{n+1}\\$ with \\$F\_{n+2}\\$ in the sequence and we now have a shorter sequence that sums to the same value.

Keep repeating this process indefinitely, and we can see that the shortest sequence of Fibonacci numbers that sums to \\$N\\$ has to be the unique one containing no consecutive terms, otherwise we can reduce it to something shorter, which would be a contradiction.

Thus, we only need to find the *shortest* sequence. Here follows the explanation of the Jelly code itself:

```
ŒP‘ÆḞS=ɗƇ¹Ḣ)p/§ÆḞS    Main Link; accept a list [x, y]
           )          For each k of x and y
ŒP                    Take the powerset of [1, 2, ..., k], shortest & lexicographically least first
  ‘                   Add one (now we have the powerset of [2, 3, ..., k + 1])
        Ƈ             Filter; keep terms where
   ÆḞ                 Taking the Nth fibonacci number
     S                and summing
      =               is equal to
         ¹            k itself
          Ḣ           And take the first (thus shortest) such subset
            p/        Take the cartesian product of the two codings
              §       Sum each pair
               ÆḞ     Get the Nth fibonacci number for each
                 S    and sum

```
> 5 votes

# Answer
# , 70 bytes

```
+/@,@(1{:@F@++/)&(F i.2-/\[(0>.]-(<:@I.>:){[)^:a:~F=:_2&(],+/@{.)&1 2)

```

Try it online!

* `F=:_2&(],+/@{.)&1 2)` `F_1, F_2 … F_n`.
* `[(0>.]-(<:@I.>:){[)^:a:~` starting with `n`, greedily find the highest Fibonacci number (with binary search with adjusted indices `<:@I.>:`), subtract from `n` and repeat until we hit `0`. Return the intermediate results.
* `F i.2-/\` From the intermediate results get the Fibonacci numbers, and then their indices.
* `…&…` do this for both results, then for both Fibonacci index lists do …
* `1{:@F@++/` addition table, get the last `F_i` for each sum.
* `+/@,@` … and sum it again
> 4 votes

# Answer
# Jelly, 25 bytes

```
¹©R‘U;ṖÆḞS>®Ʋ¡¥ƒ“”)p/§ÆḞS

```

Try it online!

-4 bytes thanks to caird coinheringaahing

Non-brute force answer that should run in \\$O(N^2)\\$ time. Still trying to figure out how to remove the register usage.

Basically, constructs the Fibonacci coding by starting from an upper bound and counting down, adding in the largest Fibonacci number that can fit each time. Since I am summing the accumulating list each time, and I think the output list is roughly \\$O(\log N)\\$ in size, I *believe* this is \\$O(N \log N)\\$, but I'm not sure, so I'll just put down \\$O(N^2)\\$ for now.

```
¹©R‘U;ṖÆḞS>®Ʋ¡¥ƒ“”)p/§ÆḞS        Main Link (monadic): accept [x, y]
                  )              For each k in [x, y]
¹©                               Save it to the register
  R                              Range; [1, 2, ..., k]
   ‘                             Increment; [2, 3, ..., k + 1]
    U                            Reverse; [k + 1, k, ..., 2]
     ;ṖÆḞS>®Ʋ¡¥ƒ“”               Reduce this list starting from []:
     -========¥                  Last two as a dyad:
     ;                           - append the new value to the list
             ¡                   - then, N times (if statement for boolean values)
       ÆḞS>®Ʋ                      - if the sum of those Fibonacci numbers exceeds the desired value
      Ṗ                            - pop the last addition back off
                   p/            Cartesian product of the results
                     §           Sum of each; get the indexes
                      ÆḞ         Convert to Fibonacci numbers
                        S        Sum

```
> 4 votes

# Answer
# Jelly, 22 bytes

```
ŒP‘I’ẠƊƇÆḞS=ɗƇ)p"/§ÆḞ§

```

Try it online!

This feels grossly long.

Returns `[x]` where `x` is the expected output. This is allowed by default

-1 byte thanks to hyper-neutrino

---

## How it works

```
ŒP‘I’ẠƊƇÆḞS=ɗƇ)p"/§ÆḞ§ - Main link. Takes [a, b] on the left
              )        - For each input:
ŒP                     -   Cast to range, then powerset
  ‘                    -   Increment each one
      ƊƇ               -   Keep those for which the following is true:
   I                   -     Forward differences
    ’                  -     Decrement
     Ạ                       Are all non-zero?
                             This removes all lists with any consecutive indices
            ɗƇ         -   Keep those for which the following is true:
        ÆḞ             -     Convert each index to its Fibonacci number
          S=           -     Does the sum equal the input?
               p"/     - Get the Cartesian product of the indices
                          The " (vectorise) quick allows us to avoid extracting the
                          first element, instead we operate with everything
                          wrapped to an additional depth
                  §    - Sums
                   ÆḞ  - Fibonacci number of each
                     § - Sum

```
> 3 votes

# Answer
# JavaScript (ES6),  ~~98~~  90 bytes

A full implementation.

Expects `(a)(b)`.

```
a=>g=(x,k,n)=>(F=n=>n<3||F(n-1)+F(n-2))(-~n)>x?x&&(k?F(k+n):g(a,n))+g(x-F(n),k):g(x,k,-~n)

```

Try it online!

### Commented

The helper function \\$F\\$ just computes the \\$n\\$-th Fibonacci term, 1-indexed.

```
F = n => n < 3 || F(n - 1) + F(n - 2)

```

Main function:

```
a =>               // outer function taking a
g = (              // the inner function g first takes x = b and later
  x,               // invokes itself for the 2nd pass with x = a
  k,               // k is undefined during the 1st pass, then set to
                   // a positive integer
  n                // n is the Fibonacci term index
) =>               //
  F(-~n) > x ?     // if F(n + 1) is greater than x:
    x && (         //   stop if x = 0, otherwise:
      k ?          //     if k is defined:
        F(k + n)   //       compute F(k + n)
      :            //     else:
        g(a, n)    //       process the 2nd pass with x = a and k = n
    ) +            //
    g(x - F(n), k) //   add the result of a recursive call with F(n)
                   //   subtracted from x and k unchanged
  :                // else:
    g(x, k, -~n)   //   try again with n + 1

```

---

# JavaScript (ES7), 42 bytes

Using @att's closed-form formula is, obviously, significantly shorter.

Expects `(a)(b)`.

```
a=>b=>~~(p=.5+5**.5/2,b-~b/p)*a-~~(~a/p)*b

```

Try it online!
> 3 votes

# Answer
# Vyxal `as`, 11 bytes

```
›5√›½ḭṘ*⁰ΠJ

```

Try it Online!

A port of the other ones. No, there isn't a phi builtin.
> 3 votes

# Answer
# Ruby, 56 bytes

```
->a,b{g=->z{(2*z/=1+5**0.5).to_i};a*b+a*g[b+1]+b*g[a+1]}

```

Try it online!

Same formula as almost everybody else.
> 3 votes

# Answer
# Japt, ~~19~~ 18 bytes

Far too long but just can't seem to do any better. There's gotta be a shorter way to get Phi!

```
×+UËÄ z5¬Ä ÑÃx_*Uo

```

Try it
> 2 votes

# Answer
# Retina 0.8.2, 123 bytes

```
.+
$*
(\G1|(?>\2?)(\1))*1
$#1$*01¶
%)+`^(.*).(.*¶)(\1.)¶
$3$2
+`^(0*)1(.*¶¶)(.+)
0$1$2$3¶00$1$3
3A`
0?
;
+`;(1*);1
1;1$1;
1

```

Try it online! Takes newline-separated inputs but link is to test suite that splits on comma for convenience. Explanation:

```
.+
$*
(\G1|(?>\2?)(\1))*1
$#1$*01¶
+`^(.*).(.*¶)(\1.)¶
$3$2

```

Convert the input to its Zeckendorf representation. This is based on my answer to Fibonacci Encoding but without the trailing `1` of course.

```
%)`

```

Apply the above to each input separately.

```
+`^(0*)1(.*¶¶)(.+)
0$1$2$3¶00$1$3
3A`

```

Long multiply the two inputs. (The final addition is implicitly accomplished after the conversion back to decimal.) Additionally, since the Zeckendorf representation starts at F₂, prefix an additional two zeros to adjust for the 2-indexing.

```
0?
;
+`;(1*);1
1;1$1;

```

Convert each Zeckendorf representation back to unary. This is based on my answer to Converting a number from Zeckendorf Representation to Decimal.

```
1

```

Sum the unary values and convert to decimal.
> 2 votes

# Answer
# C (gcc), ~~77~~ ~~62~~ 53 bytes

```
g(m){m=~m*(1-sqrt(5))/2;}f(m,n){m=m*n+g(m)*n+g(n)*m;}

```

Try it online!

-15 bytes thanks to ovs
-9 bytes thanks to att

Original submission:

```
#define X(m,n) +(int)((m+1)*2/(sqrt(5)+1))*n
f(m,n){return m*n X(m,n)X(n,m);}

```

Basically an adaptation of att's excellent answer.

Thanks to the power of ~~the preprocessor~~ *undefined behavior* this is way shorter than an equivalent Java version I tried.
> 1 votes

# Answer
# Python 2, ~~68~~ *61* bytes

-7 bytes thanks to ovs, and based on att's answer:

```
def f(x,y):p=lambda a:~a*(1-5**.5)//2;print x*y+x*p(x)+y*p(y)

```

Try it online!

As my first golfing experience with python, there might be room for improvement. Suggestions are welcome.
> 0 votes

# Answer
# MathGolf, 16 bytes

```
ê)φ/iêx^~êßmÅε*Σ

```

MathGolf has a builtin for the golden ratio / phi, but unfortunately it's not too good at taking the product of inner lists..

Try it online.

**Explanation:**

```
ê                # Push the input as integer-array: [a,b]
 )               # Increase both values by 1: [a+1,b+1]
  φ/             # Divide both by phi: [(a+1)/phi,(b+1)/phi]
    i            # Floor the decimals to an integer: [(a+1)//phi,(b+1)//phi]
     êx          # Push the input-array again, and reverse it: [b,a]
       ^         # Zip the two lists together: [[(a+1)//phi,b],[(b+1)//phi,a]]
                 # Append the input-pair to this list, by:
        ~        #  Dumping both pairs onto the stack
         ê       #  Push the input-array again
          ß      #  Wrap all three pairs into a list: [[(a+1)//phi,b],[(b+1)//phi,a],[a,b]]
           m     # Map over the inner lists,
            Å    # using the following two characters as inner code-block:
             ε*  #  Take the product of this inner pair: [(a+1)//phi*b,(b+1)//phi*a,a*b]
               Σ # Sum all three values together: (a+1)//phi*b+(b+1)//phi*a+a*b
                 # (after which the entire stack is output implicitly as result)

```
> 0 votes

---
Tags: code-golf, fibonacci
---


title: Shortest Code to Legitimately Slack Off

text:
# Question
Title: Shortest Code to Legitimately Slack Off
I'm a developer, and I don't feel like doing my work. I know from XKCD that the best excuse for slacking off is that your code's compiling. Because of this, I think I need some code that will *compile forever!* And because I'm lazy and don't want to have to type much, this has to be done with the shortest code possible.

So, your task is to write a program that is syntactically valid, but will cause the compiler to enter an infinite loop.

## Specifications

* You must use a language that has a compiler, obviously.
* Specify the implementation used in each solution.
* This is , so the shortest valid solution (in bytes) wins.
* The compiler can terminate from running out of memory or stack space.

# Answer
# Japt, 2 bytes

```
`ÿ

```

You can test this online here, but I wouldn't recommend it as it will freeze your browser.

### Explanation

Japt uses the shoco library for compressing strings. A backtick tells the compiler to decompress everything until the next backtick or the end of the file. Each byte does the following:

* `00-7F` are left intact.
* `80-BF` each transform into a common lowercase two-letter pair (`at`, `oo`, `th`, etc.).
* `C0-DF` each consume the next byte and transform into a common four-letter string.
* `E0-EF` each consume the next *three* bytes and transform into a "common" eight-letter string (starting at `Whererer` and going downhill from there).
* `F0-F7` break the decompressor, though it still returns everything up to the breaking byte.
* `F8-FF` cause the decompressor to enter into an infinite loop. I'm not sure why this is, as I'm not very familiar with the inner workings of the shoco library (and the JavaScript code is completely unreadable), but it's quite handy in this case.

I don't believe there is any other way to mess with the Japt compiler, but you never know...
> 17 votes

# Answer
# TikZ (pdfTeX 3.14159265-2.6-1.40.17), ~~85~~ ~~79~~ ~~74~~ ~~24~~ ~~22~~ 21 bytes

*A bunch of bytes saved thanks to wchargin*

*One byte saved thanks to Chris H*

```
\input tikz
\tikz\pic

```

I actually encountered this one by accident when I was working on homework. I spent quite a while waiting for it to compile before I realized what was happening.

This has two parts:

```
\input tikz

```

This loads the TikZ package

and:

```
\tikz\pic

```

This starts a `\tikz` environment and a draw command.

## What is going on

The pdflatex compiler has trouble with `\tikz\pic`, and enters interactive mode causing it to stall indefinitely.
> 58 votes

# Answer
# Java, ~~102~~ ~~95~~ ~~89~~ ~~88~~ 78 bytes

```
class A<T>{}class B<T>extends A<A<?super B<B<T>>>>{A<?super B<A>>a=new B<>();}

```

This terminates with a `StackOverflowError` which happens because the generic resolution system can't decide a root against which to resolve the other generics.

Credits where due.

## What happens here?

1. `A<T>` is just there to have a 1-letter parent. It's generic. I could have used `List`, but the imports and repetition of 4 letters are too long.
2. `B<T>` declares a basic generic.
3. `B extends A` is required to have a hierarchy between `B` and `A`.
4. `extends A<A>` creates a self reference on `A<T>`.
5. `A<? super B>` triggers the lookup for generics on `A<T>`
6. `B<B<T>>` creates a self-reference on `B<T>`.
7. `A<...> a=new B<>()` forces the usage of the generics, instead of simply the definition of those, forcing the resolution when compiling `B`, and not afterwards.
8. `A<?super B` creates a non-self-reference, so we have both a reference to one type and to another in the generics of `A`.
9. `B<A>` creates a non-self-reference, so we have both a reference to one type and to another in the generics of `B`.

Now, the type `A` has generics type `A` and `B`, but which is to be chosen? Forget about self, let's try to resolve `B`. Ping.

Okay, `B` has generics type `A` and `B`, but which is to be chosen? Forget about self, let's try to resolve `A`. Pong.

This kind of recursion can't really be avoided because there are legitimate cases like `A<B<A<B<A<B<Object>>>>>>`: for example a JSON object: `List<Map<String,Map<String,List<Map<String,List<String>>>>>>`.

## Compilation result

```
$ javac NoCompile.java

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2587)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)
        at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types.java:3260)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2592)
        at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579)
        at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554)

```

On my system, the stack trace stops after showing 1024 lines, which are actually the 4 same lines repeated 256 times, thus proving an infinite recursion. I'll spare you that whole trace.

## Savings

1. 102 → 95 bytes: replaced `interface`+`implements` with `class`+`extends`.
2. 95 → 89 bytes: replaced `Long` with `A` (twice).
3. 89 → 88 bytes: used diamond operator (`new B()``new B<>()`) .
4. 88 → 78 bytes: moved the variable declaration to a class member, thanks to VoteToClose.
> 44 votes

# Answer
## C, 18 bytes

```
#include __FILE__

```

Compilers will usually give up after recursing about 200 times.

Does DOM construction count as a compilation step? If so, then `x.htm`:

```
<iframe src=x.htm>

```
> 42 votes

# Answer
## GNU Makefile, ~~8~~ 7 bytes

*One byte saved thanks to KonradRudolph*

Saved as `Makefile` and invoked by `make`:

```
x:;make

```

This will produce an infinite build recursion on the first target found `"x"`.

Needless to say that you don't *really* want to run this fork bomb on your production server. :-)

```
make
make[1]: Entering directory `/path/to/my/dir'
make
make[2]: Entering directory `/path/to/my/dir'
make
make[3]: Entering directory `/path/to/my/dir'
make
make[4]: Entering directory `/path/to/my/dir'
make
make[5]: Entering directory `/path/to/my/dir'
make
make[6]: Entering directory `/path/to/my/dir'
make
make[7]: Entering directory `/path/to/my/dir'
make
...

```

### Alternate version, 5 bytes

Suggested by KonradRudolph:

```
x:;$_

```

`$_` is a reference to the last argument of the previous command. More specifically, it is resolved here as the absolute path to the command being executed -- which is `make` itself.

This should work fine in a genuine Bash environment, but not on Windows+MinGW.
> 35 votes

# Answer
# Perl, ~~15~~ 13 bytes

```
BEGIN{{redo}}

```

Try it online!

Now with 2 bytes saved: @Zaid reminded me of a terser way to do a loop in Perl.

This is pretty simple: it just installs a parser hook with an infinite loop in, making the code take infinitely long to parse. (Perl's nice in that it allows you to run arbitrary code in the middle of the parse; the parser hooks are specified in Perl itself, and frequently used to do things like import libraries or change the parsing rules for an identifier you want to treat like a keyword.) The Try it online! link above gives the `-c` option (to compile the code to verify the syntax for correctness, but not run it), to prove that the infinite loop happens at compile time.

In case you're wondering about "compile time" in a scripting language: Perl actually compiles to bytecode and then runs the bytecode, but this is a detail that's rarely relevant when programming it. The `-MO=` command line option family can be used to do things with the bytecode other than running it (although not with this program, as the infinite loop happens before the bytecode can be generated).
> 24 votes

# Answer
# C++, 60 58

```
template<class T>class a{a<T*>operator->();};a<int>i=i->b;

```

This recursivly creates instances of `class a` with different template parameters. GCC 7.0 stops after 900 recursion levels with tons of errors about `operator->` being private but for example ICC 17 and Microsoft (R) C/C++ Optimizing Compiler 19 time out on godbolt.

Problem with that is that probably all compilers will run out of memory at some point in time so even without recursion limits this will stop. The same probably applies to the Clojure answer, too.

Edit: 2 bytes saved by bolov - Thanks
> 23 votes

# Answer
# C++, ~~37~~ ~~30~~ 29 bytes

```
int f(auto p){f(&p);},a=f(0);

```

It uses the future auto function parameter. It was proposed into C++17, but I don't think it made it. `gcc` however supports it as an extension.

Basically

```
void foo(auto p);

```

is equivalent to

```
template <class T>
void foo(T p);

```

The code tries to instantiate `f` recursively with different template arguments. `gcc` fails with

> fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)

With `-ftemplate-depth=10000` I got it to spit "Killed - processing time exceeded" on godbolt.

Check it on godbolt

---

1 byte saved by Quentin. Thank you.
> 20 votes

# Answer
## Common Lisp, 8 bytes

```
#.(loop)

```

The compiler will try to read a form and will encounter the sharpsign-dot reader macro, which evaluates code at *read time* and uses its result as the form to compile. Here, the code being executed is an infinite loop.
> 18 votes

# Answer
## TeX, 9 bytes

```
\def~{~}~

```

TeX works by expanding macros. Most of the time, TeX's macros (also called *control sequences*) are of the form `\name` but it is also possible to define certain characters as macros, these are called *active characters*. The character `~` is active by default in plain TeX and so can be used as a macro name without further declaration. The `\def~{~}` in the above defines `~` so that it expands to `~`. That is, whenever TeX encounters `~` then it replaces it by `~` and then re-examines the replacement, meaning that it encounters a wholly new occurrence of `~` and replaces that by `~`. This defines the infinite loop. All that is then needed is to start the loop and that's what the final `~` does.

---

*Added in edit*

To make this properly *compiled*, invoke as:

```
pdftex -ini "&pdftex \def~{~}~"

```

The `-ini` flag says that `pdftex` should *compile* a new format file. This is a precompiled set of definitions which can be loaded when TeX is later invoked to speed up processing a document (LaTeX2e is an example of this). I guess that the `&pdftex` adds a few bytes, taking the total to 17.
> 17 votes

# Answer
## Haskell, 25+17=42 bytes

```
a= $(let a='a':a in[|a|])

```

A simple Haskell metaprogram which defines an infinite value and attempts to compute that value at compile time.

Invoke with `ghc -XTemplateHaskell <file.hs>` (+17 for the parameter to the compiler)
> 14 votes

# Answer
# gradle, 10 9 bytes

```
for(;;){}

```

with the above code placed in a `build.gradle` file. Gradle uses groovy as its base language so we are really talking about groovy here, but as the question was about build time I figured gradle would be more appropriate.

Running any gradle build commands with the above code prints the pointy-haired-boss-compatible build status line:

```
$ gradle tasks
> Configuring > 0/1 projects > root project

```

if you are aiming for a raise, add the debug `-d` flag for:

```
$ gradle -d tasks
14:56:25.522 [INFO] [org.gradle.internal.nativeintegration.services.NativeServices] Initialized native services in: .gradle/native
14:56:25.757 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Executing build 84908c0d-f28d-4c57-be61-40eaf0025e16.1 in daemon client {pid=27884}
14:56:25.761 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface tun0
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.762 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%tun0
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a loopback interface? false
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Is this a multicast interface? true
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x:x:x:x:x:x:%eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote address /x.x.x.x
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding remote multicast interface eth1
14:56:25.764 [DEBUG] [org.gradle.internal.remote.internal.inet.InetAddresses] Adding IP addresses for network interface lo
<snip>
14:57:07.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
14:57:07.056 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
> Configuring > 0/1 projects > root project

```

which in addition to looking impressively complicated also updates with a new set of:

```
15:07:57.054 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] DaemonExpirationPeriodicCheck running
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.054 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
15:07:57.055 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.

```

status lines every 10 seconds making it look like the build is busy doing important technical...stuff.
> 14 votes

# Answer
# SWI-Prolog, 34 bytes

```
term_expansion(_,_):-repeat,1=0.

```

### Explanation

`term_expansion/2` is something that gets called automatically by the compiler before actually compiling code to transform some terms in the source code into other terms.

Here, we introduce a new rule for `term_expansion/2`: `repeat,1=0.`.

`repeat/0` is a predicate which always succeeds, and provides an infinite number of choice points.

`1=0` is trying to unify `1` with `0`, which is always `false`. This will cause the compiler to backtrack to `repeat` (since it always provides a choice point) and try `1=0` again, etc.
> 9 votes

# Answer
# GNU Make, 44

```
.PHONY:x
$(MAKEFILE_LIST):x;sleep 1;touch $@

```

I can't claim credit for this. It is derived from Robert Mecklenburg's book *Managing Projects with GNU Make: The Power of GNU Make for Building Anything*.

> When make executes this makefile, it sees the makefile is out of date (because the .PHONY target is out of date, so it executes the touch command, which updates the timestamp of the makefile. Then make re-reads the file and discovers the makefile is out of date.... Well you get the idea.

I prefer this to the other Make answer because it does not use recursion. On my VM, the other Make answer continues forking processes and at somewhere around 7,000 deep, the VM grinds to an unresponsive halt. However, with this answer it is able to continue indefinitely without eating up system resources. You really will be able to slack off with this build. I've gone over 1,000,000 iterations with no apparent system degradation.

Note I had to add the `sleep 1` so that the makefile timestamp is actually updated every time. You can change this to `sleep 0.01` if you want it to burn through iterations a bit faster.
> 8 votes

# Answer
# GNU Forth, 15 bytes

**Golfed**

```
: : [do] [loop]

```

Re-defines (re-compiles) the word `:` and invokes an immediate infinite loop `[do] [loop]` inside the new definition (right at the compile time).

> One category of words don't get compiled. These so-called immediate words get executed (performed now) regardless of whether the text interpreter is interpreting or compiling.

Try It Online !
> 7 votes

# Answer
# C, 31 bytes (16 + 15 for `-mcmodel=medium`)

```
main[-1llu]={1};

```

Inspired by Digital Trauma. Compile with the `-mcmodel=medium` flag.

Good luck compiling this, you'll need 1.8 yottabytes of RAM and disk space.
> 6 votes

# Answer
# Clojure, 21 bytes

```
(defmacro a[]`(a))(a)

```

Ties up the compiler by defining a macro that repeatedly emits calls to itself.

On my phone, this causes the REPL to hang and lag the device. On my laptop, this fails outright with a StackOverflow.

Unfortunately the StackOverflow happens instantly, but it's still valid according to the rules.
> 5 votes

# Answer
# MSBuild, 130 bytes

```
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="X">
        <Exec Command="msbuild"/>
    </Target>
</Project>

```

Save this as a file with `.proj` extension, and run with `msbuild` from the command prompt. MSBuild will run its only target which simply spawns another `msbuild` process.
> 5 votes

# Answer
## Haskell (GHC, *without* Template Haskell or custom rewrite rules), 138

```
{-#LANGUAGE FlexibleContexts,UndecidableInstances#-}
data A x=A
class C y where y::y
instance C(A(A x))=>C(A x)where y=A
main|A<-y=pure()

```

Theoretically, this enters an infinite loop in much the same way the C++ approach does: the polymorphic method `y` is instantiated to ever more convoluted types. In practice, the default allotted stack size actually overflows quickly:

```
$ ghc-7.10 wtmpf-file14146.hs
[1 of 1] Compiling Main             ( wtmpf-file14146.hs, wtmpf-file14146.o )

wtmpf-file14146.hs:5:9:
    Context reduction stack overflow; size = 101
    Use -fcontext-stack=N to increase stack size to N
      C (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A (A t0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    In a stmt of a pattern guard for
                   an equation for ‘main’:
      A <- y
    In an equation for ‘main’: main | A <- y = pure ()

```

Credits to Luke Palmer.
> 5 votes

# Answer
## Mathematica 33 Bytes

```
Compile[{},Evaluate@While[True,]]

```

The code will attempt to symbolically evaluate the argument prior to compilation, and the argument itself is an infinite loop. The While function has a null second argument since it's not important.
> 4 votes

# Answer
# Haskell (ghc), 32 + 2 = 34 bytes

```
{-#RULES""main=main#-}
main=main

```

run with `ghc -O <file>`. Triggers a rewrite rule for the main function which rewrites to the same thing. The only unfortunate feature is that ghc is smart enough to detect this and stop after 100 iterations. I don't know of an easy way to disable this behavior.
> 2 votes

# Answer
## Rust, 18 bytes

```
include!(file!());

```

Classic self-include. Rustc is annoyingly sane though, and by default will bail out after 128 recursions, and it expands depth-first so exponential growth doesn't work either. The same applies to the C and C++ solutions though.
> 2 votes

# Answer
# Factor, ~~29~~ 16

```
<< [ t ] loop >>

```

The part between `<<` `>>` is executed at parse time.

As for what `[ t ] loop` does, I'll let you guess...

You can put that in the Listener as is, or add it to any vocabulary or script file with the corresponding boilerplate stuff.
> 1 votes

# Answer
# Boo, 25 bytes

```
macro l:
 x=0 while 1>0
l

```

This defines a macro, which executes at compile time, which executes an infinite loop, and then invokes the macro.
> 1 votes

# Answer
# PHP, 19 bytes

```
<?include __FILE__;

```
> 1 votes

# Answer
# Nim, 25 bytes

```
static:
 while 0<1:echo 2

```

Try it online!

Compile with `--maxLoopIterationsVM:10000000000000000`. The compiler on TIO is old and doesn't support this flag.
> 1 votes

# Answer
# Julia 1.0, 16 bytes

```
@generated !x=!x

```

not a full program but a function, since Julia compiles functions the first time they are called

I'm pretty sure that's a compile-time infinite loop, since `@code_llvm` (which only compiles the function whithout executing it) also loops forever

Try it online!
> 1 votes

# Answer
# Scala 3, 47 bytes

```
type T[X]=X match{case 1=>T[X]}
val x:T[1]= ???

```

Try it in Scastie!

Terminates saying "Recursion limit exceeded."
> 0 votes

---
Tags: code-golf, compile-time
---