# Find the program that prints this integer sequence (Cops' thread)

• The cop's task is to write a program/function that takes a positive (or non-negative) integer and outputs/returns another integer.
• The cop must state it if the program is intolerant towards zero.
• The cop will provide at least 2 sample inputs/outputs.
• For example, if I have decided to write the Fibonacci sequence, I would write this in my answer:
a(0) returns 0
a(3) returns 2

• The number of examples is up to the cop's discretion.
• However, the sequence must actually exist in the On-Line Encyclopedia of Integer Sequences®, so no pseudo-random number generator for you. :(
• The cop can hide as many characters as is so wished.
• For example, if my program is:

function a(n)
if n>2 then
return n
else
return a(n-1) + a(n-2)
end
end


• Then I would hide these characters as I want:

function a(n)
if ### then
########
else
######################
end
end


• is obviously to find the original source code.
• However, any proposed source code that produces the same set of output also counts as valid, as long as it is also found in OEIS.

## Tips for the cops

• The search function in the OEIS only works for consecutive terms, so if you want to hide your sequence, then just leave a hole anywhere.
• Apparently there is no way to hide the sequence. Put this in mind when you choose the sequence.

The winner will be the submission with the lowest score that hasn't been cracked in 7 days.

Only submissions that are posted in 2016 April are eligible for the win. Submissions that are posted later than this are welcome, but cannot win.

In order to claim the win you need to reveal the full code and the OEIS sequence (after 7 days).

Your post should be formatted like this (NN is the number of characters):

# Lua, 98 bytes

Output:

a(0) returns 0
a(3) returns 2


Code (# marks unrevealed characters):

function a(n)
if ### then
########
else
######################
end
end


If the code is cracked, insert [Cracked](link to cracker) in the header. If the submission is safe, insert "Safe" in the header and reveal the full code in your answer. Only answers that have revealed the full code will be eligible for the win.

• Also, OEIS search can have blanks with _, fyi – Sp3000 Apr 9 '16 at 0:59
• It may be too late to change, but allowing sequences that are multiples of an OEIS sequence, and/or only include every nth term would have made this challenge much better. sandbox, hint, hint – Nathan Merrill Apr 9 '16 at 2:37
• Can I, for example, pick the Fibonacci sequence and provide only a(1000)? (which is part of the sequence, but too large to be searchable on OEIS) – Sp3000 Apr 9 '16 at 6:36
• I'd say the values have to actually be searchable on OEIS, so that it can easily be verified that the values are correct for the chosen sequence. – Mego Apr 9 '16 at 6:38
• "Intolerant towards zero" makes no sense. What is that supposed to mean? – feersum Apr 10 '16 at 23:28

## 05AB1E, 3 bytes, Cracked

Output:

a(3) = 2
a(4) = 6


Code:

___


_ (underscore) indicates an obfuscated character

Try it online

Original Code:

D;^


Which is the sequence A003188 (Decimal equivalent of Gray code for n)

• Cracked. That was a nice puzzle! :) – Adnan Apr 28 '16 at 22:54

## Python 3, 58 Bytes, Cracked

# marks unrevealed chars.

import math;x=int(input());print(int(x/math.####(#)*#**#))


If x < 1, it will not work.

in    out
1     0
4     457
7     2578097
10    44721359549
13    1760848250285208
16    131994155879539032064
19    16810747184697114703691776


## Pyth, 51 bytes, Safe

# denote hidden characters:

K"#"D#d=#:d"#|#"1Rs#?qd"#"####"##"b#W<#K+#1=KhK;@KQ

K"0"Dhd=b:d"0|1"1Rsm?qd"0""01""10"b;W<lK+Q1=KhK;@KQ


## Outputs

a(0) -> 0
a(1) -> 1
a(2) -> 1
a(4) -> 0


This is a fair one.

Thue-morse sequence, A010060.

# Python, 17 bytes, Cracked

####a(n):########


Test cases:

a(1) -> 1
a(2) -> 2

• Cracked – Blue Apr 12 '16 at 17:40

# Python, 60 bytes, Cracked

def a(n):
if n<#:
return #
else:
return a(n-#)+a(n-#)


Test cases:

a(0) -> 1
a(1) -> 1
a(3) -> 2
a(6) -> 6

• Cracked – Blue Apr 12 '16 at 17:46

# Jelly, 5 bytes (safe)

### Code

??Œ??


Each ? denotes a missing character.

### Output

n a(n)

0    1
1    3
2    9
3   21
4   45
5   93
6  189
7  381
8  765
9 1533


This is OEIS entry A068156.

### Solution

Ḷ¡ŒṘL


Try it online!

### How it works

As noted on the OEIS page, this sequence obeys the recursive formula a(n + 1) = 2a(n) + 3, with base cases a(0) = 1, a(1) = 3.

The code begins with the integer n and applies Ḷ (unlength) n times, which convert all integers k in the previous array into the range [0, ... k - 1]. The output after all n steps is similar to the set-theoretic definition of n.

For n = 0, 1, 2, 3, 4, the outputs of Ḷ¡ŒṘ (unlength n times, then generate Python's string representation) is as follows.

0: 0
1: [0]
2: [[], [0]]
3: [[], [[]], [[], [0]]]
4: [[], [[]], [[], [[]]], [[], [[]], [[], [0]]]]


If we examine the outputs for 3 and 4 closely, we can note the following pattern.

[[], [[]], [[], [0]]]XX[[], [[]], [[], [0]]]X
[[], [[]], [[], [[]]], [[], [[]], [[], [0]]]]


The output for 4 consists of two copies of the output for 3 (the actual characters differ, but we're only interested in the length), and three additional characters (X marks the spots). Thus, if we take the length with L, our program follows the desired recursive formula.

## Python 3, 108 bytes (Cracked)

Warning (and hint): my implementation is dreadfully slow...

>>> a(0)
0
>>> a(4)
2
>>> a(16)
8
>>> a(20)
42


a(0) is the first element of the series exactly as defined in OEIS. # is used to hide chars.

def a(n):
###n####0######n#0
f=a#######
return f #f#####a###### f ####a(##f###i#i###a####n##else a#######

• Cracked – FliiFe Apr 10 '16 at 20:58

## Python 3, 50 bytes (Cracked)

Another one, because I like this sequence

>>> a(1)
0
>>> a(10)
2303


The first number from the sequence is a(0). # used to obfuscate characters.

from #### import ####
a=lambda n:####(###########)

• Cracked – Mego Apr 11 '16 at 1:44

# Python 3, 58 bytes (Cracked)

One last series

>>> a(0)
0
>>> a(4)
8
>>> a(5)
17


Sequence starts with a(0).

a=lambda n:###(###(###)## if ###### else #####(#######)##)


Original was different than the cracked, because I can't golf Python :P

a=lambda n:int(3**(n/2)-1 if n%2==0 else 2*3**(n/2-1/2)-1)


## Pyth, 29 bytes

W##YQ#t^#Z=#h#I#_#=#+Y##;@#tQ


Probably not an easy one. Begins at 1.

a(1) -> 2
a(2) -> 3
a(3) -> 5
a(4) -> 7
a(5) -> 13


# Python 2, 72 bytes, cracked

print####((#y##########.####c###6#####16#.######)#131963###input()#3###)


Outputs:

a(1) = 1
a(2) = 2
a(3) = 3
a(4) = 6
a(5) = 9
a(6) = 18


a(1) is the first element of the sequence. Tested on my personal computer, on repl.it and on ideone (which have versions 2.7.11, 2.7.2 and 2.7.10 respectively).

The sequence is finite, and all terms are listed - it's just the divisors of 18. However, I overlooked the idea that #s could be substituted for newlines...

The original one-liner was:

print len((BytesWarning.__doc__*6)[8::16].split()[1319648>>input()*3&7])

## Pyth, 4 bytes, Cracked

# denote hidden characters:

###Q


## Output

a(1) -> 1
a(2) -> 2
a(3) -> 3
a(10) -> 42

• Is this offset at all? – Blue Apr 11 '16 at 17:22
• @muddyfish ... I posted this answer without double-checking. I updated the examples. – FliiFe Apr 11 '16 at 17:30
• @muddyfish To answer your question, a(0) is the first term of the sequence. I'm not sure if that's what you wanted to know, but at least you know that. – FliiFe Apr 11 '16 at 17:32
• – Adnan Apr 11 '16 at 18:31

# Molecule (v5.5), 25 bytes (UTF-8)

"ᘰᜟᘄఄሳÝ̲"Cn


No characters are hidden here ;)
An input of 0 is allowed.

Output of 1: 16
Output of 2: 21

• You need to hide some characters to make it a valid submission – TuxCrafting Oct 22 '16 at 21:37
• The worst thing: It's safe xD – TuxCrafting Oct 22 '16 at 21:37

## Python, 42 bytes Cracked

def f(x):return # if x<#else ######+######


Where

f(0) -> 0
f(1) -> 1
f(7) -> 13
f(15) -> 610

• Cracked. – Dennis Oct 4 '16 at 15:40

# PHP, 118 Bytes, Safe

I hope that I'm understand the rules right

function f($n){for($a=[],$i=0,$n++;$n!=@@@@@@($a);$i++)if(@@@@@@@)if(@@@@@@@@(@@@@@@@@@@@@@@))$a[]=$i;return end($a);}

echo f(6); # 16
echo f(13);# 32
echo f(0); #2
echo f(1); #4
echo f(54); #128


Original code

function f($n){ for($a=[],$i=0,$n++;$n!=sizeof($a);$i++){ if($t=$i%7)if(in_array($t,array(2,4,6)))$a[]=$i;
}
return end(\$a);
}
`

generates this sequence