38
\$\begingroup\$

This is the cops' thread. The robbers' thread goes here.

The last thread was already 4 months ago.

The cop's task

  • 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

The robber's task

  • 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.

Your score is the number of bytes in your code.

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.

\$\endgroup\$
21
  • 2
    \$\begingroup\$ Also, OEIS search can have blanks with _, fyi \$\endgroup\$
    – Sp3000
    Commented Apr 9, 2016 at 0:59
  • 9
    \$\begingroup\$ 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 \$\endgroup\$ Commented Apr 9, 2016 at 2:37
  • 6
    \$\begingroup\$ 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) \$\endgroup\$
    – Sp3000
    Commented Apr 9, 2016 at 6:36
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – user45941
    Commented Apr 9, 2016 at 6:38
  • 3
    \$\begingroup\$ "Intolerant towards zero" makes no sense. What is that supposed to mean? \$\endgroup\$
    – feersum
    Commented Apr 10, 2016 at 23:28

75 Answers 75

11
\$\begingroup\$

Vim, 36 keystrokes -- Safe!

i****<esc>:let @q="^*i****$**@***"<cr><n>@qbD

(Note: <n> is where you type your input)

Here is the code unrelated to number generation:

          :let @q="              "<cr><n>@qbD

Meaning I am revealing 5 out of 19 characters.

<n> is the input. Here are some sample outputs:

1@q:    1
2@q:    3
6@q:    18

Answer

This code prints The Lucas Numbers (A000032), which are just like The Fibonnaci Sequence, except that it starts on 2, 1 instead of 1, 1. Here are the first 15 numbers:

2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843

Here's the revealed code:

i2 1 <esc>:let @q="^diwwyw$pb@-<c-v><c-a>"<cr><n>@qbD

Explanation:

i2 1 <esc>                          "Insert the starting numbers
          :let @q="....."<cr>       "Define the macro 'Q'

Explanation of the macro:

^                      "Move to the first non-whitespace character on the line.
 diw                   "(d)elete (i)nner (w)ord. This is different then 'dw' because it doesn't grab the space. 
                      "It also throws people off since 'i' is usually used for inserting text.
    wyw$               "Move to the next number, yank it then move to the end of the line 
        pb             "(p)aste the yanked text and move (b)ack
          @-     <c-a> "@- is the register holding the word we deleted. Increment the current number that many times.
            <c-v>      "Since we're adding <c-a> this from the command line, we need to type it as a literal.

Now, we just need to remove the second number, since the first number is the lucas number we want. So we do

b   "move (b)ack
 D  "(D)elete to the end of the line.

Also, if I'm not mistaken, this is the first safe submission! That's kinda cool.

\$\endgroup\$
4
  • \$\begingroup\$ I know the sequence, I think. I just don't know how to turn it into Vim keystrokes. \$\endgroup\$
    – anon
    Commented Apr 9, 2016 at 6:54
  • \$\begingroup\$ Is the output just the number or the entire line? \$\endgroup\$ Commented Apr 11, 2016 at 20:51
  • \$\begingroup\$ @ASCIIThenANSI After hitting bD at the end, the output is just the one number and some extra whitespace. \$\endgroup\$
    – DJMcMayhem
    Commented Apr 11, 2016 at 20:58
  • \$\begingroup\$ I got the sequence right! \$\endgroup\$
    – anon
    Commented Apr 16, 2016 at 4:58
8
\$\begingroup\$

05AB1E, 5 bytes, safe

Last one for today :p. Output:

a(0) = 9
a(5) = 4
a(10) = 89

Code:

___m_

Obfuscated characters are indicated with _. Try it online!-link. Uses CP-1252 encoding.


Solution:

žhžm‡

Explanation:

žh       # Short for [0-9].
  žm     # Short for [9-0].
    ‡    # Translate.

Try it online! or Try for all test cases!.

\$\endgroup\$
4
  • \$\begingroup\$ I know the sequence, just not how to generate it in so few bytes... \$\endgroup\$ Commented Apr 9, 2016 at 20:26
  • \$\begingroup\$ @LegionMammal978 Yes, I think that is going to be the hardest part of this one. \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 20:57
  • \$\begingroup\$ I can get it in 5 bytes with g°<¹- but I can't figure out any way to use m at this size! D: \$\endgroup\$
    – user81655
    Commented Apr 11, 2016 at 0:42
  • \$\begingroup\$ @user81655 Yes, that was the alternative solution :). \$\endgroup\$
    – Adnan
    Commented Apr 11, 2016 at 4:39
6
\$\begingroup\$

Element, 7 bytes, cracked

Output:

a(3) = 111
a(7) = 1111111

The # are hidden characters, and they are all printable ASCII. I think this one is actually reasonably difficult (for only having 5 missing characters).

###,##}

For convenience, here's the Try It Online and Esolang wiki pages.


My original program was:

_'[,$`}

The trick is that

] and } are functionally identical (both translate to } in Perl). Also, I used ,$ to produce a 1 as an additional layer of confusion, although it is possible to ignore the , completely by doing ,1 instead.

\$\endgroup\$
6
  • \$\begingroup\$ (I know I shouldn't ask this, but) are you sure that it is correct? In particular, } instead of ]? \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 5:18
  • \$\begingroup\$ @KennyLau The } is correct, and my program (as far as I know) works in every version of Element. \$\endgroup\$
    – PhiNotPi
    Commented Apr 9, 2016 at 5:20
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 6:07
  • \$\begingroup\$ I think the formatting is wrong in your original code? \$\endgroup\$
    – Riker
    Commented Apr 9, 2016 at 21:46
  • \$\begingroup\$ @EasterlyIrk It is. If you know how to fix it, be my guest. \$\endgroup\$
    – PhiNotPi
    Commented Apr 9, 2016 at 21:55
5
\$\begingroup\$

Jolf, 5 bytes, cracked

Output:

a(2) = 8
a(10) = 4738245926336

All of it is crucial, and I have shown 1 of 5.

####x

Original code:

mPm$x
mP     cube
  m$   catalan number
    x  input

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Cracked! \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 1:33
  • 1
    \$\begingroup\$ For anyone interested, it's this sequence: oeis.org/A033536 \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 1:34
5
+100
\$\begingroup\$

JavaScript (ES7), 10 bytes, Cracked

Output

f(0) -> 1
f(1) -> -1

Code

t=>~t##**#

Test it in Firefox nightly. The code is an anonymous function. This will probably be easy since there's only three characters hidden, but at least it's short! :P


My original code was:

t=>~top**t

but after brute-forcing my own code for a solution, I soon realised

t=>~t.x**t (where x can be any variable name character)

could also be used. This works because

in the original ES7 exponentiation operator spec, the operator had lower precedence than unary operators (unlike conventional mathematics and most other languages). ~ performs a bitwise NOT on t.x (undefined) or top (Object) which casts them to a 32-bit signed integer (uncastables like these become 0) before doing the NOT (so 0 becomes -1). I looked into further into this, and very recently, the spec has changed to disallow ambiguous references like this (not good for future golfing D: ), however most ES7 engines haven't updated to the latest version of the spec yet.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ @insertusernamehere It seems to think it contains an illegal expression. It does work in Firefox nightly though. I guess they implement the ES7 spec differently. \$\endgroup\$
    – user81655
    Commented Apr 13, 2016 at 9:33
  • \$\begingroup\$ I just got Firefox nightly, and I must complain that this does not work there. 32-bit windows from here \$\endgroup\$ Commented Apr 13, 2016 at 21:11
  • \$\begingroup\$ Assuming ** is equivalent to Math.pow, I have done some of my own testing, and even run a brute force. This is quite hard to crack! \$\endgroup\$ Commented Apr 13, 2016 at 21:42
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ My Firefox nightly is up to date as of yesterday. I'm using OS X but I'm quite sure it will work in Windows also. Traceur with appropriate ES7 options enabled transpiles it correctly too. \$\endgroup\$
    – user81655
    Commented Apr 13, 2016 at 22:30
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Just tried it in 32-bit Windows from your link and it works also. I'm surprised your brute force search couldn't crack it. I actually just realised there's many solutions to this! D: \$\endgroup\$
    – user81655
    Commented Apr 13, 2016 at 23:40
4
\$\begingroup\$

05AB1E, 4 bytes (Cracked)

Sample output :

a(5) = 51
a(8) = 257

And for the code :

###^

I revealed the last one. Should be easy enough though, I had quite a hard time finding a sequence :(

All hidden characters are printable.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked! :) \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 9:32
4
\$\begingroup\$

MATL, 5 bytes, cracked

Hidden characters are indicated by %.

%5%*%

Output:

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

Input 0 is valid.


Original code:

35B*s

that is,

35    % push number 35
B     % convert to binary: array [1 0 0 0 1 1]
*     % multiply element-wise by implicit input n: gives [n 0 0 0 n n]
s     % sum of array: gives 3*n
\$\endgroup\$
3
  • 2
    \$\begingroup\$ Hmmm, the five in code is very annoying! \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 12:27
  • \$\begingroup\$ Technically this could be brute-forced by a program... but I won't do that. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 12:37
  • 1
    \$\begingroup\$ cracked \$\endgroup\$
    – flawr
    Commented Apr 9, 2016 at 19:19
4
\$\begingroup\$

SWIFT, 55 bytes, Cracked

func M(n:Int)->Int{
return(n*****) ?M(**n****):n***;
}

* marks a hidden character

Output:

M(30) -> 91
M(60) -> 91
M(90) -> 91
M(120)-> 110
M(150)-> 140

Function accepts 0

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 14, 2016 at 9:45
4
\$\begingroup\$

Ruby, 46 bytes, safe

Edit to add disclaimer/apology: This sequence starts with f[0], while the OEIS entry starts with f[1]. The values are the same.

Obfuscated code (# is any character):

->####or x##1###(#..##0#);x*=3;end;#.###ect:+}

Call like

->####or x##1###(#..##0#);x*=3;end;#.###ect:+}[3] (returns 39)

Output:

f[0] = 0
f[1] = 3
f[2] = 12
f[3] = 39
f[4] = 120
f[5] = 363
f[6] = 1092
f[7] = 3279
f[8] = 9840
f[9] = 29523

Solution:

f=->*x{for x[-1]in(0..x[0]);x*=3;end;x.inject:+}

Sequence:

http://oeis.org/A029858

Explanation:

The minor trick here is that we declare the parameter as *x rather than x. This means that if you pass in 2, x is set to [2]...at first. The major trick exploits bizarre, and justly obscure, Ruby syntax where you can set the iterator in a for loop to any valid left hand side of an assignment expression, instead of an iterator variable like i. So this loops through from 0 to (in this example) 2, assigning each number to x[-1], meaning it overwrites the last value of x. Then the loop body x*=3, further mutates x by concatenating it to itself 3 times. So first x becomes [0], then [0,0,0]. On the next loop it becomes [0,0,1], then [0,0,1,0,0,1,0,0,1]. Finally we pass in 2 and it becomes [0,0,1,0,0,1,0,0,2], then [0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2]. We then sum the result using the inject method, which reduces the array by applying + (the passed in method) to each element in turn. If we consider how each iteration changes the sum, we see that we effectively add 1 (by overwriting the last element with an element one higher), then multiply by 3. Since 3*(n+1) = 3*n + 3, this implements Alexandre Wajnberg's recurrence relation for the sequence as described on the page.

\$\endgroup\$
1
  • \$\begingroup\$ I really like your cops here, this one particularly. Well done. \$\endgroup\$ Commented Apr 13, 2016 at 14:27
3
\$\begingroup\$

05AB1E, 3 bytes, cracked

Output:

a(9) = 165
a(10) = 220

Hidden code:

##O

Try it online might come in handy.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 7:50
3
\$\begingroup\$

Hexagony, 7 bytes, cracked

Output:

a(1) = 2
a(2) = 4

Hidden code:

?#####@

Or alternatively:

 ? #
# # #
 # @

Try it online might come in handy.

\$\endgroup\$
3
  • \$\begingroup\$ Cracked. \$\endgroup\$ Commented Apr 9, 2016 at 8:42
  • \$\begingroup\$ Uhhh wait, does your code work for input 0? \$\endgroup\$ Commented Apr 9, 2016 at 8:44
  • \$\begingroup\$ @MartinBüttner Oh, it doesn't, my bad. Your solution was the right one though. \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 9:03
3
\$\begingroup\$

PHP, 41 bytes, cracked

Yeah, finally another Cops and Robbers challenge. Hope I didn't make it to easy.

Output

a(5)   = 0
a(15)  = 1
a(35)  = 0
a(36)  = 1
a(45)  = 1

Source

____________________$argv[1]____________;
####################        ############

Notes


Cracked

I obviously made it to easy and provided not enough examples. The sequence I had in mind was A010054:

a(n) = 1 if n is a triangular number else 0.

Here's my original source code:

echo(int)($r=sqrt(8*$argv[1]+1))==$r?1:0;

It tests whether the input is a triangular number and outputs 1 or 0 accordingly.

\$\endgroup\$
1
3
\$\begingroup\$

Jolf, 11 bytes, Cracked , A011551

c*______x__

c*mf^+91x~P

Original code:

c*^c"10"x~P

Examples:

0 -> 1

12 -> 1618033988749
\$\endgroup\$
4
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 22:07
  • \$\begingroup\$ @Adnan Good job, though different from mine. And you couldn't figure out first op. :P \$\endgroup\$
    – Riker
    Commented Apr 9, 2016 at 22:17
  • \$\begingroup\$ Yeah, I couldn't figure out what it does :p \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 22:30
  • \$\begingroup\$ @Adnan it was a cast to int function, misused as a floor one. \$\endgroup\$
    – Riker
    Commented Apr 9, 2016 at 23:02
3
\$\begingroup\$

MATL, 9 bytes, Cracked

Code:

3#2###*##

Output:

a(1)  = 3
a(2)  = 6
a(4)  = 12
a(12) = 37

a(0) is valid.


Cracked

Original sequence: A059563

Original code:

3L2^Ze*sk
3L          % Push [1 -1j] from the clipboard
  2^        % square
    Ze      % exp
      *     % times input
       s    % sum
        k   % floor
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 22:55
3
\$\begingroup\$

Java, 479 bytes, Cracked

Outputs:

a(10) = 81
a(20) = 35890

(Inputs are provided via command line arguments)

Code (# marks hidden characters):

import java.util.*;
public class A{

    public static int#########
    public boolean###########

    static A a = new A();

    public static void main(String[] args){
        int input = Integer.parseInt(args[0]);

        LinkedList<Integer> l = new LinkedList<>();
        l.add(1);
        l.add(0);
        l.add(0);

        for(int ix = 0; ################if(##>##{
            ###########d#
            #######+##p##########+##########(#######
        }

        System.out.println(#########################
            ###(A.#############(#5#####)));
    }
}

The program starts at index 0.

(Note that SE replaces all of the \t indents with 4 spaces, bringing the byte total to 569. Click here to see the program with \t indents instead of space indents.)

Original code:

import java.util.*;
public class A{
    public static interface B{
    public boolean C(int i);} 
    
    static A a = new A();
    
    public static void main(String[] args){
        int input = Integer.parseInt(args[0]);
        
        LinkedList<Integer> l = new LinkedList<>();
        l.add(1);
        l.add(0);
        l.add(0);
        
        for(int ix = 0; ix<input; ix++)cif(i->  {
            return l.add(
            l.pop()+l.peekFirst()+l.peekLast());});{    
        }
        
        System.out.println(l.get(1));}static boolean 
            cif(A.B b5){return (b5.C((0)));
    }
}

(Same code, but formatted normally):

import java.util.*;

public class A {
    public static interface B { //functional interface for lambda expression
        public boolean C(int i); //void would have given it away
    }

    static A a = new A(); //distraction

    public static void main(String[] args) {
        int input = Integer.parseInt(args[0]);//Input

        LinkedList<Integer> l = new LinkedList<>();
        l.add(1);//Set up list
        l.add(0);
        l.add(0);

        for (int ix = 0; ix < input; ix++)
            cif(i -> { //Fake if statement is really a lambda expression
                return l.add(l.pop() + l.peekFirst() + l.peekLast());
            });
        { //Distraction
        }

        System.out.println(l.get(1));//Output
    }

    static boolean cif(A.B b5) { //Used to pass in lambda expression.
                  //The A. and b5 were both distractions
        return (b5.C((0)));
    }
}
\$\endgroup\$
17
  • \$\begingroup\$ Hm, how do you come to a byte count of 488? I count 545 from i to }? And please specify 0-tolerance. \$\endgroup\$
    – Vampire
    Commented Apr 9, 2016 at 23:46
  • \$\begingroup\$ Aren't your examples a(9) and a(19) or a(8) and a(18), according to which version of it on OEIS you took? \$\endgroup\$
    – Vampire
    Commented Apr 9, 2016 at 23:54
  • \$\begingroup\$ @BjörnKautler I'll post a link to the byte counter when I get home. What do you mean by 0-tolerance? The first value is a(1) = 0 \$\endgroup\$
    – Daniel M.
    Commented Apr 9, 2016 at 23:55
  • \$\begingroup\$ From the OP: "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." So I guess you take the input 1 as 0 and this also explains the shift in position, according to the OEIS sequence. \$\endgroup\$
    – Vampire
    Commented Apr 9, 2016 at 23:58
  • \$\begingroup\$ @BjörnKautler OK, thanks. The program doesn't crash if 0 is entered but the sequence starts at index 1, so I guess it's zero-intolerant. \$\endgroup\$
    – Daniel M.
    Commented Apr 10, 2016 at 0:02
3
\$\begingroup\$

Octave, 34 bytes, cracked

@(m)(m###m#####m##)&isprime(#)####

Outputs:

ans(1) = 0
ans(6) = 5
ans(7) = 10
ans(8) = 15

The sequence starts at ans(1) in OEIS.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – feersum
    Commented Apr 10, 2016 at 19:45
3
\$\begingroup\$

C, 71 bytes cracked

############
#####
main(){
 scanf("%d",##);
 ###6#;
 printf("%d",##);
}

Output:

a(1) = 0   a(2) = 0   a(5) = 1
a(6) = 1   a(7) = 1   a(9) = 2

This works with gcc, and is a full program. It accepts 0 as input.

\$\endgroup\$
2
3
\$\begingroup\$

Pyth, 70 bytes, Cracked

DhbI|qb"#"qb"#"R!1Iqb"#"#####+""s####2###;##lY+Q1Ih+""Z#####)=Z+Z1;@YQ

# are the hidden characters

Has been cracked, so here is the versionn without hidden chars :

DhbI|qb"4"qb"0"R!1Iqb"1"R!0Rh+""sm^sd2cb1;W<lY+Q1Ih+""Z=Y+YZ)=Z+Z1;@YQ

Sample outputs :

a(2) -> 10
a(4) -> 19

Good luck to find this on OEIS, I personally failed to find it from those examples (even tho the sequence is quite easy to spot.)

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Adnan
    Commented Apr 10, 2016 at 19:39
3
\$\begingroup\$

Ruby, 38 bytes, cracked

Obfuscated code (# can be any character):

->#{(s=#########).sum==#3333&&eval(s)}

Output:

Multiplies the input by 10 (A008592). Works for any integer, including 0. e.g.

->#{(s=#########).sum==#3333&&eval(s)}[3]  => 30
->#{(s=#########).sum==#3333&&eval(s)}[10] => 100
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – xsot
    Commented Apr 12, 2016 at 6:40
3
\$\begingroup\$

05AB1E, 5 bytes, cracked

Output:

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

Obfuscated code:

_____

Try it online!-link.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$
    – jimmy23013
    Commented Apr 12, 2016 at 13:22
3
\$\begingroup\$

05AB1E, 4 bytes, cracked

Well then, I think I'm addicted to CnR's... Obfuscated code (_ indicates a wild card):

____

Sequence:

a(1) = 2
a(4) = 6720

The sequence in OEIS starts at a(1) = 2.

Try it online!-link

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – David
    Commented Apr 13, 2016 at 4:28
3
\$\begingroup\$

Lua, 45 Bytes, Cracked

A small hint:

a(0) will make the program crash :)

Output

a(1)=>0
a(2)=>1

Code

Uses # to hide the code :).

a=function(n)#####n###### and #or ########end

I was using the OEIS A007814, with the following code:

a=function(n)return n%2>0 and 0or 1+a(n/2)end
\$\endgroup\$
2
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Leaky Nun
    Commented Apr 14, 2016 at 9:36
  • \$\begingroup\$ @KennyLau Well done, I've added the OEIS I was thinking to and the intended code, I should have added at least one more output to prevent this to happen :p \$\endgroup\$
    – Katenkyo
    Commented Apr 14, 2016 at 9:42
3
\$\begingroup\$

Pyke, 15 bytes, SAFE

Output

a(2) = 21
a(15) = 17

Revealed code:

#R#D######+##)#

Solution:

OEIS A038822
wR}DSR_Q*L+#P)l
I used a couple of red herrings here by using wR} to generate the number 100 and revealing the character R which is normally used to rotate the stack. I also used #P)l instead of the more simple mPs to count the number of primes in the sequence.

\$\endgroup\$
2
  • \$\begingroup\$ The sequence in question starts from n=1 not n=0 by the way \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 11:09
  • \$\begingroup\$ I thought it was that sequence, except it starts at n=0 and not n=1 as you've stated. \$\endgroup\$
    – Emigna
    Commented Apr 18, 2016 at 11:07
3
\$\begingroup\$

C, 82 bytes, safe

####=############
main(i){scanf("%d",##);
for(i=1;i++/4<#;)##=2;
printf("%d",##);}

Works with gcc, and it is a full program, which reads its input from stdin and prints its output to stdout. Here the sequence is A004526, floor(n/2).

a(0) = 0    a(1) = 0    a(2) = 1
a(3) = 1    a(4) = 2    a(5) = 2
a(6) = 3    a(7) = 3    a(8) = 4

Solution:

a;*b=(char*)&a+1;
main(i){scanf("%d",&a);
for(i=1;i++/4<2;)a*=2;
printf("%d",*b);}

This works only on little endian machines, and only if the size of char is 1 byte.
And only if the byte higher than the highest order byte of a has value 0. I think this is true for gcc since by default uninitialized global variables go into the bss segment, and initialized global variables go into the data segment (see https://stackoverflow.com/questions/8721475/if-a-global-variable-is-initialized-to-0-will-it-go-to-bss).
So only a goes into bss (the only other global variable b is initialized and thus goes into the data segment). If a is not at the end of bss, then the byte higher than the highest order byte of a is also in bss and thus has value 0.

\$\endgroup\$
3
  • \$\begingroup\$ Try making function calls now :) \$\endgroup\$
    – mIllIbyte
    Commented Apr 11, 2016 at 11:22
  • 1
    \$\begingroup\$ I don't think you had to specify the sequence... \$\endgroup\$
    – THC
    Commented Apr 11, 2016 at 13:35
  • \$\begingroup\$ @FliiFe - Fixed :) \$\endgroup\$
    – mIllIbyte
    Commented Apr 11, 2016 at 13:39
3
\$\begingroup\$

05AB1E, 1 byte, Cracked

_

_ denotes hidden code.

f(1) == 1
f(18) == 6
\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Emigna
    Commented Apr 27, 2016 at 6:11
2
\$\begingroup\$

Element, 10 bytes, cracked

Output:

a(3) = 6561
a(4) = 4294967296

There's probably only a few ways to compute this sequence in Element. I found a 9-char solution, but I figured this 10-char solution is actually more difficult. The # are hidden characters.

#_####@^#`

For convenience, here's the Try It Online and Esolang wiki pages.


The original was

2_3:~2@^^`
\$\endgroup\$
6
  • \$\begingroup\$ Show one more byte. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 3:02
  • \$\begingroup\$ @KennyLau I thought it was 1 out of 5? It's 10 bytes and I'm showing 3. \$\endgroup\$
    – PhiNotPi
    Commented Apr 9, 2016 at 3:03
  • \$\begingroup\$ Inputs and outputs don't count, so you have 8 bytes and you showed 1. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 3:07
  • \$\begingroup\$ @KennyLau done. \$\endgroup\$
    – PhiNotPi
    Commented Apr 9, 2016 at 3:09
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 3:20
2
\$\begingroup\$

Pyth, 18 bytes

# marks unrevealed characters.

L?Jtb##5#m##S#2 #y

Outputs (starts from 1):

1 -> 2
2 -> 3
3 -> 5
4 -> 7

Online interpreter

\$\endgroup\$
3
  • \$\begingroup\$ Primes, no? If not... \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 12:45
  • \$\begingroup\$ If not... what? \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 12:47
  • \$\begingroup\$ then I have no idea \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 12:47
2
\$\begingroup\$

05AB1E, 5 bytes, cracked

I hope that this submission isn't as easy as my other ones :p. Outputs:

a(0) = 0
a(1) = 1
a(2) = 6
a(3) = 24
a(4) = 80
a(5) = 240

Obfuscated code:

####O

Contains some non-ASCII characters though, uses CP-1252 encoding.

Try it online! might come in handy :p.

\$\endgroup\$
3
  • \$\begingroup\$ Cracked. \$\endgroup\$ Commented Apr 9, 2016 at 15:12
  • \$\begingroup\$ Why do I feel like I've seen it before? \$\endgroup\$
    – Leaky Nun
    Commented Apr 9, 2016 at 16:14
  • \$\begingroup\$ @KennyLau ¯\_(ツ)_/¯ \$\endgroup\$
    – Adnan
    Commented Apr 9, 2016 at 16:18
2
\$\begingroup\$

Jolf, 11 bytes, Cracked.

Output:

a(10) = 4
a(20) = 6
a(30) = 8

And the partially hidden code:

####xd###x#

Hint:

When I looked through the sequences in order, I didn't go very far before finding this one.

The cracked version isn't quite the same as my original code. I'm not currently at my computer, so I don't have it exactly, but it was something like this:

l fzxd!m%xH

(The only part I'm unsure about is the !m. It's whatever checks if a variable is zero.)

\$\endgroup\$
6
  • \$\begingroup\$ I found the sequence... Pity I don't know Jolf or javascript very well :( \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 10:57
  • \$\begingroup\$ @muddyfish, Same here... \$\endgroup\$ Commented Apr 9, 2016 at 11:00
  • \$\begingroup\$ Well, I guess it's time for the master to do it... may I? \$\endgroup\$ Commented Apr 9, 2016 at 14:31
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ If everyone else is stumped – and it looks like they are – feel free. \$\endgroup\$
    – anon
    Commented Apr 9, 2016 at 14:32
  • \$\begingroup\$ Cracked. \$\endgroup\$ Commented Apr 9, 2016 at 14:35
2
\$\begingroup\$

Pyke, 6 bytes, Cracked

###X#s

Output:

a(2) = 8
a(8) = 80
a(10) = 120

This doesn't work with N<1

Original solution:

hSmX$s

\$\endgroup\$
2
  • \$\begingroup\$ Welp, I found an easier alternate to what I had \$\endgroup\$
    – Blue
    Commented Apr 9, 2016 at 19:12
  • \$\begingroup\$ Cracked. \$\endgroup\$ Commented Apr 9, 2016 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.