15
\$\begingroup\$

Cops' Thread

Your challenge is to find an uncracked, unsafe cop on the cops thread, and find an input value for which their code does not do as specified by the challenge.

You must use values within the bounds specified by the cop and the challenge - if a float breaks their program but they specified integers only, it's not a valid crack.

Use any submission on the specified challenge to find the correct value for any input - you probably want to check this against another submission.

Scoring

Your score is the number of cops you have cracked, with higher score being better.

\$\endgroup\$

18 Answers 18

17
\$\begingroup\$

Python by Sisyphus for Is this number a prime?

\$ 110728750366081 = 37 \times 41 \times 71 \times 661 \times 673 \times 2311 \$ is wrongly recognized as a prime.

Try it online!

Sisyphus implemented the Solovay-Strassen primality test, which is based on a theorem by Euler which states for any prime number \$p\$ and any integer \$a\$:

$$ a^{p-1\over2} \equiv \left({a \over p}\right) \mod p, $$

where \$\left({a \over p}\right)\$ is the Jacobi symbol. The primality test usually draws a few random numbers for \$a\$ and assumes \$p\$ is a prime if the equality was satisfied for all \$a\$.
Because randomness doesn't work very well with , the long constant hardcodes a fixed set of values for \$a\$:

2, 3, 5, 7, 11, 13, 17, 19, 11617, 15493, 16433, 25919, 31091, 31469, 49307, 55001, 55399, 65071

For a given \$a\$ there exist composite numbers that satisfy the equivalence, these are called Euler-Jacobi Pseudoprime to base \$a\$.
To solve the challenge, one needs to a find a single positive integer that is a Euler-Jacobi Pseudoprime to all the bases. Bruteforcing this turned out to be infeasible, but this article mentions that some Carmichael numbers are Euler-Jacobi Pseudoprime to some base. By filtering a list of Carmichael numbers from this site¹, I was able to find a few solutions:

110728750366081 37*41*71*661*673*2311
237382308072001 29*101*127*337*631*3001
549022047900481 29*31*199*857*1381*2593
815369599393441 179*5741*6673*118903
1777021736490001 71*79*199*461*3453451
2409992788323121 29*67*499*20693*120121
5514474572006401 1051*2521*11551*180181
6036890513068801 43*71*101*40129*487873
9704292238761121 79*113*521*631*937*3529
14988701359951201 191*241*271*401*1051*2851
23456937465858961 37*43*71*103*181*821*13567
23880657211210801 23*61*109*157*271*937*3917
26055899070788161 31*173*433*1777*2437*2591
28365866503643761 43*53*137*281*443*457*1597
30908877197436001 421*601*1429*1709*50021
33834184755920641 29*37*71*73*97*547*114661
45561504118095001 211*421*751*3571*191251
51176905599093121 29*31*43*67*137*6427*22441
64612622789870401 97*181*277*647*691*29717
83629862695874881 181*881*953*4789*114913
132132263067090001 41*131*647*47501*800473
162098861806081201 71*421*2393*11047*205141
219842309289002401 23*29*71*151*337*3851*23689
283029750046243201 47*101*113*691*21841*34961
308601054690500881 29*37*41*331*691*4621*6637
314618527970346601 991*1093*3511*3571*23167
317711413912838401 43*53*73*79*113*3361*63649
397597753071953281 73*211*241*271*8317*47521
406954063186624801 29*37*41*191*3037*3221*4951
507180584040530401 89*163*281*397*463*743*911
511311312146194561 37*79*131*353*577*1361*4817
594232587298120681 29*71*127*1163*1171*1668629
650151107946325441 547*6553*35491*5110561
682696543350931201 315011*882029*2457079
685726732138361761 67*331*397*487*1567*102061
738294418360350721 89*353*5897*14081*283009
794134562259598561 23*79*89*157*241*2341*55441
806936176399473121 53*137*157*2731*4409*58787
830121613337016001 73*109*34651*53353*56431
963141865421809921 23*43*61*113*193*353*617*3361

¹The files are not actually gzipped, they are just plain text files

\$\endgroup\$
2
  • \$\begingroup\$ Ooh, nice. Thanks for the explanation! \$\endgroup\$
    – justhalf
    Commented Jul 15, 2021 at 15:32
  • \$\begingroup\$ Very nice solution. \$\endgroup\$
    – Sisyphus
    Commented Jul 16, 2021 at 1:44
7
\$\begingroup\$

Jelly by caird coinheringaahing for Is it double speak?

ṾḊṖŒœE

Try it online!

Uneval doesn't always surround the string in quotes. Since Jelly cannot escape string delimiters (and even if it could, the escape characters would cause it to fail), ““ unevaluates to ”“,”“ (literal character followed by literal character ), which is not even an even-length string.

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

Jelly by caird coinheringaahing for Is it double speak?

Original code:

ṾḊṖ⁼2/Ạ

Crack:

'

The explanation described removing quotes, so I just tried quotes.

Edit: Based on several other cracks by fireflame241 and Jonathan Allen that I only sniped by a matter of seconds, any odd-length string will also result in a crack.

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Not my intended crack, but very nice \$\endgroup\$ Commented Jul 14, 2021 at 0:24
  • 2
    \$\begingroup\$ Ah, simultaneous! I've deleted my answer, but this actually works because the string has an odd length. This is better demonstrated with the input aabbccd which is grouped into [[a,a],[b,b],[c,c],[d]], and the equality gives [1,1,1,'d'], which outputs 1 because 'd' is truthy. Try it online \$\endgroup\$ Commented Jul 14, 2021 at 0:24
3
\$\begingroup\$

Jelly by caird coinheringaahing for Make a ;# interpreter

For n > 127, ; repeated n times, then #.

Original: Try it online!

Broken: Try it online!

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

Taxi by Stephen for Draw an asterisk triangle

9

Be sad online

\$\endgroup\$
3
  • \$\begingroup\$ Or any greater number. \$\endgroup\$
    – Makonede
    Commented Jul 14, 2021 at 21:22
  • \$\begingroup\$ Any integer between 1 and 8 (inclusive) may also make an error \$\endgroup\$ Commented Jul 15, 2021 at 9:42
  • \$\begingroup\$ @Scratch---Cat At random? Or do you mean the no outgoing passengers found error which terminates the program after it has produced the correct output? \$\endgroup\$ Commented Jul 15, 2021 at 19:00
3
\$\begingroup\$

Javascript by Redwolf Programs for Is this even or odd?

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]}

Crack input:

968040030946052874125008971077898749420224656625100629300118076307717369397814550869471412902654978373500023349257848576032587637596801109818665n

Outputs 0, which is wrong because the given number is odd.

This is the result of f(s) where f and s are

f=s=>[...s].map(c=>BigInt(c.charCodeAt())).reduce((x,y)=>x*256n+y)
s='Object.defineProperty(Array.prototype,0,{get:_=>0,set:_=>_})'

The payload basically fixes the index 0 of every single Array as 0 by defining the 0 property of Array.prototype. The getter returns 0 and the setter does nothing.

Does not work in Chrome console for security reasons, but you can try out the following full code by copy-pasting into an MDN demo window such as one on this page. The whole page will malfunction after the code runs, so be sure to close the tab after seeing the result :P

z=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]}
f=s=>[...s].map(c=>BigInt(c.charCodeAt())).reduce((x,y)=>x*256n+y)
s='Object.defineProperty(Array.prototype,0,{get:_=>0,set:_=>_})'
console.log(n=f(s))
console.log(z(n))
console.log([10][0]) // bonus; shows what the code does

Output:

968040030946052874125008971077898749420224656625100629300118076307717369397814550869471412902654978373500023349257848576032587637596801109818665n
0
0
\$\endgroup\$
2
  • \$\begingroup\$ Ooh, nice solution! I forgot about using defineProperty on arrays, my intended solution was something similar involving overriding String.prototype[Symbol.iterator]. \$\endgroup\$
    – rydwolf
    Commented Jul 15, 2021 at 2:34
  • \$\begingroup\$ Oh, nice! This is slightly evil. \$\endgroup\$
    – emanresu A
    Commented Jul 15, 2021 at 3:36
2
\$\begingroup\$

Vyxal by A username for Stack Exchange Vote Simulator

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

Try it Online!

Input of ^v.

I don't think this even works for most of the test cases.

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

Vyxal by Aaron Miller for Simple cat program

Any string - implicit output is with a trailing newline, so this is invalid no matter what.

\$\endgroup\$
3
  • \$\begingroup\$ Ah, the empty string makes it output 0 as well. \$\endgroup\$ Commented Jul 14, 2021 at 0:45
  • \$\begingroup\$ I didn't even think of that. \$\endgroup\$
    – emanresu A
    Commented Jul 14, 2021 at 0:46
  • \$\begingroup\$ I suppose not having used Vyxal before helps lol. \$\endgroup\$ Commented Jul 14, 2021 at 0:47
2
\$\begingroup\$

JavaScript by Redwolf Programs for "Hello, World!"

Input: 90071992547409929007199254740992

Try it online!

Since all numbers in JavaScript are floating point, once numbers get big enough, adding and subtracting from them gets kinda weird.

\$\endgroup\$
2
  • \$\begingroup\$ Not the intended crack at all, but good job! \$\endgroup\$
    – rydwolf
    Commented Jul 14, 2021 at 1:47
  • \$\begingroup\$ Infinity breaks it too. \$\endgroup\$ Commented Jul 15, 2021 at 6:00
2
\$\begingroup\$

Vyxal by Wasif for Least Common Multiple

[2,1,2]

Or similar

Try it Online!

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

Rattle by Daniel H., 3 bytes

|!p

Try it Online!

Fails for input .1. It seems that | just outputs the input but p will evaluate it? I am not sure exactly how this language works.

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

Python 3 by Gavin S. Yancey, Is this number a prime?

The input 77833763775941059 is a prime, but evaluates as False in the answer given.

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!

x/d==x//d is the obvious culprit here. It's supposed to act like x%d==0, but due to precision issues it starts to falter for primes at around 17 digits.

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

Python 3 by pajonk for Convert YYYYMM to MMMYY

Month 09 just outputs 'SER' instead of 'SEP'.

Try it online!

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

Vyxal by A username for Find the first word starting with each letter

Original Code (40 bytes):

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

Try it Online!

Crack:

Any word repeating without change.

example: test test, or .test test results in test test, while it should return test

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

Jelly by Jonathan Allan for Generate Recamán's sequence

Input of 1024.

Try it online!

As the challenge asks for a sequence involving some sort of recursion, I tried a large input (if something breaks early it probably will be carried on) and compared with correct answers in the challenge.

As pointed by @Stephen, the code actually breaks around input of 58.

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

Python 3 by Gavin S. Yancey for Is this number a prime?

Input is 1. The program given loops forever on that input, and, since all programs are required to terminate, it is not a valid answer.

The challenge given even explicitly states that answers have to handle 1 as composite.

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

Python by dingledooper for DDoouubbllee ssppeeaakk!!

'()'*200000

Try it online!

(that is, 200000 pairs of left right brackets in a row)

This is an application of Python Bug 5765 where a stack overflow can be caused by a large number of chained function calls. This doesn't work in modern versions of Python 3.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Well done! I'm a bit disappointed since this is not at all the intended solution, though I should have seen this coming :P. I think I'll give you (and others) a day or two to come up with a solution that is closer to what I had intended, before I reveal mine (in particular, it runs through the function but returns an incorrect result). \$\endgroup\$ Commented Jul 16, 2021 at 2:17
0
\$\begingroup\$

Python by StardustGogeta for Simple cat program

Try it online!

\$\endgroup\$

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.