# 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

# Reng v.3.3, 36 bytes. Cracked, A005449

Output:

a(1) = 2
a(3) = 15


# denotes a gone character. There are no other #s in the program.

i#:#+##-##)####¡#~
##########!</div>


Alright this is the last one for a while. Other people need to answer >_>. A description of each character can be found in the source code, where all the ops are defined. A comment proceeds each operator.

Original code:

i>:1+(1-?v)v/a+¡n~
~^<$:$:$:>!</div>  • Cracked. – Leaky Nun Apr 9 '16 at 5:52 • What is the original sequence? – Leaky Nun Apr 10 '16 at 0:06 • +1 for </div>, an HTML tag that strangely appeared in this code. I like finding out secrets like this. :-P – user48538 Apr 17 '16 at 13:17 • @zyabin101 XD Thanks! I put it there as a red herring. – Conor O'Brien Apr 17 '16 at 18:36 # J, 8 bytes, cracked # marks unrevealed characters (##-#)#.  ### Output: No, I'm not hiding anything by using a long sample. If the input is 0, it outputs 0, if the input is between 1 and 29, it outputs 1. The outputs for the negative inputs do not match with the actual sequence.  (##-#)#.0 0 (##-#)#.1 1 (##-#)#.2 1 (##-#)#.3 1 (##-#)#.4 1 (##-#)#.5 1 (##-#)#.6 1 (##-#)#.7 1 (##-#)#.8 1 (##-#)#.9 1 (##-#)#.10 1 (##-#)#.11 1 (##-#)#.12 1 (##-#)#.13 1 (##-#)#.14 1 (##-#)#.15 1 (##-#)#.16 1 (##-#)#.17 1 (##-#)#.18 1 (##-#)#.19 1 (##-#)#.20 1 (##-#)#.21 1 (##-#)#.22 1 (##-#)#.23 1 (##-#)#.24 1 (##-#)#.25 1 (##-#)#.26 1 (##-#)#.27 1 (##-#)#.28 1 (##-#)#.29 1  # JavaScript ES6, 119 bytes, Cracked. Output: a(0) = 0 a(5) = 10000  Code: x=>##=#=>[[[##x####r(###f#n###;#####n####h.##w###<1##].c####t.##pl##[####nc#######y([###(###(#]###)#############h####  Returns an anonymous function. Original sequence: A016744. Original code: x=>{f=n=>[[[1,x] for(x of n)]];return Math.pow(x<<1,[].concat.apply([].concat.apply([],f(f(f([]))))).join.length)}//  I need to show more characters of obsfucated code next time :P • Cracked. I wasn't sure which sequence you were going for though, so I had to just choose the easiest one then ignore the rest of the characters. :( – user81655 Apr 10 '16 at 6:52 # 05AB1E, 5 bytes, cracked ##s##  # indicates a hidden character. Output: a(4) = 8 a(6) = 144  The sequence starts at a(1). The original code was exactly as in @Adnan's answer to robbers' thread. • My first 05AB1E submission! – Luis Mendo Apr 10 '16 at 3:26 • Wow! I'm glad to see this :) – Adnan Apr 10 '16 at 8:22 • – Adnan Apr 10 '16 at 8:48 • @Adnan I thought it would last longer :-) Can sequences in OEIS be searched for specific terms? – Luis Mendo Apr 10 '16 at 11:38 • @Adnan I think you could avoid copyright law infringement by first making a first search on oeis (preformated), and then let the script choose which one respects the indexes – FliiFe Apr 11 '16 at 12:18 # Jolf, 13 bytes, safe! Outputs: a(5) = 40 a(8) = 128  Code: #+~##~####xx#  Revealed: OEIS A003600 γ+~iu~iZCzxxγγ γ = zx range 1..x (input) ZC cumulutive sum ~i identity u sum of ~i identity + x plus x γ out γ • Ooh, Jolf. I'm gonna have a crack at this one. Please don't steal it, Kenny. – Fund Monica's Lawsuit Apr 10 '16 at 4:04 • @QPaysTaxes Any luck? :3 – Conor O'Brien Apr 10 '16 at 15:37 • I might've had some of you didn't have undocumented functions everywhere :P. As it is, I've got two candidates for the sequence, and some idea of how to make them, but it's a pain in the butt :P – Fund Monica's Lawsuit Apr 10 '16 at 16:36 • @QPaysTaxes I don't think this code uses any undocumented features. – Conor O'Brien Apr 10 '16 at 16:37 • But they still make reading the source hard. Anyway, I'm just complaining. Feel free to ignore me. – Fund Monica's Lawsuit Apr 10 '16 at 16:38 # Jolf, 16 bytes, safe! Outputs: a(0) = 0 a(4) = -2 a(51) = 26  Code: #.‘###4#x##32#mA  Revealed: Sequence: A001057, the canonical enumeration of integers.*.‘01m4zx’m32xmA ‘ ’ an array 0 0: 0 1 1: 1 m4zx antisum of range 1..x (1 - 2 - 3 - 4 - ... - x) . m32x get min(2, x) of that array* mA multiply that entry by the sign of x (implicit input); is zero when zero # 05AB1E, 28 bytes (Cracked) #D>D>D>D>*##*#D<*#+*#n#n#**#  a(1) = 1 a(2) = 8 a(3) = 42 Behaviour for zero is unspecified. Cracked:  DD>D>D>D>****rD<*6+*6n2n5**/  There is no need for an explanation I think as the crack was almost 100% spot on. The only difference is I used r to reverse stack instead of swapping top two elements. • Cracked – Emigna Apr 14 '16 at 12:38 ## 05AB1E, 10 bytes, Cracked ##3##1+*1+  0-indexed. 0 ==> 1 4 ==> 61 5 ==> 91 9 ==> 271  Original Program: UX3*X1+*1+ • Cracked – Emigna May 15 '16 at 8:41 ## S.I.L.O.S, 37 bytes (Cracked.) ### Code: readIO #=# #+# #*# #*# #+# printInt i  #s are the hidden characters. ### Output: a(0) = 1 a(4) = 41 a(9) = 181  • Cracked – Emigna Oct 20 '16 at 9:18 # J, 7 bytes, cracked Output: a(0) = 6 a(2) = 27  Code (I have shown more for added difficulty): #+#:###  Is a tacit verb. • Cracked. – Dennis Apr 9 '16 at 2:57 ## Python 2, 87 bytes, cracked n=input() ##################################################################### print _  Output: a(5) = 2 a(10) = 2 a(15) = 1 a(20) = 1 a(25) = 1  I really should have checked for other sequences before I posted, here's another one that works (A014709): n=input() g=lambda n:~n%2*(n/2%2+1)or g(n/2);_=g(n)############################ print _  # Jolf, 3 bytes Cracked, A001477 ___  Examples: 0 -> 0 1 -> 1 4 -> 4 9 -> 9  Original Code:  "%"  # PHP, 18 bytes, cracked Here's a very short one, at least in terms of PHP. I wonder if it survives this Sunday the next thirty minutes. Output a(0) = -1 a(1) = 0  Source ____$____[1]+_+_0;
#### ####    # #


Notes

Cracked

The sequence was A023443:

a(n) = n - 1

Here's my original source code, which is slightly different to the robber's:

echo$argv[1]+-+!0; # J, 8 bytes (Cracked) # marks unrevealed characters (#1-#)#.  ### The output: No, I'm not hiding anything by using a long sample. If the input is 0, it outputs 0, if the input is between 1 and 29, it outputs 1. The outputs for the negative inputs do not match with the actual sequence.  (#1-#)#.0 0 (#1-#)#.1 1 (#1-#)#.2 1 (#1-#)#.3 1 (#1-#)#.4 1 (#1-#)#.5 1 (#1-#)#.6 1 (#1-#)#.7 1 (#1-#)#.8 1 (#1-#)#.9 1 (#1-#)#.10 1 (#1-#)#.11 1 (#1-#)#.12 1 (#1-#)#.13 1 (#1-#)#.14 1 (#1-#)#.15 1 (#1-#)#.16 1 (#1-#)#.17 1 (#1-#)#.18 1 (#1-#)#.19 1 (#1-#)#.20 1 (#1-#)#.21 1 (#1-#)#.22 1 (#1-#)#.23 1 (#1-#)#.24 1 (#1-#)#.25 1 (#1-#)#.26 1 (#1-#)#.27 1 (#1-#)#.28 1 (#1-#)#.29 1  • Are you sure it's a function, so ((#1-#)#.)1 also works? – jimmy23013 Apr 10 '16 at 9:58 • ((#1-#)#.)1 works. – Leaky Nun Apr 10 '16 at 10:09 • Cracked. – Zgarb Apr 10 '16 at 20:39 # PHP, 137 bytes, cracked This is my final sequence. You should be feeling lucky when trying this one. Output a(3) = 7 a(7) = 21 a(23) = 99  Source for(___range___303_______________________array_merge____)for(__________________________________________)unset________;echo___$argv[1]-1_;
###     ###   #######################           ####     ##########################################      ########     ###          #


Notes

• This sequence starts at 1.
• The program works up to the last number given bei OEIS, but can easily be adjusted to go to any other value as well.
• It's a full program, not a function.
• Reads the input from command line (obviously).
• Does not contain any PHP opening tag.

Cracked

The wording "feeling lucky" and the value 303 in the source were hints to the sequence A000959:

Lucky numbers

This is my original source, which is slightly different to the robber's:

for($n=range(1,303);$j<count($n);++$j,$n=array_merge($n))for($i=($x=$j?$n[$j]:2)-1;isset($n[$i]);$i+=$x)unset($n[$i]);echo$n[$argv[1]-1]; # Ruby, 11 bytes, cracked Code: ->i{######}  Output: f(0) = 0 f(1) = 0 f(2) = 0 f(3) = 1 f(4) = 0 f(5) = 0 f(6) = 0 f(7) = 1 f(8) = 0 f(9) = 0 f(10) = 0 f(11) = 1 f(12) = 0 f(13) = 0 f(14) = 0 f(15) = 1  And so on, forming A011765. Curious to see if there's more than one way to do this in 6 bytes. • Cracked? – Martin Ender Apr 11 '16 at 20:13 • What was the intended solution then? :) – Martin Ender Apr 11 '16 at 20:27 • Was being cagey since there might be a way to salvage the trick, but I've added it to the solution thread. – histocrat Apr 11 '16 at 20:29 • Here it is in 6 bytes in bc: !++x%4 – user53101 Apr 18 '16 at 1:53 # Python, 123 bytes, Cracked Probably not winning any prizes, but fun nonetheless. # marks a hidden character, it is not used anywhere in the code. def #(#): if n<2: return n else: return #(n-1)+#(n-2) def g(n): ######: return n else: return (#(n##)+#(##2))###  Sample cases: g(1) -> 1 g(6) -> 8 g(10) -> 7  My sequence was A089911, Fibonacci Numbers mod 12. Original code: def f(n): if n<2: return n else: return f(n-1)+f(n-2) def g(n): if n<2: return n else: return (f(n-1)+f(n-2))%12  • – Adnan Apr 12 '16 at 12:02 ## Haskell, 51 bytes (Cracked) Outputs: f 0 -> 0 f 1 -> 1 f 2 -> 1 f 3 -> 0 f 4 -> 0 f 5 -> 3 f 6 -> 5  Code: f e=sum[#########$#####(f######=#####e####)#######]


This defines a function named f, with # as the wildcard character. Shouldn't bee too hard to crack.

• my guess – nimi Apr 11 '16 at 23:37
• @nimi That is exactly identical to my reference answer. I'll edit it here later. – Zgarb Apr 13 '16 at 2:03

# Javascript, 30 bytes, Cracked

# marks unrevealed characters.

n=>M###.##w(n#!#[#+!#[#)-(n##)

Examples:

0 -> 1
1 -> 1
7 -> 43
18 -> 307


Original Code:

n=>Math.pow(n,!+[]+!+[])-(n-1)


# R 64 bytes

Code

##########################
a=function(x)sum(x*3,1,a(x-2):a(x-1))


Output

a(1) =1
a(2) =1
a(3) =2
a(4) =3
a(5) =5
a(6) =8
a(7) =13
a(8) =21
a(9) =34
a(10)=55
a(11)=89
a(12)=144
a(13)=233
a(14)=377
a(15)=610
a(16)=987
a(17)=1597
a(18)=2584
a(19)=4181
a(20)=6765


Simply, Fibonnaci sequence.

Hope it's fun enough.

# Jolf, 3 bytes, cracked

Output:

a(0)  =      0
a(4)  =    260
a(10) =  10010
a(23) = 279864


Code:

###


All these features are documented. Yeah, you don't get any parts of the code :P The sequence is off-by-one.

Original:

+ΤQ

• Cracked. – Martin Ender Apr 17 '16 at 20:46
• Ah, I thought you might be using T because you added it to the docs just before you posted the answer, but I didn't consider combining it with Q. – Martin Ender Apr 17 '16 at 21:09
• @MartinBüttner Was it that obvious? XD Nice job, anyhow! Thanks for using Jolf! :D – Conor O'Brien Apr 17 '16 at 21:10

# MATL, 10 bytes, safe!

2*##n##qn-


Starts at 1, # are hidden characters. Sample input/output:

a(3)=1
a(8)=2


Revealed

The sequence is the number of primes between n and 2*n. The code used was 2*ZqnGZqn-. This takes implicit input, doubles it, and finds the number of primes less than that number, pushes the input again and finds the number of primes less than that, and then subtracts the two lengths from each other.

• I was close with 2*_VnGYqn- (number of decimal figures in 2*input). But that doesn't seem to be an OEIS sequence – Luis Mendo Apr 17 '16 at 23:36
• I'm really surprised you haven't got it! I wan't thinking of anything like that sequence though. The G is correct though..... – David Apr 17 '16 at 23:40

# C++, 55 bytes (Safe)

This one should be easy...

### source:

bool f(int###########;##r#;r###&1#####+######r######r;}


### Output:

f(1)=>0
f(2)=>1
f(3)=>1
f(4)=>0
f(5)=>1
f(6)=>0
f(7)=>1
f(8)=>0
f(9)=>0
f(10)=>0
f(11)=>1


Sequence:

A010051 (Characteristic function of primes: 1 if n is prime else 0.)

code:

bool f(int r){int i=2;for(;r%i&&1-r;i++);return i ==r;}

• I am curious, what is the solution? – mIllIbyte Apr 20 '16 at 7:52
• @mIllIbyte my solution is posted – MegaTom Apr 20 '16 at 13:51
• No obscure language features at all, it's just optimized. Neat! – mIllIbyte Apr 21 '16 at 15:15

# 05AB1E, 4 bytes, cracked

Outputs:

a(0) = 1
a(2) = 4
a(10) = 4444


Code:

____


_ indicates an obfuscated character. Try it online!.

• Easy to find. Easy to implement. Hard to optimize to 4 bytes (stuck at 6 atm). Nice challenge! – Emigna Apr 20 '16 at 11:34
• @Emigna Yeah, that's probably going to be the hardest part. I think I know what your current 6 byte solution is, so my tip is that there are 1 byte commands which can replace 2-byte combinations in your code (and there are two of them). Good luck though :) – Adnan Apr 20 '16 at 20:22
• Cracked I never understood was Â did when I read the spec. Should have just looked at the code. Pretty sure I tried F earlier, but I must have done something wrong. My favorite cop this far :) – Emigna Apr 21 '16 at 9:03
• @Emigna Yeah, I might have to make the docs a bit more specific. Great job in cracking though :). – Adnan Apr 21 '16 at 19:02

## Seriously, 16 bytes (safe)

???"Xi"?≈$?,?R??  Examples: a(3) = 1 a(40) = 4  This sequence starts at a(1). Sequence: http://oeis.org/A001222 (prime divisors of n with multiplicity) Code: ΣM£"Xi"w≈$X,QR£ƒ

Explanation:

The neat thing about this code (and the reason why it's difficult to crack) is that the actual divisor-counting part is reversed. Going through the code, everything up until the , doesn't actually do anything when executed left-to-right (except for pushing "Xi" and then subsequently popping it). ,QR£ƒ reads in the input (n) and executes the code reversed (Q pushes the source code, R reverses it, and £ƒ calls it). Now, the stack contains n and the code is ƒ£RQ,X$≈w"iX"£MΣ. The first 3 commands (ƒ£R) do nothing with an integer on the stack. Q pushes the source code (again), , does nothing because the input is exhausted, and X gets rid of the Q result. $≈ converts the input to a string and back to an int (necessary in the reversed code to prevent unwanted stack items). w pushes a list of [prime, exponent] pairs for all the prime factors of n, and iX"£MΣ sums up all of the exponents.

## Seriously, 14 bytes (Safe)

,???D*≈@??D*≈-


The ?s denote the hidden code. This sequence starts at a(0).

Output:

a(0) = 1
a(1) = 0
a(3) = 1


## Solution:

The sequence is:

A005614 (the infinite Fibonacci word)

My solution:

,;uφD*≈@⌐φD*≈-

The solution is a straightforward implementation of the formula found on the OEIS page (with an error corrected so that the sequence starts at n=0 like the page shows, rather than n=1).

• I'm assuming your sequence starts at 0. – Fund Monica's Lawsuit Apr 11 '16 at 4:38
• @QPaysTaxes Given that the first sample output is a(0), that's a safe assumption :) – Mego Apr 11 '16 at 4:43
• No, I mean that either a(-1) is undefined or not listed on OEIS. – Fund Monica's Lawsuit Apr 11 '16 at 4:44
• @QPaysTaxes You are correct. – Mego Apr 11 '16 at 4:50

## 05AB1E, 3 bytes, Cracked

Output:

a(4) = 4
a(6) = 7


Code:

___


_ (underscore) indicates an obfuscated character

Try it online

• Cracked :) – Adnan Apr 25 '16 at 18:06
• @Adnan: Oh come on! Not even 1h :) – Emigna Apr 25 '16 at 18:12
• Hahaha, sorry. I always get excited when I see someone else post in 05AB1E :). – Adnan Apr 25 '16 at 18:16

## LiveCode, 35 bytes, cracked

_un_t_on oeis _
___u___n__
En__oeis


oeis (2)==2

oeis (0)==0

• Cracked – Emigna Apr 27 '16 at 6:24

## Python, 37 bytes, cracked

def a(n):
return ______!______n____*_


a(2)==4 a(4)==16

• Cracked – Emigna Apr 27 '16 at 7:13

## 05AB1E, 8 bytes, Cracked

Output:

a(3) = 2
a(4) = 7


Code:

___s_r__


_ (underscore) indicates an obfuscated character

Try it online

Original Code:

ÑDgsrG^


Which is the sequence A178910 (Binary XOR of divisors of n.)

• – Adnan Apr 28 '16 at 23:09