# Solving Secret Swapping Sequences

This is a challenge, the cops thread can be found here.

This is the robbers thread, your job here is to take submissions on the cops thread and try to find the hidden sequences. If you find any sequence that can be substituted into the original code to compute that sequence that is a valid crack. Please notify the cops of your cracks as they happen so they can update their answers.

## Scoring

Your score will be the number of successful cracks you have made, with more cracks being better.

• Why not just let robbers comment the sequence # in the cops thread? – Lynn Aug 3 '17 at 16:08
• @Lynn I think that robbers should be able to get upvotes for their work in cracking answers. I prefer the two thread format for that reason. – Wheat Wizard Aug 3 '17 at 16:09

# Japt, Shaggy, A000290

p#A000290uCnG


Try it online!

# Python 3: Mr. Xcoder, A010709

n=int(input())
print(sum(1for i in"A010709"if i>"0")*-~n//-~n)


Try it online!

Additionally, here's a golfed version of the original. :P

lambda n:sum(1for i in"A017016"if i>"0")*-~n//-~n

• Well done... I knew it would be cracked soon – Mr. Xcoder Aug 3 '17 at 15:14

# Python 3, pppery

A018226

The original code put the sequence name in a comment. Since the comment probably can't affect the code I figured the hidden sequence had to be some sub-sequence of the original. A quick search of the first couple terms brought up A018226. Since it is a sub-sequence the code works for both. A018226 is even listed on the original sequence's page if you look back

One way to generalize the magic number sequence in A018226.

• That was the intended solution. I had the idea of trying to make people think it was impossible by putting the sequence in a comment. – pppery Aug 3 '17 at 18:17
• @ppperry The comment was what gave it away :). I figured it had to be a sub-sequence. Good fun anyway! – Wheat Wizard Aug 3 '17 at 18:18
• Maybe I could have hid that better, but still is an interesting twist compared to the typical answers to this sort of thing; about numbers, rather than code. – pppery Aug 3 '17 at 18:20

# C#, TheLethalCoder

A000578 (Cubes)

An easy one - it was also posted here.

• Of course, people should stop posting the answers from the other challenge :) – Mr. Xcoder Aug 3 '17 at 14:50

A000007: The characteristic function of 0: a(n) = 0^n.

# C#, TheLethalCoder, A000244

Also works with A000079 (powers of two).

A000244 (Powers of 3)

This no longer works, the OP updated the example after I posted this.

# dc, Bruce Forte

Cracked with A027480.

• Well done! What gave it away? – ბიმო Aug 4 '17 at 13:42
• The modulus operations limit the number of sequences generated. In this case 8 × 9 = 72. So plugged the formula into a spreadsheet and generated all of them. Only a handful of sequences produced all integers for all terms, and of those made a guess that only sequences with all positive terms would be of interest. Then it was a matter of searching the sequences and plugging the reference number back in. Searched five, three had corresponding entries, the third one matched outputs for all inputs. – user15259 Aug 4 '17 at 14:01
• If only I had not divided by 2 ;P – ბიმო Aug 4 '17 at 14:13

# Python 2: officialaimm, A055642

lambda x:len(x**(sum(map(int,'A055642'[1:]))==22))


Try it online!

It took me a while to find the sequence... Mostly 'cause OEIS search is super slow for me. o0

• Nicely done. (y) – officialaimm Aug 3 '17 at 17:29

# Python 3, ppperry, A000027 -> A004526

f=lambda a,n=((int("A004526",11)-0x103519a)%100%30+1)/2:a//(14-n)


Try it online! (prints first few terms of both. Note the two sequences have offsets of 1 and 0 respectively, so the first has a leading zero - it threw me a little!)

Cracked with A055642.

# Python 3.6, RootTwo

Original is A005843
Cracked with A001107

Try it online

The eval'd code of the original (minus comments) is n*2, of the cracked version is 4*n*n-n*3.

After filtering out syntax errors, undeclared variables, zero divisions, etc, it didn't take too long to run through the remaining list. There were a few false positives (like A004917) that I had to filter out by hand due to only checking the first few numbers, but it wasn't too common.

Also, A040489 tries to calculate n**3436485154-n, which slowed me down a bit. :P

• Congrats. That's it. Did you brute force it? I tried to make a few incorrect sequence ID's result in valid Python to slow things down, but not enough I guess. – RootTwo Aug 10 '17 at 3:38
• @RootTwo I did mostly brute force it. I had some other heuristics in there too, but nothing very complex. Took a couple mins to find 1107, about 8 to get up to 5843. Out of curiousity, I went up to 50000. No other matches in that range. I'd guess 15-20% were valid python. – Phlarx Aug 10 '17 at 4:04

# Chip, Phlarx

Cracked with A060843. On a hunch, guessed the sequence was going to be short!

• You got it! Good job – Phlarx Aug 10 '17 at 4:06