title: The Speed of Letters

text:
# Question
Title: The Speed of Letters
Given a string as input, print a new string with each letter pushed to the right by its respective alphabet index.

We all know that A is a slow and Z is a fast letter. This means that Z gets shifted to the right by 25 spaces, A doesn't get shifted at all and B gets shifted by 1 space.

Your program only has to handle uppercase letters from A-Z, and no other characters, no whitespaces, no punctuation.

Note that if 2 or more letters fall onto the same space after shifting, the latest character will be used. (Example: `BA` -\> `A`)

## Examples

```
"AZ" -> "A                         Z"

"ABC" -> "A B C"

"ACE" -> "A  C  E"

"CBA" -> "  A"

"HELLOWORLD" -> "     E H    DLL   OLO   R  W"

```

## Rules

* This is , so the shortest code in any language bytes wins.
* Standard loopholes are forbidden.
* Input must be received as a string.
* You may print the result to `stdout` or return a string.
* A *single* trailing whitespace and/or newline is allowed.
* You may also use lowercase letters as input or output, but only use either case.

# Answer
> 13 votes
# Python 2, 81 bytes

```
t=[]
i=65
for c in input():t+=[' ']*26;t[ord(c)-i]=c;i-=1
print`t`[2::5].rstrip()

```

Try it online!

# Answer
> 11 votes
# MATL, 11 bytes

```
''jtfy65-+(

```

Try it online! Or verify all test cases.

### Explanation

MATL indexing is 1-based. This golfing trick is used here. This other one cannot be used because we need an empty string, not an empty numeric array.

Consider input `'ACE'` as an example. Stack contents are shown bottom to top.

```
''     % Push empty string
       %   Stack: ''
j      % Input string
       %   Stack: '', 'ACE'
t      % Duplicate
       %   Stack: '', 'ACE', 'ACE'
f      % Indices of nonzero entries. Gives [1 2 ... n] where n is input length
       %   Stack: '', 'ACE', [1 2 3]
y      % Duplicate from below
       %   Stack: '', 'ACE', [1 2 3], 'ACE'
65     % Push 65
       %   Stack: '', 'ACE', [1 2 3], 'ACE', 65
-      % Subtract, element-wise. Characters are converted to codepoints
       %   Stack: '', 'ACE', [1 2 3], [0 2 4]
+      % Add, element-wise
       %   Stack: '', 'ACE', [1 4 7]
(      % Fill string '' with values 'ACE' at positions [1 4 7]. The original
       % empty string is extended. Non-existing values are filled with char 0,
       % which is displayed as space. Implicitly display
       %   Stack: 'A  C  E'

```

# Answer
> 7 votes
# , ~~140~~ ~~133~~ ~~129~~ 74 bytes

Saved a ton of bytes porting an ASCII value approach like everyone else. Sad I didn't think of it before :(

```
function(s){F[X-65+1:sum(X|1)]=X=utf8ToInt(s)
F[is.na(F)]=32
intToUtf8(F)}

```

Try it online!

### original answer, 129 bytes:

```
function(s){o=rep(' ',(n=nchar(s))+25)
for(i in 1:n){k=substr(s,i,i)
o[x<-i+match(k,LETTERS)-1]=k
F=max(F,x)}
cat(o[1:F],sep='')}

```

Try it online!

generates a too-long list `o` of spaces, then iterates through `s`, replacing the values in `o` with the correct value and updating `F`, the position of the rightmost character. Then prints out the first `F` elements of `o` with no separators between them.

# Answer
> 6 votes
# 05AB1E, ~~20~~ 16 bytes

-4 bytes thanks to Emigna

```
ð₄×svyAuykN+ǝ}ðÜ

```

Try it online!

# Answer
> 6 votes
# JavaScript (ES6), 81 bytes

```
s=>[...s].map((c,i)=>a[i+parseInt(c,36)-10]=c,a=[])&&[...a].map(c=>c||" ").join``

```

Somewhat builds off of Rick Hitchcock's incomplete answer but ended up rather different.

Places the characters into their respective index of an empty array, then uses array spread (`[...a]`) to turn the missing elements into `undefined`, allowing `map` to replace empty elements with a space.

## Test Cases

```
let f=
s=>[...s].map((c,i)=>a[i+parseInt(c,36)-10]=c,a=[])&&[...a].map(c=>c||" ").join``

;["AZ", "ABC", "ACE", "CBA", "HELLOWORLD"]
.forEach(t=>console.log(`"${t}"`, "=>", `"${f(t)}"`))
```

# Answer
> 5 votes
## Perl 5, 42 bytes

**41 bytes code + 1 for `-p`. The `\x1b`s in the code are literal escape characters.**

Relies on ANSI escape sequences to position the cursor and therefore doesn't work on TIO.

```
s/./($-=-65+ord$&)?"\x1b[$-C$&\x1b[--$-D":$&/ge

```

### Usage

```
perl -pe 's/./($-=-65+ord$&)?"\x1b[$-C$&\x1b[--$-D":$&/ge' <<< 'HELLOWORLD'
     E H    DLL   OLO   R  W

```

# Answer
> 5 votes
# Java (OpenJDK 8), ~~207~~ ~~191~~ ~~189~~ ~~183~~ ~~178~~ ~~174~~ ~~173~~ 170 bytes

```
s->{char i=0,l,c[]=new char[s.chars().map(j->j+s.lastIndexOf(j)).max().getAsInt()-64];for(;i<s.length();c[i+l-66]=l)l=s.charAt(i++);return"".valueOf(c).replace('',' ');}

```

Try it online!

# Answer
> 4 votes
# Perl 5, 41 + (`-F`) = 43 bytes

```
map$r[$i++-65+ord]=$_,@F;print$_||$"for@r

```

Try it online!

Just for @lynn

# Answer
> 4 votes
# brainfuck, 127 bytes

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

```

Try it online!

### Explanation

```
,[                    Take input and start main loop
  [-<+<+>>]             Make two copies of input byte
  ----[----<<->>]<<-    Subtract 64 from one of them to get position in alphabet

                        There are two zero cells between the input and the
                        remaining output cells; we wish to move these zeroes
                        to indicate where the letter is to be moved

  [                     A number of times equal to the position in the alphabet:
    [>]                   Go to current position in output string
    >++++>                Create 4 (as part of creating a space if needed)
    [-<[-]<+>>]           Move output byte back two cells; zero the previous 4 if output existed
    <[-<++++++++>]        Otherwise move a space (32) into that position
    <[<]>-                Move back to counter and decrement
  ]
  >[>]<[-]              Delete last moved byte to make room for input byte
  +[<]>-                Initialize slot at 1 so it is always nonzero in this loop
  [[>]<+[<]>-]          Move input byte into slot
  >.[-]                 Output next output byte and clear
  >[>]<                 Move to space vacated in preparation to remove gap
                        (Moves to end instead if input was A; this causes no problems)
  [[->>+<<]<]           Move values two cells right until zero reached
  >,                    Get into position and take another byte of input
]
>>[.>]                Output characters beyond end of input

```

# Answer
> 3 votes
# Proton, 78 bytes

```
x=>{t=[' ']*26*(q=len(x))for i:0..q{t[i+ord(k=x[i])-65]=k}"".join(t).rstrip()}

```

Try it online!

69 bytes by porting Lynn's solution: `x=>{t=[]i=65for k:x{t+=[' ']*26t[ord(k)-i]=k;i--}"".join(t).rstrip()}`

# Answer
> 3 votes
# Jelly, 20 bytes

```
ØAiÐ€+JṬ€a"⁸Zḟ€0Ṫ€o⁶

```

Try it online!

# Answer
> 3 votes
# Haskell, ~~90~~ 88 bytes

```
d=drop 1
[a]#s|s<"A"=a:d s|0<1=s
b#s=(s++" ")!!0:d b#d s
f(c:t)=['A'..c]#(' ':f t)
f s=s

```

Try it online!

# Answer
> 2 votes
# Japt, 23 bytes

```
;iB ç
Ng £=hX10nY+XnG
U

```

Test it online!

First attempt, may be improvable...

# Answer
> 2 votes
# J, ~~37~~ 31 bytes

~~`[`]`(' '#~(1+>./)@])}(i.@#+65-~a.&i.)`~~

```
[`]`(' '#~(1+>./)@])}#\-66-3&u:

```

-6 bytes thanks to FrownyFrog

### explanation

The entire thing is a hook:

```
[`]`(' '#~(1+>./)@])}  #\-66-3&u:

```

The right side calculates the new indexes for all the letters.

The left side uses the gerund form of Amend `}` first to create a string of the necessary number of spaces: `(' '#~(1+>./)@])` . And then to place each letter of the original string into its appropriate index within the all-space string.

Try it online!

# Answer
> 2 votes
# Wolfram Language (Mathematica), 76 bytes

```
SparseArray[Reverse@MapIndexed[#&@@#2+LetterNumber@#-1->#&,#]]<>""/. 0->" "&

```

Takes a list of characters as input. This generates some error messages that are safe to ignore.

I included `Print` and `Character` command in the footer of the TIO link for ease of use. (`Character` command simply converts a string to a list of characters)

Try it online!

# Answer
> 2 votes
# Haskell, 88 bytes

```
foldr(\c->(((['B'..c]>>" ")++[c])#).(' ':))[]
(x:r)#(y:t)|y>' '=y:r#t|1<3=x:r#t
r#t=r++t

```

Try it online!

# Answer
> 2 votes
# C# (.NET Core), ~~117~~ ~~110~~ 84 bytes

Saved 7 bytes thanks to **Ayb4tu**.

Changed return type from `string` to `char[]` to save 26 bytes.

```
n=>{int i=0,l=n.Length;var t=new char[l+26];for(;i<l;)t[i+n[i]-65]=n[i++];return t;}

```

Try it online!

# Answer
> 2 votes
## Haskell, 88 bytes

```
f s|q<-zipWith((+).fromEnum)s[0..]=[last$' ':[c|(c,i)<-zip s q,i==p]|p<-[65..maximum q]]

```

Try it online!

`q` is the list of the final indices of the letters of the input string (with an offset of `65`). Loop through all indices (starting at `65`) and find all letters for it, prepending a space. Take the last.

# Answer
> 2 votes
# Kotlin, ~~207 bytes~~ ~~189 bytes~~ ~~187 bytes~~ 177 bytes

```
fun main(){val i=(readLine()+" ".repeat(26)).toCharArray();for(x in(i.size-1) downTo 0){if(i[x]!=' '){i[x+i[x].toInt()-65]=i[x];i[x]=' '}};print(i.joinToString("").trim())}

```

If the leading blank should remain I would just call `trimEnd()` instead of `trim()`.

**Unminified:**

```
fun main() {
    val m = (readLine() + " ".repeat(26)).toCharArray()
    for (x in (m.size - 1) downTo 0) {
        if(m[x] != ' ') {
            m[x + m[x].toInt() - 65] = m[x]
            m[x] = ' '
        }
    }

    print(m.joinToString("").trim())
}

```

---

Maybe Kotlin is not the best language for code golfing but I liked the challenge and I wanted to make myself more familiar with Kotlin's standard library.

# Answer
> 2 votes
# **C# .NET, ~~89 Bytes~~ 87 Bytes**

-2 bytes thanks to Lan H.

```
f=>{var s=new char[f.Length+26];for(int i=0;i<f.Length;i++)s[f[i]+i-65]=f[i];return s;}

```

Try it Online!

# Answer
> 1 votes
# q/kdb+, 37 bytes

**Solution:**

```
@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:

```

**Examples:**

```
q)@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:"AZ"
"A                         Z"
q)@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:"ABC"
"A B C"
q)@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:"ACE"
"A  C  E"
q)@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:"CBA"
"  A"
q)@[max[1+m]#" ";m:!:[x#:]+.Q.A?x;:;]x:"HELLOWORLD"
"     E H    DLL   OLO   R  W"

```

**Explanation:**

I think this is the same idea as the J solution, calculate the correct indices for the input array and then assign them to an empty string of correct length:

```
@[max[1+m]#" ";m:til[count x]+.Q.A?x;:;]x: / ungolfed solution
                                        x: / save input as x
@[            ;                     ; ;]   / apply[variable;indices;function;parameters]
                                     :     / assignment
                              .Q.A?x       / location of x in uppercase alphabet
                             +             / added to
                     count x               / length of input
                 til[       ]              / range, 0..n
               m:                          / save as m
  max[   ]                                 / maximum of list
      1+m                                  / m + 1
          #" "                             / take " ", creates empty character list

```

# Answer
> 1 votes
# Jq 1.5, 91 bytes

```
reduce(explode|[.,keys]|transpose[]|.[1]+=.[0]-65)as[$c,$p]([];.[$p]=$c)|map(.//32)|implode

```

Expanded

```
  reduce(  explode         # convert string to array of ordinals
         | [.,keys]        # [ [v0,v1,...], [0,1,2,...] ]
         | transpose[]     # [ [v0,0], [v1,1], [v2,2]...]
         | .[1]+=.[0]-65   # adjust position of each value
  ) as[$c,$p] (
    []
  ; .[$p]=$c               # store each value at its position
  )
| map(.//32)               # map null values to spaces
| implode                  # convert back to string

```

Try it online!

# Answer
> 1 votes
# Charcoal, 16 bytes

```
Ｐ ＦＳ«Ｍ⌕αι→ιＭ⌕αι←

```

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

```
Ｐ                   Output a space to force the indent
   Ｓ                Input string
  Ｆ «               Loop over each letter
       α            Uppercase letters predefined variable
      ⌕ ι           Find index of current letter
     Ｍ   →          Move that many characters right
          ι         Implicitly print the current letter
           Ｍ⌕αι←    Move the same number of characters left

```

# Answer
> 1 votes
# APL (Dyalog), 26 bytes

Anonymous prefix lambda which takes the input string as argument and returns the output string. Assumes `⎕IO` (**I**ndex **O**rigin) `0`, which is default on many systems.

```
{⍵@i⊢''↑⍨1+⌈/i←(⎕A⍳⍵)+⍳≢⍵}

```

Try it online!

`{``}` anonymous lambda;  represents the argument

`≢⍵` tally of the argument

than many **ɩ**ntegers (0…LengthOfArgument-1)

`(``)+` plus:

`⎕A⍳⍵` the indices of the argument in the uppercase **A**lphabet

`i←` strore in `i` (for **i**ndices)

`⌈/` maximum (reduction)

`1+` add one

`''↑⍨` take that many characters from the empty string, padding with spaces as needed

yield that (serves to separate `i` from `''`)

`⍵@i` amend that with the argument letters **at** the `i` indices

# Answer
> 1 votes
# SOGL V0.12, 10 bytes

```
ā,{ZFWē+1ž

```

Try it Here!

Explanation:

```
ā           push an empty array
 ,{         for each char in the input
   ZFW        get its index in the uppercase alphabet
      ē+      add to that the 0-indexed counter
        1ž    at [pop; 1] insert in the array the current character

```

# Answer
> 1 votes
# Pyth, ~~44~~ 38 bytes

Striked out 44 is still 44 :(

Bloody Pyth beginner.

Saved 6 bytes thanks to @Mr. Xcoder.

```
K*d+lz26Vlz K=XK-C@zN-65N@zN;.WqeHdPZK

```

Try it online!

---

**How?**

```
K*d+lz26Vlz K=XK-C@zN-65N@zN;.WqeHdPZK          Full program

K*d+lz26                                        Assign a string consisting of
                                                  (26 + input.length) whitespaces to K
        Vlz                                     For-loop from 0 to input.length
                -C@zN-65N                       Calculate the index for the current letter
                         @zN                    The current letter
            K=XK                                Insert the current letter into K at
                                                  position i
                            ;                   End statement
                             .WqeHdPZK          While the last character of H is not a
                                                  whitespace, pop the last character off K

```

# Answer
> 1 votes
# Batch, ~~418~~ 331 bytes

Works with uppercase letters only and will take some seconds for longer strings.

Learned new tricks here, the character to ASCII value conversion using `%=exitcodeAscii%`. Also, `if defined` and "array" access using `call`. Also, golfing by almost 100 bytes was good batch code golf training.

Note the trailing space in `set z=set`.

```
@echo off
setlocal EnableDelayedExpansion
set z=set
%z%a=%1
:a
%z%v=64
:b
%z%/Av+=1
cmd/Cexit %v%
if %=exitcodeAscii% neq %a:~0,1% goto b
%z%/Ao=v+c
%z%a%o%=%a:~0,1%
if %o%. geq %m%. %z%m=%o%
%z%/Ac+=1
%z%a=%a:~1%
if %a%. neq . goto a
for /l %%n in (65,1,%m%)do (
if defined a%%n (call %z%r=%%r%%%%a%%n%%
)else %z%r=!r! )
echo %r%

```

# Answer
> 1 votes
# Ruby, 68 bytes

```
->s{r,w="",-66;s.bytes{|b|r[(b+w+=1).times{|a|r[a]||=" "}]=b.chr};r}

```

Try it online!

# Answer
> 1 votes
# x86-16 machine code, PC DOS, 27 bytes

```
00000000: b403 cd10 d1ee ad98 91ac b402 8ad0 80ea  ................
00000010: 4102 d343 cd10 cd29 e2ef c3              A..C...)...

```

**Listing:**

```
B4 03       MOV  AH, 3          ; get current cursor position row into DH
CD 10       INT  10H            ; call BIOS
D1 EE       SHR  SI, 1          ; SI to DOS PSP
AD          LODSW               ; AL = command line string length
98          CBW                 ; AH = 0
91          XCHG AX, CX         ; CX = length
        OUTPUT:
AC          LODSB               ; load DS:SI into AL
B4 02       MOV  AH, 2          ; BIOS set cursor position function
8A D0       MOV  DL, AL         ; ASCII char to DL
80 EA 41    SUB  DL, 'A'        ; convert ASCII char to numeric val (A=0, Z=25)
02 D3       ADD  DL, BL         ; add current position offset
43          INC  BX             ; increment position offset
CD 10       INT  10H            ; move cursor to column in DL
CD 29       INT  29H            ; write char in AL to console
E2 EF       LOOP OUTPUT         ; loop until end of input
C3          RET                 ; exit to DOS

```

Standalone PC DOS executable. Input from command line and prints the new "faster" version to console.

**Output:**

# Answer
> 0 votes
# PHP, ~~127~~ 123 bytes

```
function b($i){for($q=0;$q<strlen($i);$q++){$n[ord($i[$q])-65]=$i[$q];}while($x++<26){$m.=$n[$x-1]?$n[$x-1]:" ";}return$m;}

```

Try it online

Had to fix a bug that wouldn't output 'A'...

# Answer
> 0 votes
## Javascript, 136 characters

Replace the variable s by the input string

```
for(s='',w=[],o=[],i=0;i<s.length;i++)w.push(s[i].charCodeAt(0)-65+i);w.forEach((a,b)=>o[a]=s[b]),console.log((o+'').replace(/,/g,' '));

```

# Answer
> 0 votes
# Java 7, ~~135~~ 133 bytes

```
String a(char[]a){char b[]=new char[37+a.length],c=0;for(;c<a.length;b[a[c]-65+c]=a[c++]);return"".valueOf(b).replaceAll("\0*$","");}

```

### Less Golfed

```
String a(char[]a) {
  char b[]=new char[37+a.length],            // Create an array buffer that is the length of
                                             // the incoming string plus the length of the
                                             // alphabet so we have room to move characters
                                             // 37 is arbitrary. We need >26
  c=0;                                       // Also initialize our index variable. chars are
                                             // basically just bytes in java
  for(;c<a.length;                           // Loop over the input
    b[a[c]-65+c]=a[c++]);                    // 'A' is ascii 65 so if we subtract that and add
                                             // the current index, we have the resulting index
                                             // for that character.
  return"".valueOf(b).replaceAll("\0*$",""); // Convert char array to a string and remove any
                                             // trailing nulls that we didn't use
}

```

Try it online!

# Answer
> 0 votes
# Actually, 32 bytes

```
;ñ⌠i@O:65@-i+⌡M;Mu' *╗Z⌠i╜T╗⌡MX╜

```

Try it online!

### Explanation

As is customary with my long Actually answers, I'm going to break down the code into sections for the explanation.

**Space Padding**

Input: `s` (a string of uppercase ASCII letters)

Output: a list `L` of new indexes for the letters in `s` on top of the stack, `s` below it on the stack, and a string of spaces of sufficient length to hold the output string in register 0

```
;ñ⌠i@O:65@-i+⌡M;Mu' *╗
                        (implicit input)
;ñ                      make a copy of s, enumerate
  ⌠i@O:65@-i+⌡M         for each [index, character] pair: calculate the new position
   i@O                    ordinal of character (in a list)
      :65@-               subtract 65
           i+             add index
               ;M       maximum index
                 u' *   add one, string of that length containing spaces
                     ╗  save to register 0

```

**Letter Rearranging**

Input: the output from the previous step

Output: the expected challenge output

```
Z⌠i╜T╗⌡MX╜
Z           zip the new indices with their respective letters
 ⌠i╜T╗⌡M    for each [index, character] pair: put the character in that index
  i           flatten pair
   ╜T╗        bring string from register 0, set string[index] to character, save in register 0
        X   discard the empty list from the map
         ╜  push the string in register 0
            (implicit output)

```

# Answer
> 0 votes
# AWK, 140 bytes

```
BEGIN{OFS=FS=""}func f(A){for(z=0;sprintf("%c",++z)!=A;);return z-65}{for(;++i<=NF;m=n>m?n:m)a[n=i+f($i)]=$i
for(;++k<=m;)$k=a[k]?a[k]:" "}1

```

Try it online!

Designed for uppercase letters, since I'm subtracting 65. Converting characters to numbers isn't so easy in `AWK`. This is a few bytes shorter than indexing into a string.

# Answer
> 0 votes
# Lua, 126 bytes

```
s=""a={}i=-65(...):gsub(".",function(c)a[c:byte()+i]=c i=i+1 end)for j=0,i+91 do s=s..(a[j]or" ")end print((s:gsub(" +$","")))

```

Try it online!

# Answer
> 0 votes
# ARBLE, 122 bytes

```
s=explode&read()t={}n=0s.map(load'a,b=...k=b+byte(a)-byte"A"t[k]=a n=max&n|k')for i=1,n do t[i]=t[i]or" "end print(join&t)

```

Try it online!

# Answer
> 0 votes
# PHP 7.1, 54+1 bytes

Insert a space between the quotation marks for older PHP.

```
for($r="";$c=$argn[$i++];)$r[$i+ord($c)-66]=$c;echo$r;

```

Run as pipe with `-nR` or try it online.

# Answer
> 0 votes
# Japt `-h`, 14 bytes

```
;åÈhYZ+BbY}Ucç

```

Try it

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


# Question
Title: Generate and print the first 20 Fibonacci numbers with the least unique characters
As the title suggests, my task is fairly straightforward:

Write a program in your language of choice that will print out the first 20 Fibonacci numbers using the least unique characters.

For example in Python 2:

```
def fib(n):
  a,b = 1,1
  for i in range(n-1):
    a,b = b,a+b
  return a
for i in range(1,21):print fib(i)

```

This would have a score of 24, as it has 24 unique characters **including whitespace**.

# Answer
> 15 votes
# CJam, 2 unique characters (1070 bytes)

```
S))))))))))))))))))SS))))))))))))))))))SS)))))))))))))))))))SS)))))))))))))))
)))))SS))))))))))))))))))))))SS)))))))))))))))))))))))))SS))))))))))))))))))S
))))))))))))))))))))SS)))))))))))))))))))S))))))))))))))))))SS)))))))))))))))
)))))S)))))))))))))))))))))SS))))))))))))))))))))))S))))))))))))))))))))))SS)
))))))))))))))))))))))))S))))))))))))))))))))))))))SS))))))))))))))))))S)))))
))))))))))))))))S)))))))))))))))))))))SS)))))))))))))))))))S)))))))))))))))))
)))S))))))))))))))))))))SS))))))))))))))))))))S))))))))))))))))))))))))S)))))
)))))))))))))))))))SS)))))))))))))))))))))))S))))))))))))))))))S)))))))))))))
))))SS))))))))))))))))))))))))))S)))))))))))))))))))))))))S))))))))))))))))))
))))))SS))))))))))))))))))S))))))))))))))))))))))S))))))))))))))))))))))))))S
))))))))))))))))))))))))SS)))))))))))))))))))S))))))))))))))))))))))S))))))))
)))))))))))))))))S)))))))))))))))))))))SS)))))))))))))))))))))S))))))))))))))
))))S)))))))))))))))))))))))))S))))))))))))))))))SS)))))))))))))))))))))))S))
))))))))))))))))))))))S)))))))))))))))))))))))S))))))))))))))))))))))

```

The linefeeds are included for "readability". Try it online in the CJam interpreter.

### How it works

For starters, we don't actually calculate Fibonacci numbers, but build the string

```
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765

```

byte by byte.

Keeping that in mind, we only need two characters to obtain the desired output:

* `S` pushes the string `" "`.
* `)` serves two purposes here:

1. When the topmost item on the stack is a string, `)` pops its last character.

    `S)` leaves an empty string and the space character on the stack.
    2. When the topmost item on the stack is a character, `)` increments its code point.

    This way, `S))))))))))))))))))` pushes the character `1`.

After the program finishes, CJam automatically prints all items on the stack. Fortunately, the empty strings pushed by `S)` aren't visible in the output.

# Answer
> 9 votes
# Unary - 1 unique character

You all knew it was coming.

```
16552026807580920665211491750921730725235456808115643715721126181201732948544576109630429486831063241863270261670172778716193514984700165915528962410601287909151038925505538654870723736863226948250191139201776105749450716207585389147819928943248825902527229387923577427801786113554433618089574276607647435912941850901589122233248109334271085540771125628916636 0's

```

The equivalent brainfuck program:

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

```

It doesn't even bother doing anything with Fibonacci's, just prints the literals.

# Answer
> 6 votes
# Whitespace, 3 unique characters

Dammit, CJam.

Space characters are replaced into `S`, and tabs are `T`, line feeds are `L`.

```
SSSLSSSTSTSTLTTSSSSLSSSTLLSSLSSSLTTTSSSTLTSSTSLSLTSTLSSSLSLTTTSSLSTLSTSSSTSTSLTLSSSLTSTSSTSLTSSSLSLLLSSTLLLL

```

or xxd.

```
$ xxd fib.ws
0000000: 2020 200a 2020 2009 2009 2009 0a09 0920     .   . . ....
0000010: 2020 200a 2020 2009 0a0a 2020 0a20 2020     .   ...  .
0000020: 0a09 0909 2020 2009 0a09 2020 0920 0a20  ....   ...  . .
0000030: 0a09 2009 0a20 2020 0a20 0a09 0909 2020  .. ..   . ....
0000040: 0a20 090a 2009 2020 2009 2009 200a 090a  . .. .   . . ...
0000050: 2020 200a 0920 0920 2009 200a 0920 2020     .. .  . ..
0000060: 0a20 0a0a 0a20 2009 0a0a 0a0a            . ...  .....

```

---

I made it from Whitelips by compiling assembly(?) code.

You can compile and run below at Whitelips.

```
;;;; store repeat count to heap
  push 0
  push 21
  store

;;;; initial setup
  push 0
  push 1

;;;; repeat
repeat:

;;;; check end of loop
  push 0
  retrieve
  push 1
  sub
  dup
  jz end
  push 0
  swap
  store

;;;; print
  dup
  printi
  push 10
  printc

;;;; add
  swap
  copy 2
  add
  jmp repeat

;;;; end
end:
  end

```

# Answer
> 5 votes
## Python 2, 8 unique chars

Uses characters `print+1,`. 35444 chars total. Because of SE character limits, I post an abbreviated version below that only prints the first 14 Fibonacci numbers, but I think it should be clear how to extend it.

```
print+1,+1,+1+1,+1+1+1,+1+1+1+1+1,+1+1+1+1+1+1+1+1,+1+1+1+1+1+1+1+1+1+1+1+1+1,+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1,+1+1+1+1+1+1+1+1+1+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1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1,+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1

```

Here is code to generate the code string `s`:

```
def fib(n):
  a,b = 1,1
  for i in range(n-1):
    a,b = b,a+b
  return a

s="print"
for i in range(1,21):
    n=fib(i)
    s+="+1"*n+','

s=s[:-1]

```

In Python REPL, as well as in many languages, one could omit the `print`, reducing the score to 3.

# Answer
> 4 votes
# Brainfuck, 2 unique characters

## 7801 characters

```
+++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++.++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++.+.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++.+++..++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++.+..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++.++++..+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++.++++.++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++.+++.+++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++.+.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.

```

**Output:** `1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765`

Ideone

Here is the code that wrote this program:

```
ans = "1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765"
x=[ord(c) for c in ans]
s=""
n=0
for q in x:
    if q > n:
        d = q - n
    elif q < n:
        d = 256 - n
        d += q
    else:
        d=0
    s+= "+"*d + "."
    n += d
    if n>255:
        n-=256
print s

```

# Answer
> 4 votes
# Ruby, 6 unique characters, ~~183~~ 118 bytes, actually does the calculation.

183 byte version with `p+=1` space and `\n`

```
p p=1
p pp=1
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p
p p=p+pp
p pp=pp+p

```

It looks like some oddball esolang (like Brainfuck or Perl for example), but it's valid ruby.

We have 2 variables `p` and `pp` to accumulate the numbers in, and we print by means of the `p` command at the beginning of the line.

**118 byte version, with comma instead of newline, and += instead of addition.**

```
p p=1,pp=1,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p,p+=pp,pp+=p

```

# Answer
> 4 votes
# dc, 5 unique

Shortest "non-esoteric" answer so far. Characters used are `2i10P`

```
2i110001001000000011000100100000001100100010000000110011001000000011010100100000001110000010000000110001001100110010000000110010001100010010000000110011001101000010000000110101001101010010000000111000001110010010000000110001001101000011010000100000001100100011001100110011001000000011001100110111001101110010000000110110001100010011000000100000001110010011100000110111001000000011000100110101001110010011011100100000001100100011010100111000001101000010000000110100001100010011100000110001001000000011011000110111001101100011010100001010P

```

I guess its open to debate whether or not `dc` is esoteric.

# Answer
> 3 votes
# Fish (\>\<\>), 3 unique, 3326 bytes

```
111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--11-11-p111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-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-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--111-1-1-1-1-1-1-1-1-1-1--1p111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--111-1-1-1-1-1-1-1-1-1-1-1--1p111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--111-1-1-1-1-1-1-1-1-1-1-1-1--1p111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--111-1-1-1-1-1-1-1-1-1-1-1-1-1--1p111-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1-1--111-1-1-1-1-1-1-1-1-1-1-1-1-1-1--1p

```

Actually calculates the Fibonacci numbers using the program

```
01aa+v
@+&1->:?!;&:nao:

```

which is placed into the codebox using only `-1p`.

# Answer
> 1 votes
# JavaScript, 6 unique

```
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[+!+[]]+[!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]]+[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[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]+!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[!+[]+!+[]]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()

```

This has a total of 6547 characters and alerts the string `"1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765"`.

# Answer
> 1 votes
# dc, 2 unique, 6786 bytes

```
zzppzpzpzzpzzzpzzzzzpzzzzzzzzpzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzzzpzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzp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zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzp

```

Try it online!

The only characters used are `p` and `z`.

Here's a run with output:

```
$ dc -f fibo
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765

```

# Answer
> 1 votes
# SmileBASIC, 3 unique chars (409 bytes)

Characters used: `?`, `1`, `-` (Line breaks inserted for readability)

```
?1
?1
?1--1
?1--1--1
?1--1--1--1--1
?11-1-1-1
?11--1--1
?11--11-1
?11--11--11--1
?11--11--11--11--11
?111-11-11
?111--11--11--11--11--11
?111--111--11
?111--111--111--11--11--11--11
?111--111--111--111--111--11--11--11--11--11
?1111-111-11-1-1
?1111--111--111--111--111--11--11--11--11-1-1
?1111--1111--111--111--111--11--11--11-1-1-1-1
?1111--1111--1111--1111-111-111-11-11-11-11--1--1--1
?11111-1111-1111-1111-1111--111-11-1-1

```

`?` is the same as `PRINT`

I used `-` instead of `+` to allow both addition and subtraction, which (probably) makes it shorter (not that it matters).

Probably works in other BASIC dialects, as long as they don't care about the lack of separation between lines.

Also works in my unfinished language. (Online interpreter: https://12me21.github.io/language/wasm/)

# Answer
> 0 votes
# Golfscript, 4 unique characters

Uses `1 +p` (literal space)

Only pasting the first 7....

```
1p 1p 1 1+p 1 1+1+p 1 1+1+1+1+p 1 1+1+1+1+1+1+1+p 1 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+p

```

It gets out of hand quickly. Copy, paste, copy, paste, copy, paste the same sequence.

# Answer
> 0 votes
# Jelly, 2 unique chars

```
‘ṄṄ‘Ṅ‘Ṅ‘‘Ṅ‘‘‘Ṅ‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘Ṅ‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘

```

Try it online!

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


title: Connect 4: Spot the Fake!

text:
# Question
Title: Connect 4: Spot the Fake!
The bank has been broken into, and all the local mafia thugs have an unusual alibi: they were at home playing Connect 4! In order to assist with the investigation, you are asked to write a program to validate all the Connect 4 boards that have been seized in order to check that the positions are indeed positions from a valid Connect 4 game, and have not been hastily put together as soon as the police knocked on the door.

The rules for connect 4: players `R` and `Y` take it in turns to drop tiles of their colour into columns of a 7x6 grid. When a player drops a tile into the column, it falls down to occupy the lowest unfilled position in that column. If a player manages to get a horizontal, vertical or diagonal run of four tiles of their colour on the board, then they win and the game ends immediately.

For example (with `R` starting), the following is an impossible Connect 4 position.

```
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | |R| | | | |
| | |Y| | | | |
|R| |Y| | | | |

```

Your program or function must take in a Connect 4 board and return either

* A falsy value, indicating that the position is impossible or
* A string of numbers from 1 to 7, indicating one possible sequence of moves leading to that position (the columns are numbered `1` to `7` from left to right, and so the sequence `112`, for example, indicates a red move in column `1`, followed by a yellow move in column `1`, followed by a red move in column `2`). You may choose a column-numbering other than 1234567 if you like, as long as you specify in your solution. If you want to return the list in some other format; for example as an array `[2, 4, 3, 1, 1, 3]` then that is fine too, as long as it is easy to see what the moves are.

You can choose to read the board in in any sensible format including using letters other than `R` and `Y` for the players, but you must specify which player goes first. You can assume that the board will always be 6x7, with two players.

You may assume that the positions you receive are at least physically possible to create on a standard Connect 4 board; i.e., that there will be no 'floating' pieces. You can assume that the board will be non-empty.

This is code golf, so shortest answer wins. Standard loopholes apply.

**Examples**

```
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> 1234567 (one possible answer)
| | | | | | | |
|R|Y|R|Y|R|Y|R|

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | |R| | | | | --> false
| | |Y| | | | |
|R| |Y| | | | |

| | | | | | | |
| | |Y| | | | |
| | |R| | | | |
| | |Y| | | | | --> 323333 (only possible answer)
| | |R| | | | |
| |Y|R| | | | |

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> false (this is the position arising after
| |Y|Y|Y|Y| | |     the moves 11223344, but using those moves
| |R|R|R|R| | |     the game would have ended once R made a 4)

| | | | | | | |
| | | | | | | |
|Y| | | | | | |
|R|Y| | | | | | --> 2134231211 (among other possibilities)
|R|R|Y| | | | |
|Y|R|R|Y| | | |

| | | | | | | |
| | | | | | | |
|Y| | | | | | |
|R|Y| | | | | | --> false (for example, 21342312117 does not
|R|R|Y| | | | |     work, because Y has already made a diagonal 4)
|Y|R|R|Y| | |R|

| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | | --> 112244553 or similar
|Y|Y| |Y|Y| | |
|R|R|R|R|R| | |

```

# Answer
# Jelly, 57 bytes

```
ŒṪŒ!µ0ịŒṬ¬a³ZU,Ɗ;ŒD$€Ẏṡ€4Ḅo1%15;Ḋ€ṢṚ$Ƒƙ$Ȧȧœị³$2R¤ṁ$ƑµƇṪṪ€

```

Takes a matrix where `0` is unfilled, `1` played first, and `2` played second. Yields a list of 1-indexed columns, empty if a fake was identified.

**Try it online!** (too inefficient for more than 7 pieces to run in under a minute)

Note:

1. Assumes that no "floating" pieces are present (fix this by prepending `ZṠṢ€Ƒȧ` for +6 bytes)
2. Assumes that the empty board is a fake
> 9 votes

# Answer
# JavaScript (ES6),  ~~202 194 187~~  183 bytes

Takes input as a matrix with \\$2\\$ for red, \\$4\\$ for yellow and \\$0\\$ for empty. Returns a string of 0-indexed moves (or an empty string if there's no solution). Reds start the game.

```
m=>(p=[...'5555555'],g=(c,s=o='')=>/2|4/.test(m)?['',0,2,4].some(n=>m.join``.match(`(1|3)(.{1${n}}\\1){3}`))?o:p.map((y,x)=>m[m[y][x]--^c||p[g(c^6,s+x,p[x]--),x]++,y][x]++)&&o:o=s)(2)

```

Try it online!

### How?

The recursive function \\$g\\$ attempts to replace all \\$2\\$'s and \\$4\\$'s in the input matrix with \\$1\\$'s and \\$3\\$'s respectively.

While doing so, it makes sure that we don't have any run of four consecutive odd values until all even values have disappeared (i.e. if a side wins, it must be the last move).

The row \\$y\\$ of the next available slot for each column \\$x\\$ is stored in \\$p\[x\]\\$.

### Commented

```
m => (                            // m[] = input matrix
  p = [...'5555555'],             // p[] = next row for each column
  g = (c,                         // g = recursive function taking c = color,
          s = o = '') =>          //     s = current solution, o = final output
    /2|4/.test(m) ?               // if the matrix still contains at least a 2 or a 4:
      ['', 0, 2, 4]               //   see if we have four consecutive 1's or 3's
      .some(n =>                  //   by testing the four possible directions
        m.join``                  //   on the joined matrix, using
        .match(                   //   a regular expression where the number of characters
          `(1|3)(.{1${n}}\\1){3}` //   between each occurrence is either 1, 10, 12 or 14
        )                         //   (horizontal, diagonal, vertical, anti-diagonal)
      ) ?                         //   if we have a match:
        o                         //     abort and just return the current value of o
      :                           //   else:
        p.map((y, x) =>           //     for each cell at (x, y = p[x]):
          m[                      //
            m[y][x]--             //       decrement the value of the cell
            ^ c ||                //       compare the original value with c
            p[                    //       if they're equal:
              g(                  //         do a recursive call with:
                c ^ 6,            //           the other color
                s + x,            //           the updated solution
                p[x]--            //           the updated row for this column
              ),                  //         end of recursive call
              x                   //         then:
            ]++,                  //         restore p[x]
            y                     //         and restore m[y][x]
          ][x]++                  //         to their initial values
        ) && o                    //     end of map(); yield o
    :                             // else:
      o = s                       //   we've found a solution: copy s to o
)(2)                              // initial call to g() with c = 2

```
> 11 votes

# Answer
# Python 2, ~~295~~ 285 bytes

```
def f(a):
 if 1-any(a):return[]
 p=sum(map(len,a))%2
 for i in R(7):
	if a[i][-1:]==`p`:
	 b=a[:];b[i]=b[i][:-1];L=f(b)
	 if L>1>(`1-p`*4in','.join([J((u[j]+' '*14)[n-j]for j in R(7))for n in R(12)for u in[b,b[::-1]]]+b+map(J,zip(*[r+' '*7for r in b])))):return L+[i]
R=range;J=''.join

```

Try it online!

-10 thx to Jo King.

Input is a list of strings representing the columns; with '1' for Red and '0' for Yellow. The strings are not ' '-padded. So the (falsey) case:

```
| | | | | | | |
| | | | | | | |
|Y| | | | | | |
|R|Y| | | | | |
|R|R|Y| | | | |
|Y|R|R|Y| | |R|

```

is input as:

```
[
  '0110',
  '110',
  '10',
  '0',
  '',
  '',
  '1'
]

```

Output is a list of column indexes, 0-indexed, that could make the board; or `None` if it's not valid.

Accepts the empty board as valid (returns the empty list `[]` instead of `None`).

This approach is recursive from the last move to the first move: based on the parity of the total number of moves taken, we remove either the last Red move or the last Yellow move (or fail if that is not possible); check the resulting board to see if the opponent has 4-in-a-row (in which case fail, because the game should have stopped already); otherwise, recurse until the board is empty (which is valid).

The 4-in-a-row code is the most bloaty part. All the diagonal strings for the matrix `b` are generated by:

```
[
    ''.join(
        (u[j]+' '*14)[n-j] for j in range(7)
    )
    for u in[b,b[::-1]]for n in range(12)
]

```

which first lists out the 'down-sloping' diagonals, and then 'up-sloping' ones.
> 2 votes

---
Tags: code-golf, board-game
---


title: Write a Sine-Deriving Machine

text:
# Question
Title: Write a Sine-Deriving Machine
### The Challenge

Your challenge is to write a program that evaluates the following function:

f(x, t) = d^x / dt^x (sin t)

That is, the x-th derivative of sin t. In case you aren't familiar with calculus, here is a table of derivatives for the sine function:

...

f(-1, t) = -cos t

f(0, t) = sin t

f(1, t) = cos t

f(2, t)= -sin t

...

The sequence repeats these 4 functions.

### The Inputs

Your program should take in an integer to be used as the x value in the function, and a float to be used at the t value in the function.

Your program may use radians or degrees for the sine function.

### The Output

Your program should output the value of f(x, t) given the integer x and float t.

### Scoring

This is , so the shortest answer (in bytes) wins.

# Answer
## Actually, 5 bytes

```
╦*½+S

```

Try it online

Takes input as `t\nx`.

Explanation:

```
╦*½+S
╦*     pi*n
  ½    half that
   +   add t
    S  sine

```
> 6 votes

# Answer
## Python, 42 bytes

```
from math import*
lambda x,n:sin(x+pi/2*n)

```

Uses the fact that differentiating shifts the function by `pi/2` left.
> 10 votes

# Answer
# C (gcc), 30 bytes

```
#define f(x,n)sin(x+n*acos(0))

```
> 6 votes

# Answer
## Haskell, 16 bytes

```
x%n=sin$x+pi/2*n

```

Defines a binary operator `%`.

```
λ 2.0 % (-3)
-0.4161468365471426

```

Uses the fact that differentiating shifts the function by `pi/2` left.

Making it point-free was longer (takes `n x`):

```
(sin.).(+).(pi/2*)

```
> 4 votes

# Answer
# Convex (IDE version only), 6 bytes

```
P½*+ms

```

Try it online!

After futher investigation, with the help of Dennis in chat, it was found that the command-line version of Convex (what TIO uses) has a bug that breaks the code (the link above contains a workaround). However, the IDE version of Convex, avaliable on GitHub before the challenge was posted, does not have this bug. Here is a link to the IDE version that was avaliable before the challenge was posted: Convex IDE.
> 4 votes

# Answer
# Mathematica 14 bytes

With help from Martin Ender,

```
Sin[#2+Pi/2#]&

```
> 3 votes

# Answer
# J, 17 bytes

```
4 :'1&o.d.(4|x)y'

```

Computes the (x%4)th derivative of sine, and then apply to right argument.

## Usage:

```
>> f =: 4 :'1&o.d.(4|x)y'
>> _1 0 1 2 3 (f"0 0) 0
<< _1 0 1 0 _1

```

where `>>` is STDIN and `<<` is STDOUT.
> 2 votes

# Answer
# Julia, 17 bytes

```
x\t=x*π/2+t|>sin

```

Try it online!
> 2 votes

# Answer
# C (gcc), ~~53~~ ~~46~~ 45 bytes

```
#import<math.h>
#define f(x,n)sin(x+M_PI/2*n)

```

Probably Ideone doesn't have glibc, says `M_PI` is undeclared.
> 1 votes

# Answer
## R, 26 bytes

```
function(t,x)sin(t+pi/2*x)

```

Exactly what it says on the tin...
> 1 votes

# Answer
# JavaScript (ES6), 29 bytes

```
x=>t=>Math.sin(t+Math.PI/2*x)

```

Usage:

```
f=x=>t=>Math.sin(t+Math.PI/2*x)
f(x)(t)

```
> 1 votes

# Answer
## Lua 5.x, 37 bytes

```
x,n=...return math.sin(x+math.pi/2*n)

```

usage:

```
> print(loadfile('sine.lua')(1,0))
0.8414709848079
> print(loadfile('sine.lua')(math.pi,0))
1.2246467991474e-16
> print(loadfile('sine.lua')(math.pi,1))
-1.0
> print(loadfile('sine.lua')(math.pi,2))
-2.4492935982947e-16
> print(loadfile('sine.lua')(math.pi,3))
1.0

```
> 1 votes

# Answer
## Matlab, 19 bytes

```
@(x,t)sin(t+x*pi/2)

```
> 1 votes

# Answer
# SQF, 29 bytes

Using the file-as-a-function format:

```
params["x","y"];sin(x+pi/2*y)

```

Call as `[x, t] call NAME_OF_COMPILED_FUNCTION`
> 0 votes

# Answer
# SmileBASIC, 25 bytes

```
INPUT X,N?SIN(X+N*PI()/2)

```

Probably shorter in some BASIC dialect that has a constant named `PI` rather than `PI()`. (Yes, `PI()` is not actually a function, those parentheses are a lie.)
> 0 votes

# Answer
# 05AB1E, 7 bytes

```
žq*;+Å½

```

Port of *@Mego♦*'s Actually answer.

Try it online or verify some more test cases.

**Explanation:**

```
žq        # Push PI
  *       # Multiply it with the first (implicit) input `t`
   ;      # Halve it
    +     # Add the second (implicit) input `x`
     Å½   # Take the Sine of that (and output it implicitly)

```
> 0 votes

---
Tags: code-golf, calculus, trigonometry
---


title: Is it Valid Modified UTF-8?

text:
# Question
Title: Is it Valid Modified UTF-8?
UTF-8 is a relatively simple way to encode Unicode codepoints in a variable-width format such that it doesn't easily confuse code that isn't Unicode aware.

## UTF-8 overview

* Bytes in the range of 1-0x7F, inclusive, are normally valid
* Bytes with the bit pattern `10XX XXXX` are considered continuation bytes, with the six least significant bits being used to encode part of a codepoint. These must not appear unless they are expected by a preceding byte.
* Bytes with the pattern `110X XXXX` expect one continuation byte afterward
* Bytes with the pattern `1110 XXXX` expect two continuation bytes afterward
* Bytes with the pattern `1111 0XXX` expect three continuation bytes afterward
* All other bytes are invalid and should not appear anywhere in a UTF-8 stream. 5, 6, and 7 byte clusters are possible in theory, but will not be allowed for the purposes of this challenge.

## Overlong encodings

UTF-8 also requires that a codepoint should be represented with the minimum number of bytes. Any byte sequence that could be represented with fewer bytes is not valid. Modified UTF-8 adds one exception to this for null characters (U+0000), which should be represented as `C0 80` (hex representation)), and instead disallows null bytes to appear anywhere in the stream. (This makes it compatible with null-terminated strings)

# Challenge

You are to make a program that, when given a string of bytes, will determine if that string represents valid Modified UTF-8 and will return a truthy value if valid and a falsy value otherwise. Note that you must check for overlong encodings and null bytes (since this is Modified UTF-8). You do not need to decode the UTF-8 values.

# Examples

```
41 42 43  ==> yes (all bytes are in the 0-0x7F range)
00 01 02  ==> no (there is a null byte in the stream)
80 7F 41  ==> no (there is a continuation byte without a starter byte)
D9 84 10  ==> yes (the correct number of continuation bytes follow a starter byte)
F0 81 82 41  ==> no (there are not enough continuation bytes after F0)
EF 8A A7 91  ==> no (too many continuation bytes)
E1 E1 01  ==> no (starter byte where a continuation byte is expected)
E0 80 87  ==> no (overlong encoding)
41 C0 80  ==> yes (null byte encoded with the only legal overlong encoding)
F8 42 43  ==> no (invalid byte 'F8')

```

# Rules

* Standard rules and loopholes apply
* Input and output can be in any convenient format as long as all values in the unsigned byte range (0-255) can be read in.
    + You may need to use an array or file rather than a null-terminated string. You need to be able to read null bytes.
* Shortest code wins!
* Note that using builtins to decode the UTF-8 is not guaranteed to conform to the requirements given here. You may need to work around it and create special cases.

EDIT: added bonus for not using builtins that decode UTF-8

EDIT2: removed bonus since only the Rust answer qualified and it's awkward to define.

# Answer
> 2 votes
# Elixir, 69 bytes

```
import String
&valid? replace replace(&1,<<0>>,"\xFF"),"\xC0\x80","0"

```

Try it online!

Makes use of built-in string validation function. Takes input as Elixir binary.

# Answer
> 1 votes
# APL (Dyalog Unicode), ~~41~~ 39 bytesSBCS

Anonymous tacit prefix function. Takes a Unicode string as argument where the characters' code points represent the input bytes.

```
{0::0⋄×⌊/'UTF-8'⎕UCS⍣2⎕UCS⍵}'À\x80'⎕R⎕A

```

Try it online!

`'À\x80'⎕R⎕A`**R**eplace `C0 80`s with the uppercase **A**lphabet

`{``}` apply the following anonymous function, where the argument is :

`0::` if any error happens:

`0` return zero

try:

`⎕UCS⍵` convert the string to code points

`'UTF-8'⎕UCS⍣2` interpret as UTF-8 bytes and convert resulting text back to bytes

`⌊/` lowest byte (zero if a null byte is present, positive if not, "infinity" if empty string)

`×` sign (zero if null byte is present, one if not)

# Answer
> 0 votes
# Python 2, ~~104~~ 102 bytes

```
''.join(chr(int(c,16))for c in input().replace('00','-').replace('C0 80','0').split()).decode('utf-8')

```

Try it online!

Outputs via exit code

# Answer
> 0 votes
# Rust - ~~191 bytes~~ 313 bytes

Per comment below original did not work properly. New and improved version. No libraries are used, because The Mighty Rust Has No Need For You And Your Libraries. This code uses pattern matching with a state machine. By shamelessly ripping off the UTF8 spec, after finding it via reference and discussion by Jon Skeet, we can copy the spec almost character for character into a rust Match pattern match block. At the end, we add in Beefster's special Mutf8 requirement for C0 80 to be considered valid. Ungolfed:

```
/* http://www.unicode.org/versions/corrigendum1.html
 Code Points        1st Byte    2nd Byte    3rd Byte    4th Byte
U+0000..U+007F      00..7F
U+0080..U+07FF      C2..DF      80..BF
U+0800..U+0FFF      E0          A0..BF      80..BF
U+1000..U+FFFF      E1..EF      80..BF      80..BF
U+10000..U+3FFFF    F0          90..BF      80..BF      80..BF
U+40000..U+FFFFF    F1..F3      80..BF      80..BF      80..BF
U+100000..U+10FFFF  F4          80..8F      80..BF      80..BF
*/

let m=|v:&Vec<u8>|v.iter().fold(0, |s, b| match (s, b) {
        (0, 0x01..=0x7F) => 0,
        (0, 0xc2..=0xdf) => 1,
        (0, 0xe0) => 2,
        (0, 0xe1..=0xef) => 4,
        (0, 0xf0) => 5,
        (0, 0xf1..=0xf3) => 6,
        (0, 0xf4) => 7,
        (1, 0x80..=0xbf) => 0,
        (2, 0xa0..=0xbf) => 1,
        (4, 0x80..=0xbf) => 1,
        (5, 0x90..=0xbf) => 4,
        (6, 0x80..=0xbf) => 4,
        (7, 0x80..=0x8f) => 4,
        (0, 0xc0) => 8, // beefster mutf8 null
        (8, 0x80) => 0, // beefster mutf8 null
        _ => -1,
    })==0;

```

try it on the rust playground

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


title: Prime Difference

text:
# Question
Title: Prime Difference
Given an integer *n*, output the smallest prime such that the difference between it and the next prime is at least *n*.

For example, if `n=5`, you would output `23`, since the next prime is `29`, and `29-23>=5`.

# More Input/Output Examples

```
1 -> 2 (3 - 2 >= 1)
2 -> 3 (5 - 3 >= 2)
3 -> 7 (11 - 7 >= 3)
4 -> 7
5 -> 23
6 -> 23
7 -> 89
8 -> 89

```

This is , so shortest code wins.

# Answer
# Husk, 8 bytes

```
Ψḟo≥⁰≠İp

```

Try it online!

Inspired by this post in chat

, under normal circumstances, finds the first element of a list that satisfies a predicate. However, when combined with the function `Ψ`, it finds the first element that satisfies a predicate with respect to its successor in the list.

The predicate is `o≥⁰≠`, which asks if the absolute difference of two numbers is at least the input.

The list is `İp`, the list of prime numbers
> 8 votes

# Answer
# Perl 6, 40 bytes

```
{1-$_+first ++($*=!*.is-prime)>=$_,2..*}

```

Try it online!

38 bytes, 0-based (I'm not sure this is allowed):

```
{-$_+first ++($*=!*.is-prime)>$_,2..*}

```

Try it online!
> 4 votes

# Answer
# Perl 6, 56 bytes

```
{first {$^a.$![1]-$a>=$_},.$!}
$!={grep &is-prime,$_..*}

```

Try it online!

I feel like there's definitely some improvement to be made here, especially in regards to the `$![1]`. This is an anonymous code block that can be assigned to a variable, as well as a helper function assigned to `$!`.
> 3 votes

# Answer
# , ~~26~~ ~~24~~ 22 bytes

```
>:@]^:(>:4&p:-])^:_ 2:

```

Try it online!

0-based

## Explanation:

```
                      2:  start with the first prime number and
      ^:(        )^:_     while
         >:               the argument is greater or equal to the
               -          difference of
           4&p:           the next prime number and
                ]         the current prime number
  >:@]                    go to the next number

```
> 3 votes

# Answer
# C (gcc), 58 bytes

Same logic as my JS answer, with a non-recursive implementation.

```
f(n,p,q,x){for(p=q=x=2;q-p<n;q%x--||(p=x?p:q,x=q++));q=p;}

```

Try it online!
> 3 votes

# Answer
# Jelly, 8 bytes

```
2Æn:+ɗ1#

```

Try it online!

### How it works

```
2Æn:+ɗ1#  Main link. Argument: n

2         Set the return value to 2.
      1#  Find the first k ≥ 2 such that the link to the left, called with arguments
          k and n, returns a truthy value.
     ɗ    Dyadic chain:
 Æn           Find the next prime p ≥ k.
    +         Yield k + n.
   :          Perform integer division.

```
> 2 votes

# Answer
# JavaScript (ES6),  ~~61 57 56~~  54 bytes

```
n=>(g=(q,x=q++)=>q-p<n?q%x--?g(q,x):g(x?q:p=q):p)(p=2)

```

Try it online!

### Commented

```
n => (                    // n = input
  g = (                   // g = recursive function taking:
    q,                    //   q = prime candidate
    d = q++               //   d = divisor
  ) =>                    //
    q - p < n ?           // if q - p is not large enough:
      q % d-- ?           //   decrement d; if d was not a divisor of q:
        g(q, d)           //     try again until it is
      :                   //   else:
        g(                //     do a recursive call to look for the next prime
          d ? q : p = q   //       if q was prime, update the previous prime p to q
        )                 //     end of recursive call
    :                     // else:
      p                   //   success: return p
                          //   NB: we don't know if q is prime or not, but the only
                          //       thing that matters at this point is that the next
                          //       prime is greater than or equal to q
)(p = 2)                  // initial call to g with p = q = 2

```

---

# Non-recursive version, 54 bytes

By porting back in JS my non-recursive port in C, it turns out that we can reach 54 bytes as well.

```
n=>eval(`for(p=q=x=2;q-p<n;q%x--||(p=x?p:q,x=q++));p`)

```

Try it online!

### Performance

This piece of code is a good illustration of the utterly bad performance of `eval()`, which prevents JIT compilation:

* It takes 35 to 40 sec. to compute \\$a(1)\\$ to \\$a(37)\\$ on TIO with the above code.
* It takes ~1.5 sec. to do the same thing without `eval()`:

```
// 55 bytes
n=>{for(p=q=x=2;q-p<n;q%x--||(p=x?p:q,x=q++));return p}

```
> 2 votes

# Answer
# 05AB1E, 9 bytes

```
∞<ØD¥I@Ïн

```

Try it online or verify all test cases.

**Explanation:**

```
∞           # Get an infinite list in the range [1, ...]
 <          # Decrease it by one to make it in the range [0, ...]
  Ø         # Get for each the (0-indexed) n'th prime: [2,3,5,7,11,...]
   D        # Duplicate this list of primes
    ¥       # Get all deltas (difference between each pair): [1,2,2,4,2,...]
     I@     # Check for each if they are larger than or equal to the input
            #  i.e. 4 → [0,0,0,1,0,1,0,1,1,0,...]
       Ï    # Only keep the truthy values of the prime-list
            #  → [23,31,47,53,61,...]
        н   # And keep only the first item (which is output implicitly)
            #  → 23

```
> 2 votes

# Answer
# Brachylog, 12 bytes

```
∧⟧ṗˢsĊ-≥?∧Ċt

```

Try it online!

### Explanation

```
∧⟧              Take a descending range from an unknown integer down to 0
  ṗˢ            Select only primes in that range
    sĊ          Take a substring of 2 elements in that range; call it Ċ
      -≥?       The subtraction of those 2 elements must be greater than the input
         ∧Ċt    The output is the tail of Ċ

```
> 1 votes

# Answer
# Python 2, 63 bytes

```
n=input()
k=P=b=2
while k-b<n:
 if P%k:b=k
 P*=k*k;k+=1
print b

```

Try it online!
> 1 votes

# Answer
# Pari/GP, 38 bytes

```
n->i=2;while(nextprime(i+1)-i<n,i++);i

```

Try it online!
> 1 votes

# Answer
# Ruby, ~~39~~ 38 bytes

```
->n,m=2{Prime.find{|i|i-m>=n||!m=i};m}

```

Try it online!
> 1 votes

# Answer
# Husk, 9 bytes

```
→←ġo<⁰-İp

```

Try it online!

This is a really interesting question allowing a range of possible approaches (and Husk is a good fit for it; I learned the language for the challenge).

The TIO link contains a wrapper to run this function on all inputs from 1 to 10.

## Explanation

```
→←ġo<⁰-İp
       İp   The (infinite) list of primes
  ġ         Group them, putting adjacent primes in the same group if
      -         the difference between them
    <⁰          is less than the input
   o          (fix for a parser ambiguity that causes this parse to be chosen)
→           Take the last element of
 ←          the first group

```

Grouping primes that are too close together means that the first break in the groups will be the first point at which the primes are sufficiently far apart, so we simply just need to find the prime just after the break.

## Other potential solutions

Here's an 8-byte solution that, sadly, only works with even numbers as input (and thus isn't valid):

```
-⁰LU⁰mṗN
       N   On the infinite list of natural numbers
     m     replace each element with
      ṗ      0 if composite, or a distinct number if prime
   U       Find the longest prefix with no repeated sublist of length
    ⁰        equal to the input
-⁰         Subtract the input from
  L          the length of that prefix

```

The idea is that when we have two primes that are a distance of (say) 6 apart, there'll be a sequence of five consecutive zeroes in the `mṗN` sequence, which contains two identical sublists of length 4 (the first four zeroes and last four zeroes), but such a repetition cannot happen earlier (because as each prime is mapped to a unique number, any length-4 substrings before the first prime gap \> 4 will contain a prime number, and the substring will therefore be unique as it's the only substring which contains that number in that position). Then we just have to subtract the trailing zeroes from the length of the prefix to get our answer.

This doesn't work with odd inputs because the sublist of *input* zeroes only occurs once rather than twice, so the code ends up finding the second point at which it occurs rather than the first.
> 0 votes

# Answer
# Japt, 16 bytes

```
@§Xn_j}aXÄ)©Xj}a

```

Try it or test `0-20`
> 0 votes

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