28
\$\begingroup\$

Robbers' Thread

Your challenge is to find an existing challenge, and implement it in a way such that certain inputs fail. At least one input must not produce the correct output (use the other submissions on the challenge as a reference for this, but be sure to double-check). This must fail consistently, and you must know at least one input that fails.

The challenge must satisfy the following:

  • +10 net score
  • Open
  • Not language-specific
  • Posted before 8 Jul 2021
  • Unlocked
  • Not
  • Have at least 3 existing answers

The robbers will be trying to find an input which fails.

You must share the challenge, the language and your code. If a robber has not cracked your solution after a week, it is safe and you can reveal your failing input.

You may specify bounds - for example, you can say that inputs must have less than 20 digits, as long as there is an invalid value within those bounds. You should also say that input is a string/list of numbers/number/tuple/whatever.

Scoring

Your score is the length of your shortest safe program, in bytes, with shorter being better. You are allowed to post multiple submissions.

Here's an SEDE query for valid questions kindly provided by fireflame241.

\$\endgroup\$
8
  • \$\begingroup\$ Related but focused on integer sequences. \$\endgroup\$
    – Arnauld
    Jul 13 at 23:38
  • \$\begingroup\$ Here's a SEDE Query for valid questions. \$\endgroup\$ Jul 13 at 23:46
  • \$\begingroup\$ @fireflame241 Thanks! \$\endgroup\$
    – emanresu A
    Jul 13 at 23:47
  • \$\begingroup\$ Why is this code-challenge and not just code-golf? \$\endgroup\$
    – pxeger
    Jul 14 at 11:39
  • \$\begingroup\$ @Polygorial 8 Jul 2021 was when the question was sandboxed. \$\endgroup\$
    – emanresu A
    Jul 15 at 0:02

21 Answers 21

8
\$\begingroup\$

Python 2, 120 bytes, “DDoouubbllee ssppeeaakk!!”, cracked by Sisyphus

import re
def f(s):
 try:s=re.search('[a-z]{4}|[^a-z()]',s)<0<eval(s)=='hax'or s
 except:0
 return''.join(c*2for c in s)

Try it online!

As in the question, only printable ASCII are allowed as input.

(Guess my password is possibly a better fit for this challenge, ¯\_(ツ)_/¯).


The cracked solution used a Python bug to segfault the program. I'll reveal mine in two days, but before then I'd love to see if anyone can figure out a solution closer to what I had intended.

As an incentive, I'll offer +50 rep to any new answer which cracks this before the two days. In particular, it must not produce an error on the line containing s=..., regardless of whether it gets caught.


No one found my intended solution, so here it is:

max(max(dir()for(hax)in(dir)())), Try it online!

And here is an explanation:

First, let's determine what is expected of us to solve this challenge. We must input a Python expression, such that it evaluates to the string 'hax'. The regex also places two restrictions upon us: only letters and parentheses are allowed, and there can be no consecutive substring consisting of four letters.

These restrictions don't leave us with many options. We're essentially being limited to a small set of builtins (e.g. max, chr), and a few basic constructs like for or and. I've so concluded that most of the obvious approaches are very unlikely to succeed. You may or may not have noticed that the target string, 'hax', exactly matches the regex; this tiny detail is a crucial one.

I've teased you long enough, so let's begin dissecting the solution:
max(max(dir()for(hax)in(dir)()))

Some of the parentheses used here are only to ensure that no spaces exist in our program. Removing the extra obfuscation, we get:
max(max(dir()for hax in dir()))
A lot easier to read!

Within all the maxs, there is a list comprehension, which iterates through dir() using the variable hax. The dir() is completely arbitrary, anything will work as long as we can loop over it. For each iteration in the comprehension, we store the result of dir(). When no arguments are given like this, it returns a list of names in the current local scope (see dir). As a result, the entire comprehension contains [['.0', 'hax'], ['.0', 'hax'], ...] Note that the .0 is a "secret" variable which stores the list comprehension itself.

We are now 90% of the way there! By calling max once on the result, we obtain a single copy: ['.0', 'hax']. Calling it once more, we finally get our result: 'hax'.

\$\endgroup\$
6
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Sisyphus
    Jul 16 at 1:52
  • \$\begingroup\$ Does the intended crack really not require , or .? \$\endgroup\$
    – Bubbler
    Jul 16 at 5:49
  • \$\begingroup\$ @Bubbler Nope, the intended crack makes use of only parens and letters, as you can deduce from the regex. \$\endgroup\$ Jul 16 at 6:06
  • \$\begingroup\$ @dingledooper must the argument be a string? \$\endgroup\$
    – pxeger
    Jul 16 at 8:42
  • \$\begingroup\$ @pxeger Yes indeed, it must be a string of printable ASCII characters. The rules in the original problem are specified as such, so it seems fair that it be enforced here. \$\endgroup\$ Jul 16 at 8:56
7
\$\begingroup\$

Jelly, 7 bytes, Is it double speak?, Cracked by Stephen

ṾḊṖ⁼2/Ạ

Try it online!

Given how difficult Jelly can be to understand, I've provided an explanation to help the Robbers:

ṾḊṖ⁼2/Ạ - Main link. Takes a string L on the left
Ṿ       - Uneval L. This makes sure we're processing a string, as Jelly can
          try to evaluate the input if it's all digits
 ḊṖ     - Dequeue and pop. Remove the quotes that Ṿ puts around the string
    2/  - Split into chunks of 2 (e.g. [A, B]), then over each chunk:
   ⁼    -   Is A equal to B?
      Ạ - Is this true for all A?

Note that this wasn't my intended crack. Another answer incoming

\$\endgroup\$
1
7
\$\begingroup\$

Taxi, 1134 bytes, Draw an asterisk triangle, Cracked by Unrelated String

Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:s 1 l 1 r.Pickup a passenger going to The Underground.'\n'is waiting at Writer's Depot.Go to Writer's Depot:n 5 l 2 l.Pickup a passenger going to Rob's Rest.Go to Rob's Rest:n 1 r 1 r 1 r 1 r.[a]Pickup a passenger going to KonKat's.'*'is waiting at Writer's Depot.Go to Writer's Depot:s 1 l 1 l 1 l 1 l.Pickup a passenger going to KonKat's.Go to KonKat's: n 3 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Rob's Rest.Go to Rob's Rest:s 1 l 1 r 1 r 1 r.0 is waiting at Starchild Numerology.Go to Starchild Numerology:s 1 l 1 r 2 l.Pickup a passenger going to Magic Eight.Go to Post Office:w 1 r 2 r 1 r 1 l.Go to The Underground:n 1 r 1 l.Pickup a passenger going to Cyclone.Go to Cyclone:n 3 l 2 l.Pickup a passenger going to The Underground.Pickup a passenger going to Magic Eight.Go to Magic Eight:s 1 l 2 r.Pickup a passenger going to Riverview Bridge.Go to Riverview Bridge:s 2 l 4 l.Go to Rob's Rest:w 2 l 2 l 1 r 1 r 1 r.Switch to plan "a".

Try it online!

Terminates by error. Prints leading newline (allowed by linked challenge, see comments).

Always fun to bang my head against Taxi's map :D

\$\endgroup\$
3
6
\$\begingroup\$

Jelly, 12 bytes, Make a ;# interpreter, Cracked by Stephen

ṣ”#Ṗċ€”;%Ø⁷Ọ

Try it online!

Since the challenge was first posted, Jelly's had a few updates, including some nice new nilads (127 \$\to\$ Ø⁷) to save a byte :)

\$\endgroup\$
1
6
\$\begingroup\$

Python 3, 252 bytes, Is this number a prime?, cracked by ovs

I=int(input())
L=I<2
l=int('1ecvme02wjate5lzjhukn4elhetiycct0crct68uhrtiafbxxfcmvqjvz',36)
while l:
 i=I;j=J=l&131071;_=1
 while j:
  while~j%2:j>>=1;_*=1|-(i&7in(3,5))
  j,i=i,j;_*=1|-(j&3==i&3>2);j%=i
 L+=pow(J,~-I>>1,I)!=(i<2)*_%I
 l>>=17
print(L<1)

Try it online!

Inputs should be positive integers please. I don't expect this to be cracked (prove me wrong!)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ How could this test primes so fast! Haha \$\endgroup\$
    – justhalf
    Jul 15 at 6:23
  • 5
    \$\begingroup\$ proved you wrong \$\endgroup\$
    – ovs
    Jul 15 at 9:35
5
\$\begingroup\$

Jelly, 6 bytes, Is it double speak?, Cracked by hyper-neutrino

ṾḊṖŒœE

Try it online!

My last answer got cracked due to weird 2/ behaviour, so here's a golfier version. I've got the explanation as well:

ṾḊṖŒœE - Main link. Takes a string L on the left
Ṿ      - Uneval L. This makes sure we're processing a string, as Jelly can
          try to evaluate the input if it's all digits
 ḊṖ    - Dequeue and pop. Remove the quotes that Ṿ puts around the string
   Œœ  - Odd-even. Group the elements at even indices, and those at odd indices
     E - Are they both equal?

(uneval) will surround a string with “...”, which ḊṖ will remove. Unless the string has in it, in which case it will treat each character in the string as a char literal ”x and will join them by commas:

“abc is ”“,”a,”b,”c

\$\endgroup\$
2
5
\$\begingroup\$

JavaScript, 163 bytes, Hello, world!, cracked by Stephen

n=>{if(typeof n=="object"||n-32!=n-32)return "Hello, World!";var d=n-32;return [40,69,76,76,79,12,0,55,79,82,76,68,1].map(x=>String.fromCharCode(n-d+x)).join("")};

Small byte save by offsetting the char codes by 32.

Intended crack:

(() => {
    var f = x => x;
    var i = 0;

    f.valueOf = () => i++ < 2 ? 0 : i;

    return f;
})()

This is a function which will return 0 the first two times it's cast to a number (to bypass the initial checks), then return an incrementing value. It results in an output of Igopt2'_x|wp., instead of the correct one.

\$\endgroup\$
1
4
\$\begingroup\$

Vyxal, 4 bytes, Shortest code to determine if a string is a palindrome, cracked by A username

Ǎ⇩Ḃ=

Try it Online!

Returns 1 for palindromes and 0 for non-palindromes.

The challenge states that numbers affect palindrominess, but as A username pointed out, this ignores numbers.

\$\endgroup\$
1
4
\$\begingroup\$

Vyxal, 4 bytes, Least common multiple

Π?ġ/

Try it Online!

Cracking it should be easy, so no Hints

\$\endgroup\$
3
  • 3
    \$\begingroup\$ Cracked \$\endgroup\$
    – emanresu A
    Jul 14 at 6:18
  • 2
    \$\begingroup\$ Dang, I was so proud of myself to crack this without understanding the language... 10 minutes too late :( \$\endgroup\$
    – pajonk
    Jul 14 at 6:29
  • \$\begingroup\$ @pajonk Oh well. \$\endgroup\$
    – emanresu A
    Jul 14 at 6:38
4
\$\begingroup\$

Python 3, 580 bytes, Simulate a Rubik's cube - Safe!

Not going to win by byte count but maybe it'll make for an enjoyable rob.

import re
exec("d,*r=[[f]*9for f in' YBRGOW'];u,q,v,p,s,w,x,y,z=lambda v:[v[x],y(y(y(v[z]))),v[s],y(v[q]),v[0][::-z],v[p][::-z]],3,lambda w:[y(w[0])]+[w[j%p-~all(s<len(set(f))for f in w)][:q]+w[j][q:]for j in(z,x,q,p)]+[w[s]],4,5,lambda u:[y(u[0])]+u[x:s]+[u[z],y(y(y(u[s])))],2,lambda f:[f[int(v)]for v in'630741852'],1;r="+"(r);r=".join("".join("uuuvu v uuvuu wwwuvuuuw uvuuu wuvuuuwww".split()[778194%ord(t)%9]*(ord(n or'y')%6)for t,n in re.findall("([B-U])(['2i]?)",input())))+"(r);y=' '.join")
for u in[d,r[0]],r[z:s],[d,r[s]]:
 for w in 0,q,6:print(y(y(v[w:w+q])for v in u))

A full program reading a valid move sequence from STDIN that attempts to print the net of a Rubik's cube scrambled as instructed. I'll also specify a bound of 20 face turns :)

Try it online! Or see a few working ones here (the last one places the cube into the Superflip)

Failing inputs

The simulator performs a quarter-turn of a face by rotating the entire cube as need be, turning the cube's "U" face a quarter-turn, and rotating back. To turn the "U" face it permutes the stickers on the face and, separately, the stickers around the "U" face's edge, on the "L", "F", "R", and "B" faces. The latter is performed by concatenating two slices, but the code:
...+[w[j%p-~all(s<len(set(f))for f in w)][:q]+w[j][q:]for j in(z,x,q,p)]+...
should be:
...+[w[j%p+z][:q]+w[j][q:]for j in(z,x,q,p)]+...
...or with less obscured code:
...+ [faces[j%4+1][:3] + faces[j][3:] for j in (1,2,3,4)] +...
i.e:
...+ [first_3_of_previous + last_6_of_current for LFRB] +...

This is only the case when all(s<len(set(f))for f in w) is False (~False = ~0 = -1-0 = -1) or, equivalently, when:
all(5 < len(set(stickers)) for stickers in faces)

Otherwise ~all(...) evaluates to ~True = ~1 = -1-1 = -2 and stickers are copied from the wrong faces for this band (instead of using the first three stickers of each of the FRBL faces to fill the LFRB band it uses the first three stickers of each of the RBDF faces.


Thus, after the cube shows all six colours on every one of its six sides the simulator fails.

An 8-move sequence that achieves such a state is F' B L R' B F R2 D2, so adding one more face turn does it, thus a crack is something like F' B L R' B F R2 D2 U - see that the fourth cube net output here is different to the, correct, third cube net, while the first and second are the same, and show all six colours on all faces prior to the attempted final "U".

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

Vyxal, 17 bytes, Stack Exchange Vote Simulator, Cracked because I misread the challenge

C⁽꘍R:£80>[¥₁-±N|0

Try it Online! Just to start things off. I feel this will get cracked very easily though.

I misread the challenge. My intended crack was an empty string - Vyxal barfs on reducing empty lists/strings.

Input is a string of ^v.

Here's an explanation:

C                 # Charcodes
   R              # Reduced by...
 ⁽꘍               # Bitwise xor
    :£            # Store a copy to register
      80>[        # If it's over 80
          ¥₁-     # Subtract 100
             ±N   # Get the sign negated
               |0 # Else return 0.

Hint: The bug's in Vyxal itself, not my code.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Unless I messed up the inputting, cracked. Are you sure you even read the problem specification correctly though? \$\endgroup\$
    – hyper-neutrino
    Jul 14 at 0:28
3
\$\begingroup\$

Vyxal , 0 bytes, Simple Cat Program, cracked by A username

Try it Online!

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

Python 3, 71 bytes, Convert YYYYMM to MMMYY, cracked by SevC_10

lambda s:" JFMAMJJASONDAEAPAUUUECOENBRRYNLGRTVC"[int(s[4:])::12]+s[2:4]

Try it online!

Probably way too easy, but worth a try.

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

Python 3, 119 bytes, Simple cat program

while 1:
 i=input()
 if 1583454170589139748634332997977758356543730781438558028881854463983253%ord((i+'e')[0]):print(i)

Try it Online!

It's not the prettiest or the shortest, but I'm hoping it at least takes you all a second to figure it out.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – emanresu A
    Jul 14 at 21:17
  • 1
    \$\begingroup\$ Welcome to Code Golf! \$\endgroup\$ Jul 14 at 21:21
  • \$\begingroup\$ @Ausername Wow, not even three minutes... Now that's impressive. :) \$\endgroup\$ Jul 14 at 21:29
2
\$\begingroup\$

Jelly, 15 bytes, Generate Recamán's sequence, cracked by pajonk

ạLṪḟȯ+L$Ṫ;@
Ç¡Ṗ

A full program that accepts a non-negative integer, n and attempts to print the first n terms of the Recamán sequence.

Try it online!

Shouldn't prove at all difficult to crack.


This actually implements A335299, which first differs from Recamán's sequence at \$n=57\$ for which this gives \$27\$ instead of \$87\$ due to the code using the absolute difference instead of (a) performing subtraction and (b) ignoring negative values.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ I got weird output for 1024th term in both of your solutions to that challenge. Comparing to two different answers, they were consistent, so I believe them more :-) \$\endgroup\$
    – pajonk
    Jul 14 at 14:27
  • 1
    \$\begingroup\$ @pajonk Oh, I took a look and found a bug in my original solution so have deleted it. This cop entry still stands (but I'll probably need to fix it to output the first n terms...). \$\endgroup\$ Jul 14 at 15:30
  • 1
    \$\begingroup\$ Fixed up to fit the spec of the linked challenge (to produce the first n terms). \$\endgroup\$ Jul 14 at 15:39
  • 1
    \$\begingroup\$ I still claim 1024 to be the input cracking this entry. \$\endgroup\$
    – pajonk
    Jul 14 at 16:58
  • 1
    \$\begingroup\$ @pajonk in particular, it breaks right around 58 \$\endgroup\$
    – Stephen
    Jul 14 at 16:59
2
\$\begingroup\$

Vyxal, 40 bytes, Find the first word starting with each letter, cracked by EliteDaMyth

kBð\_9ɾṅṠ↔⌈:£ƛh⇩⅛¥ƛh⇩;¼ḟ¥$i=[|¤;;';ðvp∑Ṫ

Try it Online!

I made this while navigating various random bugs. It should work on the current implementation of Vyxal, but may not in the future.

My intended crack: Anything involving zeroes. kBð\_9ɾṅṠ assembles a string, and here's how it works:

kB        # Push lowercase + uppercase alphabet
  ð       # Push space
   \_     # Push underscore
     9ɾṅ  # Push 1-9 - no 0!
        Ṡ # Concatenate all

Then everything not in that is removed, including zeroes.

\$\endgroup\$
3
  • \$\begingroup\$ i dont know vyxal, but i was just trying the test cases from the problem, and seems like the third test case results in maybe some day 1 plus 2 plus 2 could result in 3 instead of maybe some day 1 plus 2 could result in 3, which led me to find out .maybe maybe returns maybe maybe while it should return just maybe \$\endgroup\$ Jul 14 at 9:02
  • 1
    \$\begingroup\$ @EliteDaMyth Nice, you cracked it! \$\endgroup\$
    – emanresu A
    Jul 14 at 9:04
  • 1
    \$\begingroup\$ Yep @EliteDaMyth I found that too just now (without test cases) TIO go for it, post a crack in the robbers thread! \$\endgroup\$ Jul 14 at 9:04
2
\$\begingroup\$

Python 3, 74 bytes, Is this number a prime, cracked by dingledooper

x=int(input())
print(x>1 and next(d for d in range(2,x+1)if x/d==x//d)==x)

Try it online!

\$\endgroup\$
1
2
\$\begingroup\$

JavaScript, 151 bytes, Is this even or odd?, cracked by Bubbler

x=>{var b=[...x.toString(2)].reverse()+"";try{eval.call(window,(t=y=>y?t(y/256n)+String.fromCharCode(Number(y%256n)):"")(x))}catch{};return +[...b][0]}

Input must be a positive bigint.

Intended Solution: (similar to Bubbler's):

3615512360242432329658769258555380793536772285803851385241947165871497272426648554788915044798172040751481373577054244237102559357n

This is a representation of the payload:

String.prototype[Symbol.iterator]=function*(){yield 0}

This results in [...b] always returning [0], so the input (which is odd) results in the output returned for even numbers.

\$\endgroup\$
3
  • \$\begingroup\$ I have two potential cracks, but they only work under MDN demo window (something like on this page) and doesn't work on my local Chrome installation or TIO :/ \$\endgroup\$
    – Bubbler
    Jul 15 at 1:08
  • \$\begingroup\$ @Bubbler My intended crack should work with browsers dating back something like six years, if that helps :p \$\endgroup\$ Jul 15 at 1:34
  • \$\begingroup\$ Then I think my crack is probably the intended one, so I posted it. \$\endgroup\$
    – Bubbler
    Jul 15 at 2:14
2
\$\begingroup\$

Pip, 11 bytes, Output a string's cumulative slope - Safe!

Yq$-A[RVyy]

Try it online! (The crack also works on TIO.)

Explanation

Yq           Read a line of input and store it in y
     [    ]  Make a list containing
      RVy     y, reversed
         y    and y
    A        Get the ASCII value of (the first character of) each of those strings
  $-         Fold on subtraction

Failing inputs:

00, 000, .0, and in general anything that looks like a numeric literal for 0. These inputs do not output anything. If you turn warnings on using the -w flag, you'll see a warning "Cannot take ASC of empty string."

Why?

It's an interpreter bug which was fixed in this commit (thus the requirement to use the TIO version of Pip).

When I wrote the code for the A operator, I wanted to raise a warning and return nil if the operand was an empty string. So I started by testing whether the operand was falsey. I must have been thinking about Python strings, which are only falsey if they're empty; but in Pip, strings and numbers are a single type, Scalar. A Scalar is falsey if it is the empty string or if it is zero. Thus, the implementation of A choked if you passed it 0 or any other literal for zero--a pretty annoying bug.

\$\endgroup\$
3
  • \$\begingroup\$ I suppose the empty string and single character strings are not an actual crack. \$\endgroup\$
    – Razetime
    Jul 24 at 4:11
  • \$\begingroup\$ (Also, how do I add newlines in my input?) \$\endgroup\$
    – Razetime
    Jul 24 at 4:11
  • \$\begingroup\$ @Razetime The original challenge is a bit underspecified... I assumed the input string would be a single line. \$\endgroup\$
    – DLosc
    Jul 24 at 4:13
1
\$\begingroup\$

Rattle, 3 bytes, Simple cat program, cracked by hyper-neutrino

|!p

Try it Online!

This should be relatively easy to crack. It takes advantage of one of Rattle's core features!

Hint: A perfect cat program is simply |

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

Python 3, 63 bytes, Is this number a prime, cracked by pppery

lambda x:next(d for d,_ in enumerate(iter(int,1),2)if x%d<1)==x

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Cracked \$\endgroup\$ Jul 14 at 19:15
  • \$\begingroup\$ iter(int,1) is an interesting golfy way to create an endless iterator! \$\endgroup\$
    – pxeger
    Jul 15 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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