100
\$\begingroup\$

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

Your challenge is to make a program that runs forever without halting1, unless it gets a particular input or inputs2. If it receives that input, it must terminate in a finite amount of time3. This is , so the shortest answer that has not been cracked by a robber within one week of posting wins. After the week has passed, please mark your answer as safe and show the halting input (in a > ! spoiler quote). If a robber cracks your submission, please mark it as cracked and show the halting input (in a > ! spoiler quote).

Submissions are preferred be runnable & crackable on TIO. Submissions not runnable or crackable on TIO are allowed, but please include instructions to download / run them.

Please make your input deterministic, and uniform across all runs. See this meta post for details.

Please, don't "implement RSA" or anything mean to the robbers. Use obscure languages and features, not boring encryption and hashing. I can't enforce this with rules, but you can expect torrential downvotes if all you do is sha(input) === "abcd1234".


1Assuming that the computer doesn't get shut down, break, get engulfed by the sun, overheat in the universe's heat death, or hit the TIO timeout of 60s.

2The program must halt on at least one input. As long as it loops forever on one input and halts on another, it works.

3This must be < 60 seconds, so that the code can be tested on TIO.


Looking for uncracked submissions?

fetch("https://api.stackexchange.com/2.2/questions/135363/answers?order=desc&sort=activity&site=codegolf&filter=!.Fjs-H6J36vlFcdkRGfButLhYEngU&key=kAc8QIHB*IqJDUFcjEF1KA((&pagesize=100").then(x=>x.json()).then(data=>{var res = data.items.filter(i=>!i.body_markdown.toLowerCase().includes("cracked")).map(x=>{const matched = /^ ?##? ?(?:(?:(?:\[|<a href ?= ?".*?">)([^\]]+)(?:\]|<\/a>)(?:[\(\[][a-z0-9/:\.]+[\]\)])?)|([^, ]+)).*[^\d](\d+) ?\[?(?:(?:byte|block|codel)s?)(?:\](?:\(.+\))?)? ?(?:\(?(?!no[nt][ -]competing)\)?)?/gim.exec(x.body_markdown);if(!matched){return;}return {link: x.link, lang: matched[1] || matched[2], owner: x.owner}}).filter(Boolean).forEach(ans=>{var tr = document.createElement("tr");var add = (lang, link)=>{var td = document.createElement("td");var a = document.createElement("a");a.innerHTML = lang;a.href = link;td.appendChild(a);tr.appendChild(td);};add(ans.lang, ans.link);add(ans.owner.display_name, ans.owner.link);document.querySelector("tbody").appendChild(tr);});});
<html><body><h1>Uncracked Submissions</h1><table><thead><tr><th>Language</th><th>Author</th></tr></thead><tbody></tbody></table></body></html>

\$\endgroup\$
9
  • 1
    \$\begingroup\$ @LuisMendo assuming infinite memory is fine \$\endgroup\$
    – user58826
    Commented Jul 24, 2017 at 16:29
  • 1
    \$\begingroup\$ @programmer5000 Thanks for clarifying. You should incorporate all this into the challenge text. Answerers are not expected to read all comments \$\endgroup\$
    – Luis Mendo
    Commented Jul 24, 2017 at 16:48
  • 7
    \$\begingroup\$ Can we restrict the input to, say, an integer? A robber could pass in some malformed or mistyped input to terminate the program immediately. I'd either have to do lots of careful input validation, or use a language that can catch arbitrary errors. \$\endgroup\$
    – xnor
    Commented Jul 24, 2017 at 18:37
  • 3
    \$\begingroup\$ @xnor I think you're supposed to have to do the input checking. \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 18:49
  • 1
    \$\begingroup\$ @StepHen That works if the malformed input is still able to be parsed by the interpreter. If I enter an illegal string, R errors immediately, without even entering the function to crack. I would argue that that doesn't count as actually terminating the function. \$\endgroup\$
    – JAD
    Commented Jul 26, 2017 at 5:02

115 Answers 115

1
\$\begingroup\$

Bash, 50 bytes (cracked)

cd $1
for((;${#PWD}-$(dirname $PWD|wc -c);))
{
:
}

Input is via command-line arguments.

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ This may seem TIO specific, but it's not. The intended crack will work on all fresh Linux installs. \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 3:32
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 3:36
  • \$\begingroup\$ Well done, that was the intended solution. \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 3:37
1
\$\begingroup\$

JavaScript (Node.js), 85 bytes Cracked

x=>{try{for(;!x||x!=0||x instanceof Object||typeof x!='object';);}catch(e){for(;;);}}

Try it online!

({valueOf:g=>{Object=Number;return 0}})
({toString:x=>'',__proto__:null})

\$\endgroup\$
3
  • \$\begingroup\$ Hmm... I believe everything except number, strings, and booleans are instanceof Object, but all of those have typeof x!='object'... I guess maybe I'd have to define a custom object? \$\endgroup\$ Commented Jul 25, 2017 at 3:38
  • \$\begingroup\$ @ETHproductions What i tried is a very strange object. but you may also hack it by some strange way on built in objects. \$\endgroup\$
    – tsh
    Commented Jul 25, 2017 at 3:47
  • \$\begingroup\$ cracked! \$\endgroup\$ Commented Jul 25, 2017 at 4:12
1
\$\begingroup\$

JavaScript (ES6), 61 bytes (cracked)

a=>{while(!Array.isArray(a)||!a.length);a.map(_=>{for(;;);})}

Intended solution:

new Array(1) or any empty array with positive length

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

JavaScript (ES6), 27 bytes (Cracked, Cracked - both unintended) (Intended Cracked)

x=>{while(!(x&&x==false));}

The other cracks were genius, but the intended crack [] or new Array(). Empty array in JavaScript is truthy, but == false.

Try it online!

\$\endgroup\$
6
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Jul 25, 2017 at 14:47
  • \$\begingroup\$ @w0lf intended solution doesn't involve using any custom objects, but nice job on that :) \$\endgroup\$
    – Stephen
    Commented Jul 25, 2017 at 14:49
  • \$\begingroup\$ cracked \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 14:50
  • \$\begingroup\$ @Dennis that's genius 0.o but not what I had in mind either \$\endgroup\$
    – Stephen
    Commented Jul 25, 2017 at 14:51
  • \$\begingroup\$ cracked \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 14:53
1
\$\begingroup\$

Python 3 (CPython), 50 bytes (cracked)

l=[]
l+=[l]
def l(a,i=id,l=id(l)):
 while i(a)-l:0

Hopefully a little bit tricky.

Pass one argument to l by appending code to this program. That argument may be initialized imperatively. This answer is the kind of thing I'm looking for.

\$\endgroup\$
3
  • \$\begingroup\$ What should be the format of the answer? l(some_object) or l(input())? Right now, not calling l is enough for the program to halt :) \$\endgroup\$ Commented Jul 25, 2017 at 8:04
  • 1
    \$\begingroup\$ @EricDuminil Pass a single argument to l. To avoid needless busywork, you may initialize that argument imperatively, given several other answers already do. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 9:22
  • 1
    \$\begingroup\$ codegolf.stackexchange.com/a/135687/967 \$\endgroup\$
    – ecatmur
    Commented Jul 25, 2017 at 14:59
1
\$\begingroup\$

JavaScript (Node.js), 43 bytes (cracked)

Thought I'd try my hand at being a copper! Should be a fun one. I trust you guys but if for some reason it's too hard I'll add hints.

Solution does not require an error, if you somehow error I'll post an update with a try/catch ;)

x=>{while(!Number.isInteger(x)||x-2!=x-3);}

Try it online!

Solution:

The offered solution: 100000000000000000
Intended solutions (the closest to zero for which this works): Number.MAX_SAFE_INTEGER+7 or -Number.MAX_SAFE_INTEGER-3

You just need to go out of safe integers and test a little to get the right floating point inconsistency.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Cracked! \$\endgroup\$
    – Maya
    Commented Jul 25, 2017 at 14:01
1
\$\begingroup\$

JavaScript (ES6), 42 bytes, Cracked

x=>{while(!(Array.isArray(x)&&x==",,,"));}

An empty array of length 4 (new Array(4)), when coerced into a string with ==, becomes ,,,.

Try it online!

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

Java 8, 47 bytes, Cracked

p->{for(;p==null||p.isEmpty()||!p.isEmpty(););}

This is a lambda of type Consumer<List>. Basically, it will run as long as the list is null, empty, or non-empty... The answer to this one is pretty simple, I'll try and come up with a truly difficult one for my next answer :)

Try it online! (Note, you will have to edit in the input in the function call in the footer)

Just FYI, the intended solution terminates in ~3 seconds (including compilation), so it should be crackable on TIO.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 16:24
1
\$\begingroup\$

JS (ES6), 37 bytes (Cracked)

x=>{for(;typeof x!=="object"||x;);}

Pretty easy. Let's see how long this lasts.

\$\endgroup\$
2
  • \$\begingroup\$ Cracked! Nooo, SE automatically converted my crack into a comment, I just reverted it now \$\endgroup\$
    – user41805
    Commented Jul 24, 2017 at 17:42
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 17:42
1
\$\begingroup\$

Python 3, 143 bytes (cracked)

try:x=int(input())
except:x=0
p=c=n=0
while x:
 b=x&511
 while (p|c|n)&b or b&(b-1):0
 p|=b;c|=b;n|=b;x>>=12;p>>=1;n*=2
while (x+1)/(c-511)<1:0

Not enough math-y ones, which makes sense but is kind'a sad. This one isn't particularly competitive, but it's different to most.

Try it online.

\$\endgroup\$
12
  • \$\begingroup\$ Bonus points for the provably smallest answer. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 15:10
  • \$\begingroup\$ Really nice challenge! Cracked. \$\endgroup\$ Commented Jul 25, 2017 at 21:54
  • \$\begingroup\$ @w0lf Nice work yourself :). \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 22:08
  • \$\begingroup\$ I have updated my answer with an explanation of how I arrived to this number. Is it true that it's the smallest? I haven't been able to find a smaller one. \$\endgroup\$ Commented Jul 26, 2017 at 7:20
  • 1
    \$\begingroup\$ OK, it's 79305685030021641783052861456. I was stubborn trying to find it by hand, but this time I wrote a program to find the answer. \$\endgroup\$ Commented Jul 26, 2017 at 19:18
1
\$\begingroup\$

Commodore 64 Basic, 14 bytes: Cracked

1INPUTB
2GOTO1

Tested using VICE, but any Commodore emulator should work.

Cracked:

9999999999999999999999999999999999999999999999999999999999999999.9

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 21:37
1
\$\begingroup\$

Python 2, 42 bytes (Unintended Crack & Intented Crack)

def f(x):
    try:x()
    except:7
    while True:7

There's an intended solution here, but I'm curious what people will come up with...

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 1:51
  • \$\begingroup\$ Cracked \$\endgroup\$
    – xnor
    Commented Jul 25, 2017 at 2:24
1
\$\begingroup\$

R, 44 bytes (cracked and cracked)

f=function(x)while(1)if(length(x))grep(x,'')

This halts if grep(x,'') receives invalid regex, which was the intended solution. Also fails when given a function as input.

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

R, 63 bytes (cracked)

f=function(x){set.seed(4);try(eval(x));x=rpois(1,1);while(x){}}
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 3:10
1
\$\begingroup\$

anyfix, 13 bytes Cracked

ɠ#5+¿2«*"ḶİP»

Try it online!

Another easy one, hopefully nobody just bruteforces it :(

-5

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 3:25
1
\$\begingroup\$

Python 3.5, 69 bytes, Cracked

def f(x):
 y=str(x)
 while not(x and(y[-1]+y[:-1])==str(2*x)):a=1

There is a solution that is an integer.

Cracked by isaacg (in 11 min) and Jarko Dubbeldam.

\$\endgroup\$
4
  • \$\begingroup\$ 105263157894736842 \$\endgroup\$
    – isaacg
    Commented Jul 26, 2017 at 6:21
  • \$\begingroup\$ @isaacg while true, can you make a post on the robbers thread that I can link to? \$\endgroup\$
    – Magenta
    Commented Jul 26, 2017 at 6:41
  • \$\begingroup\$ This seems to work for more than one solution: 210526315789473684, 421052631578947368 and more \$\endgroup\$
    – JAD
    Commented Jul 26, 2017 at 6:57
  • \$\begingroup\$ I added these solutions to a post on the robbers thread and edited the link. \$\endgroup\$
    – JAD
    Commented Jul 26, 2017 at 11:14
1
\$\begingroup\$

R, 60 bytes, cracked

f=function(x)while(1)tryCatch(eval(x),error=function(e)NULL)

tryCatch prevents exiting through errors or any kind, so the only way to exit is to call quit() or q().

\$\endgroup\$
7
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 11:42
  • \$\begingroup\$ Also Cracked \$\endgroup\$
    – Rift
    Commented Jul 26, 2017 at 11:44
  • \$\begingroup\$ @Rift oh damn, I thought I tested that, but I forgot the expression. \$\endgroup\$
    – JAD
    Commented Jul 26, 2017 at 11:45
  • \$\begingroup\$ @JarkoDubbeldam you should not have included eval \$\endgroup\$
    – Rift
    Commented Jul 26, 2017 at 12:18
  • \$\begingroup\$ @Rift Hmm, an earlier iteration had x() instead. However, that doesn't immediately terminate with q, but rather prompts for saving workspace and yadda yadda. \$\endgroup\$
    – JAD
    Commented Jul 26, 2017 at 12:23
1
\$\begingroup\$

SmallTalk, 136 bytes (not a concise language‼) (cracked)

|n p|n:=stdin nextLine asInteger abs. p:=2 raisedTo:n.[(p printString:3)sorted=(p+p printString:3)sorted and:[n\\5=1]]whileFalse:[nil]

Not a TIO language, but GNU SmallTalk is easily available.

Edited so that the program halts quickly on CodingGround. The solution is now really easy!

Code reads the input from the console.

The intent with the original code using n\\239=0 was for the robber to discover the pattern of the numbers without including a modulus criterion: 5 27 40 92 138 929 1086 ..., searching for "5 27 40 92 138 929 1086" in Google brings up one match providing five more terms. The last term is divisible by 239. Anyway, this term is too large to validate in under 30 seconds in any version of SmallTalk. So I had to pick the largest term which could finish fast enough, which was 1086. Even the next term 352664 in the sequence after 1086 takes more than an hour to validate in SmallTalk!

\$\endgroup\$
10
  • \$\begingroup\$ Help plz? Does the answer work on tutorialspoint.com/execute_smalltalk_online.php? For bonus niceness, does it halt within ~60s? \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 0:58
  • \$\begingroup\$ @Veedrac - I noticed now the rules say it must halt in < 30 seconds. Have changed the code, it's now much easier! \$\endgroup\$
    – user15259
    Commented Jul 26, 2017 at 21:50
  • \$\begingroup\$ "really easy". Why do I not trust you... :P \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 22:17
  • \$\begingroup\$ Cracked. I should have more faith! A shame you had to make it easier; I've not given up on the original though. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 22:40
  • 2
    \$\begingroup\$ Well I've found my new wallpaper. \$\endgroup\$
    – Veedrac
    Commented Jul 27, 2017 at 0:48
1
\$\begingroup\$

Pyth, 18 bytes, Cracked

J<w17#.x$eval(J)$0

Code

You must give an input - it'll just hang waiting for input and not terminate otherwise.

\$\endgroup\$
2
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 27, 2017 at 1:20
  • \$\begingroup\$ @Veedrac Darn - not what I intended. I'll have to try again. \$\endgroup\$
    – isaacg
    Commented Jul 27, 2017 at 2:29
1
\$\begingroup\$

C++ (gcc/MSVC), 63 bytes, cracked (fixed)

template<class T,T=T()>T f(T t){for(auto a=0ll;!a;(T&)a=t={});}

Tested on Linux and Windows. To compile with MSVC, use #pragma warning(default:4716).

Veedrac spotted that by supplying template parameters it's possible to make T a reference type, allowing a class type with user-defined constructor. Fixed in the newer version by disallowing reference types using *.

Try it online!

\$\endgroup\$
8
  • \$\begingroup\$ Are we allowed to specify the template parameters to f when calling it? \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 17:43
  • \$\begingroup\$ @Veedrac yes, certainly - as long as it compiles (and doesn't crash before entering f) any parameters are fine. \$\endgroup\$
    – ecatmur
    Commented Jul 26, 2017 at 17:49
  • \$\begingroup\$ ... although my intended solution doesn't require any template arguments to be supplied. \$\endgroup\$
    – ecatmur
    Commented Jul 26, 2017 at 18:10
  • 1
    \$\begingroup\$ Ugh, cracked I guess. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 18:40
  • \$\begingroup\$ @Veedrac I didn't intend to allow reference types! Fixed to disallow those - want to have another go? \$\endgroup\$
    – ecatmur
    Commented Jul 26, 2017 at 20:01
1
\$\begingroup\$

R, 145 bytes (Version 2.0)

f=function(x)if(tryCatch(x=="length"|x=="q"|x==".Internal"|x=="quit"|x=="is.list"|!getAnywhere(x)$objs[[1]](list(0)),error=function(e)1))repeat{}

R, 145 bytes Cracked

f=function(x)if(tryCatch(x=="length"|x=="q"|x==".Internal"|x=="quit"|x=="is.list"|!getAnywhere(x)$objs[[1]](list(1)),error=function(e)1))repeat{}

Modification of this answer. Creating your own version of is.list won't work this time :)

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ Commented Jul 27, 2017 at 19:57
  • \$\begingroup\$ @Gregor nicely done! See if you can crack this! \$\endgroup\$
    – JAD
    Commented Jul 27, 2017 at 20:36
1
\$\begingroup\$

JavaScript (Browser), 62 bytes (cracked)

x=>{while(!x||(!(x[Symbol.toPrimitive]=()=>true))||+x||true);}

Solution should work in modern browsers on all pages. Is possible without .toPrimitive (or similar) trickery (cracked) - is also possible with .toPrimitive (or similar) trickery (cracked) :P

Intended solutions:

W/o .toPrimitive or similar:

let i = document.createElement("iframe");
i.src="https://google.com";
i.onload=a=>f(i.contentWindow);
document.body.appendChild(i);

W/ .toPrimitive

\$\endgroup\$
4
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 23:07
  • \$\begingroup\$ @Veedrac Nice! Now we just need the solution without .toPrimitive. \$\endgroup\$
    – Birjolaxew
    Commented Jul 27, 2017 at 6:22
  • \$\begingroup\$ @PatrickRoberts I'd say that counts ;) \$\endgroup\$
    – Birjolaxew
    Commented Jul 27, 2017 at 21:56
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Jul 27, 2017 at 22:40
1
\$\begingroup\$

JavaScript (ES7), 25 bytes, Cracked

x=>{for(;!(x&&"."**x););}

Intended solution:

"0"

Try it online!

\$\endgroup\$
5
  • \$\begingroup\$ Cracked?. \$\endgroup\$
    – Shaggy
    Commented Jul 27, 2017 at 16:38
  • \$\begingroup\$ @Shaggy yup, there's a couple other (equivalent) solutions \$\endgroup\$
    – Stephen
    Commented Jul 27, 2017 at 16:45
  • \$\begingroup\$ Yeah, I also just found that String.prototype works too. \$\endgroup\$
    – Shaggy
    Commented Jul 27, 2017 at 16:46
  • \$\begingroup\$ @Shaggy why the flippity flappity does String.prototype == false \$\endgroup\$
    – Stephen
    Commented Jul 27, 2017 at 16:47
  • \$\begingroup\$ Because JS is weird?! Array.prototype also works but, strangely, Object.prototype doesn't. \$\endgroup\$
    – Shaggy
    Commented Jul 27, 2017 at 16:49
1
\$\begingroup\$

Python 2, 81 bytes, Cracked

try:x,y,z=raw_input().split(',');setattr(__import__(x),y,z)
except:0
while True:0
\$\endgroup\$
1
  • \$\begingroup\$ Cracked! \$\endgroup\$
    – Sisyphus
    Commented Jul 29, 2017 at 12:16
1
\$\begingroup\$

JavaScript (Node.js >= 6.0), 708 694 bytes, Cracked

(_=>{let v=s=>eval(s);{let e=require('events').EventEmitter.prototype;e.listeners=new Proxy(e.listeners,{apply(t,c,a){if(a[0]=='exit')return[];return t.apply(c,a)}});e.removeAllListeners=new Proxy(e.removeAllListeners,{apply(t,c,a){if(a[0]=='exit')return c;return t.apply(c,a)}});let w=new WeakSet();Proxy.revocable=new Proxy(Proxy.revocable,{apply(t,c,a){let r=t.apply(c,a);w.add(r.proxy);return r}});Proxy=new Proxy(Proxy,{construct(t,a,n){let p=new t(...a);w.add(p);return p}});let l=_=>{while(1);};process.on('exit',l);return i=>{try{if(!w.has(i)&&i instanceof Function&&typeof i!='function'&&v(String(i))===i&&i()===String(i)){process.removeListener('exit',l)}else{l()}}catch(o){l()}}}})()

Don't let the size deter you. Most of it is to just prevent you from trying to get past my intended solution doing the "obvious" stuff.

I hope this isn't more simple than I thought it was, but I assure you it's possible. I've tested on my computer and also on TIO to make sure it wasn't dependent on a particular version of Node.js or something.

This is a function submission, so assign it to a variable and call it with your intended input.

And maybe I'm not supposed to enforce this, but the input for the intended crack doesn't require any pre-processing, it can just be solved by doing this:

f=[708 bytes...]
f([your input])

Comment on @hvd's crack

I will reveal one part of the intended solution, since it is no longer relevant, and hvd's approach was much more elegant anyway.

Object.create((class extends Function{toString(){process.kill(0)}}).prototype)

would have been how I would have written that particular crack, since I had not thought of using __proto__ in an object literal, so kudos.

Edit 1

Sorry, forgot to invoke the IIFE, otherwise any input would have worked :P

Edit 2

This doesn't change the challenge at all, it just addresses the comment claiming

Halts with error, let not supported without strict mode. If fix t(...a) is unexpected token.

by explicitly defining the accepted range of versions in which these errors don't occur, making the challenge valid.

Edit 3

By moving the call to process.on('exit',l) from the function call into the IIFE scope, I prevented the stupid input of

process.on=()=>process.exit()

from working. An interesting side-effect of this change is that not calling the function causes the program to hang as well!

However, the intended solution is still the same, and the rest of the changes were only for golfing purposes. Carry on!

(And the timer for marking "safe" has been reset as of this edit because it is major)

\$\endgroup\$
15
  • 1
    \$\begingroup\$ A slightly easier to work with TIO \$\endgroup\$
    – Birjolaxew
    Commented Jul 28, 2017 at 12:03
  • \$\begingroup\$ @Birjolaxew Heh, I see you've discovered the basics of my challenge, but the question remains if you can find the answer~ (at least I hope I've narrowed it to one) \$\endgroup\$ Commented Jul 28, 2017 at 12:33
  • 1
    \$\begingroup\$ @PatrickRoberts I got stuck on implementing [[Call]] without typeof i === "function" (since that's how the specification defines typeof === "function" :P) \$\endgroup\$
    – Birjolaxew
    Commented Jul 28, 2017 at 12:37
  • \$\begingroup\$ @Birjolaxew then how do you explain var call = Function.call; console.log(typeof call); call()? I'm not saying it's entirely useful here, but I'm just playing devil's advocate. \$\endgroup\$ Commented Jul 28, 2017 at 14:05
  • 1
    \$\begingroup\$ @PatrickRoberts It does work, because the IIFE sees the WeakSet function definition even if it appears later in the code at a point where execution hasn't reached yet. \$\endgroup\$
    – hvd
    Commented Jul 30, 2017 at 21:41
1
\$\begingroup\$

Python 3, 228 Bytes (Cracked - Fixed)

I was stupid, and this was cracked because I missed a trivial case. Thanks to Jonathan Allan, it's been fixed, and I resubmit it.

Try it here

p=print
try:
    n=input()
except:
    while 1:p("i")
try:
    while sum(map(int,n))<1or not(int(n[17]+n[:17])==2*int(n[:18])and int(n[45]+n[18:45])==3*int(n[18:46])and int(n[87]+n[46:87])==5*int(n[46:88])):p("m")
except:
    while 1:p("x")
\$\endgroup\$
13
  • 1
    \$\begingroup\$ TIO is an online execution environment for programs. For example, you might post this link as a way of sharing your answer through the online environment. \$\endgroup\$ Commented Jul 24, 2017 at 20:48
  • 1
    \$\begingroup\$ Simple crack would be n a string or list of length less than length 17 causing an IndexError (this is assuming n is already limited to a string or list too). \$\endgroup\$ Commented Jul 24, 2017 at 21:39
  • 1
    \$\begingroup\$ cracked. Almost certainly not the intended crack, but also without any error raised. \$\endgroup\$ Commented Jul 24, 2017 at 21:59
  • \$\begingroup\$ @JonathanAllan You're right. I meant to restrict it to only positive values. Is it acceptable to edit it to correct my oversight? \$\endgroup\$
    – E.D.
    Commented Jul 24, 2017 at 22:46
  • 2
    \$\begingroup\$ Yeah, I think so, I have not cracked the intended and it seems cool to me - how about this modification? It means it'll be a full program, so only strings ever get in (empty or ctrl-x etc for input - prints "i") and no errors can occur in the evaluation (prints "x"). \$\endgroup\$ Commented Jul 24, 2017 at 22:52
1
\$\begingroup\$

Java (OpenJDK 8), 517 bytes (safe)

import java.lang.reflect.Constructor;
import java.util.Map;
class M{
	public static void main(String[] cm){
		try{
			Class<?>cl=Class.forName(cm[0]);
			Constructor<?>ct=cl.getConstructor();
			Map<Integer,Integer>m=(Map)ct.newInstance();
			String str="Hello World";
			for (int i=0;i<str.length();i++){
				char c=str.charAt(i);
				int cc=m.getOrDefault(new Integer(c),new Integer(0));
				cc++;
				m.put(new Integer(c),new Integer(cc));
			}
			while(m.size()<9);
		}catch(Throwable t){
			while(true);
		}
	}
}

Try it online!

Input via the command line arguments.

A little long and verbose, but hey, it's got reflection!

Golfed a little more, 432 bytes

(Thanks to Stephen!)

import java.lang.reflect.Constructor;import java.util.Map;class M{public static void main(String[]a){try{Class<?>l=Class.forName(a[0]);Constructor<?>t=l.getConstructor();Map<Integer,Integer>m=(Map)t.newInstance();String s="Hello World";for(int i=0;i<s.length();i++){char c=s.charAt(i);int C=m.getOrDefault(new Integer(c),new Integer(0));C++;m.put(new Integer(c),new Integer(C));}while(m.size()<9);}catch(Throwable t){while(true);}}}

Halting input:

java.util.IdentityHashMap

\$\endgroup\$
4
  • \$\begingroup\$ It seems very long to me for a code-golf. \$\endgroup\$
    – Toto
    Commented Sep 13, 2017 at 12:34
  • \$\begingroup\$ Welcome to PPCG! I know this is cops-and-robbers, but you can get 432 bytes by golfing variable names and whitespace: Try it online! \$\endgroup\$
    – Stephen
    Commented Sep 13, 2017 at 12:58
  • \$\begingroup\$ @Toto It's indeed not the golfiest thing in the world, but it does use some rather unusual features of Java. \$\endgroup\$ Commented Sep 13, 2017 at 13:04
  • \$\begingroup\$ @Stephen Thanks a lot! Had to leave the computer for a while and wanted to post the thing before I went. :) (Double comment because I can't mention two people at once) \$\endgroup\$ Commented Sep 13, 2017 at 13:05
1
\$\begingroup\$

JavaScript (Node.js), 99 bytes

x=>{try{while(typeof x!='string'||!x.match`^[()[\\]!+]{4321}$`|eval(x)!='☆');}catch(e){for(;;);}}

Try it online!

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

x86-64, 5 bytes assembled, SAFE

halty:
  verr si
  jnz $
  ret

This is a pretty simple "warm up" I came up with. Shouldn't be difficult at all to crack. Takes input in rsi.

Why did this win.

The solution is simple, at least on my computer. rsi == 32 will cause it to halt. In fact, it has multiple possible inputs that will cause it to halt. verr checks if the segment supplied in %r can be read. IF it can't, the zero flag is set, and the function returns.

\$\endgroup\$
1
  • \$\begingroup\$ I think a 0 as input would halt this one (line 3 is jump if not zero). I don't have a way to run it and check though. \$\endgroup\$ Commented Oct 15, 2018 at 0:19
1
\$\begingroup\$

Simplefunge, 1028 bytes, safe

0ooooooooooooooooooooooOOOOOOOOOOOOoo9ooOOoOOoOOoOoOOoOoOoOOOOoOoOoOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooIOoOoOoOoOOoOOooOOo-ov
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOooooooo
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOooooooO
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOooooooo
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOooooooO
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOooooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOooooooo
ooooOOOOooOOoOOoOOoOOoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo@oooooooooooooooooooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoooooooooooooooooooOOOOOOOOoooooH

The answer is the tab character

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Um, this halts with no input \$\endgroup\$
    – Jo King
    Commented Feb 24, 2019 at 23:33
  • \$\begingroup\$ Oh, okay. Does that count? \$\endgroup\$
    – MilkyWay90
    Commented Feb 24, 2019 at 23:40

Your Answer

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