94
\$\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\$
  • 1
    \$\begingroup\$ @LuisMendo assuming infinite memory is fine \$\endgroup\$ – programmer5000 Jul 24 '17 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 Jul 24 '17 at 16:48
  • 6
    \$\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 Jul 24 '17 at 18:37
  • 3
    \$\begingroup\$ @xnor I think you're supposed to have to do the input checking. \$\endgroup\$ – Stephen Jul 24 '17 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 Jul 26 '17 at 5:02

109 Answers 109

1
\$\begingroup\$

JavaScript in Firefox console (on blank.org), 7,987 bytes (cracked)

Not contending to win, but this should be fun.

f=B=>{eval("if(typeof B!='number')B=0;if(typeof Β!='number')Β=0;".repeat(4).repeat(2));while(B<=0||B==1||B==2||B==3||B==4||B==5||B==6||B==7||B==8||B==9||B==10||B==11||B==12||B==13||B==14||B==15||B==16||B==17||B==18||B==19||B==20||B==21||B==22||B==23||B==24||B==25||B==26||B==27||B==28||B==29||B==30||B==31||B==32||B==33||B==34||B==35||B==36||B==37||B==38||B==39||B==40||B==41||B==42||B==43||B==44||B==45||B==46||B==47||B==48||B==49||B==50||B==51||B==52||B==53||B==54||B==55||B==56||B==57||B==58||B==59||B==60||B==61||B==62||B==63||B==64||B==65||B==66||B==67||B==68||B==69||B==70||B==71||B==72||B==73||B==74||B==75||B==76||B==77||B==78||B==79||B==80||B==81||B==82||B==83||B==84||B==85||B==86||B==87||B==88||B==89||B==90||B==91||B==92||B==93||B==94||B==95||B==96||B==97||B==98||B==99||B==100||B==101||B==102||B==103||B==104||B==105||B==106||B==107||B==108||B==109||B==110||B==111||B==112||B==113||B==114||B==115||B==116||B==117||B==118||B==119||B==120||B==121||B==122||B==123||B==124||B==125||B==126||B==127||B==128||B==129||B==130||B==131||B==132||B==133||B==134||B==135||B==136||B==137||B==138||B==139||B==140||B==141||B==142||B==143||B==144||B==145||B==146||B==147||B==148||B==149||B==150||B==151||B==152||B==153||B==154||B==155||B==156||B==157||B==158||B==159||B==160||B==161||B==162||B==163||B==164||B==165||B==166||B==167||B==168||B==169||B==170||B==171||B==172||B==173||B==174||B==175||B==176||B==177||B==178||B==179||B==180||B==181||B==182||B==183||B==184||B==185||B==186||B==187||B==188||B==189||B==190||B==191||B==192||B==193||B==194||B==195||B==196||B==197||B==198||B==199||B==200||B==201||B==202||B==203||B==204||B==205||B==206||B==207||B==208||B==209||B==210||B==211||B==212||B==213||B==214||B==215||B==216||B==217||B==218||B==219||B==220||B==221||B==222||B==223||B==224||B==225||B==226||B==227||B==228||B==229||B==230||B==231||B==232||B==233||B==234||B==235||B==236||B==237||B==238||B==239||B==240||B==241||B==242||B==243||B==244||B==245||B==246||B==247||B==248||B==249||B==250||B==251||B==252||B==253||B==254||B==255||B==256||B==257||B==258||B==259||B==260||B==261||B==262||B==263||B==264||B==265||B==266||B==267||B==268||B==269||B==270||B==271||B==272||B==273||B==274||B==275||B==276||B==277||B==278||B==279||B==280||B==281||B==282||B==283||B==284||B==285||B==286||B==287||B==288||B==289||B==290||B==291||B==292||B==293||B==294||B==295||B==296||B==297||B==298||B==299||B==300||B==301||B==302||B==303||B==304||B==305||B==306||B==307||B==308||B==309||B==310||B==311||B==312||B==313||B==314||B==315||B==316||B==317||B==318||B==319||B==320||B==321||B==322||B==323||B==324||B==325||B==326||B==327||B==328||B==329||B==330||B==331||B==332||B==333||B==334||B==335||B==336||B==337||B==338||B==339||B==340||B==341||B==342||B==343||B==344||B==345||B==346||B==347||B==348||B==349||B==350||B==351||B==352||B==353||B==354||B==355||B==356||B==357||B==358||B==359||B==360||B==361||B==362||B==363||B==364||B==365||B==366||B==367||B==368||B==369||B==370||B==371||B==372||B==373||B==374||B==375||B==376||B==377||B==378||B==379||B==380||B==381||B==382||B==383||B==384||B==385||B==386||B==387||B==388||B==389||B==390||B==391||B==392||B==393||B==394||B==395||B==396||B==397||B==398||B==399||B==400||B==401||B==402||B==403||B==404||B==405||B==406||B==407||B==408||B==409||B==410||B==411||B==412||B==413||B==414||B==415||B==416||B==417||B==418||B==419||B==420||B==421||B==422||B==423||B==424||B==425||B==426||B==427||B==428||B==429||B==430||B==431||B==432||B==433||B==434||B==435||B==436||B==437||B==438||B==439||B==440||B==441||B==442||B==443||B==444||B==445||B==446||B==447||B==448||B==449||B==450||B==451||B==452||B==453||B==454||B==455||B==456||B==457||B==458||B==459||B==460||B==461||B==462||B==463||B==464||B==465||B==466||B==467||B==468||B==469||B==470||B==471||B==472||B==473||B==474||B==475||B==476||B==477||B==478||B==479||B==480||B==481||B==482||B==483||B==484||B==485||B==486||B==487||B==488||B==489||B==490||B==491||B==492||B==493||B==494||B==495||B==496||B==497||B==498||B==499||B==500||B==501||B==502||B==503||B==504||B==505||B==506||B==507||B==508||B==509||B==510||B==511||B==512||B==513||B==514||B==515||B==516||B==517||B==518||B==519||B==520||B==521||B==522||B==523||B==524||B==525||B==526||B==527||B==528||B==529||B==530||B==531||B==532||B==533||B==534||B==535||B==536||B==537||B==538||B==539||B==540||B==541||B==542||B==543||B==544||B==545||B==546||B==547||B==548||B==549||B==550||B==551||B==552||B==553||B==554||B==555||B==556||B==557||B==558||B==559||B==560||B==561||B==562||B==563||B==564||B==565||Β==566||B==567||B==568||B==569||B==570||B==571||B==572||B==573||B==574||B==575||B==576||B==577||B==578||B==579||B==580||B==581||B==582||B==583||B==584||B==585||B==586||B==587||B==588||B==589||B==590||B==591||B==592||B==593||B==594||B==595||B==596||B==597||B==598||B==599||B==600||B==601||B==602||B==603||B==604||B==605||B==606||B==607||B==608||B==609||B==610||B==611||B==612||B==613||B==614||B==615||B==616||B==617||B==618||B==619||B==620||B==621||B==622||B==623||B==624||B==625||B==626||B==627||B==628||B==629||B==630||B==631||B==632||B==633||B==634||B==635||B==636||B==637||B==638||B==639||B==640||B==641||B==642||B==643||B==644||B==645||B==646||B==647||B==648||B==649||B==650||B==651||B==652||B==653||B==654||B==655||B==656||B==657||B==658||B==659||B==660||B==661||B==662||B==663||B==664||B==665||B==666||B==667||B==668||B==669||B==670||B==671||B==672||B==673||B==674||B==675||B==676||B==677||B==678||B==679||B==680||B==681||B==682||B==683||B==684||B==685||B==686||B==687||B==688||B==689||B==690||B==691||B==692||B==693||B==694||B==695||B==696||B==697||B==698||B==699||B==700||B==701||B==702||B==703||B==704||B==705||B==706||B==707||B==708||B==709||B==710||B==711||B==712||B==713||B==714||B==715||B==716||B==717||B==718||B==719||B==720||B==721||B==722||B==723||B==724||B==725||B==726||B==727||B==728||B==729||B==730||B==731||B==732||B==733||B==734||B==735||B==736||B==737||B==738||B==739||B==740||B==741||B==742||B==743||B==744||B==745||B==746||B==747||B==748||B==749||B==750||B==751||B==752||B==753||B==754||B==755||B==756||B==757||B==758||B==759||B==760||B==761||B==762||B==763||B==764||B==765||B==766||B==767||B==768||B==769||B==770||B==771||B==772||B==773||B==774||B==775||B==776||B==777||B==778||B==779||B==780||B==781||B==782||B==783||B==784||B==785||B==786||B==787||B==788||B==789||B==790||B==791||B==792||B==793||B==794||B==795||B==796||B==797||B==798||B==799||B==800||B==801||B==802||B==803||B==804||B==805||B==806||B==807||B==808||B==809||B==810||B==811||B==812||B==813||B==814||B==815||B==816||B==817||B==818||B==819||B==820||B==821||B==822||B==823||B==824||B==825||B==826||B==827||B==828||B==829||B==830||B==831||B==832||B==833||B==834||B==835||B==836||B==837||B==838||B==839||B==840||B==841||B==842||B==843||B==844||B==845||B==846||B==847||B==848||B==849||B==850||B==851||B==852||B==853||B==854||B==855||B==856||B==857||B==858||B==859||B==860||B==861||B==862||B==863||B==864||B==865||B==866||B==867||B==868||B==869||B==870||B==871||B==872||B==873||B==874||B==875||B==876||B==877||B==878||B==879||B==880||B==881||B==882||B==883||B==884||B==885||B==886||B==887||B==888||B==889||B==890||B==891||B==892||B==893||B==894||B==895||B==896||B==897||B==898||B==899||B==900||B==901||B==902||B==903||B==904||B==905||B==906||B==907||B==908||B==909||B==910||B==911||B==912||B==913||B==914||B==915||B==916||B==917||B==918||B==919||B==920||B==921||B==922||B==923||B==924||B==925||B==926||B==927||B==928||B==929||B==930||B==931||B==932||B==933||B==934||B==935||B==936||B==937||B==938||B==939||B==940||B==941||B==942||B==943||B==944||B==945||B==946||B==947||B==948||B==949||B==950||B==951||B==952||B==953||B==954||B==955||B==956||B==957||B==958||B==959||B==960||B==961||B==962||B==963||B==964||B==965||B==966||B==967||B==968||B==969||B==970||B==971||B==972||B==973||B==974||B==975||B==976||B==977||B==978||B==979||B==980||B==981||B==982||B==983||B==984||B==985||B==986||B==987||B==988||B==989||B==990||B==991||B==992||B==993||B==994||B==995||B==996||B==997||B==998||B>=999);}

There's another crack out there, waiting to be found... Cracks:

- NaN (unintended)
- decimals

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

JavaScript (in Node.js), 65 bytes Cracked

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

Try it online!

'0'

Let's try another one: https://codegolf.stackexchange.com/a/135562/44718

\$\endgroup\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Haumed Rahmani Jul 25 '17 at 2:17
  • 1
    \$\begingroup\$ Beat me by one minute. \$\endgroup\$ – Grant Davis Jul 25 '17 at 2:19
  • 2
    \$\begingroup\$ @HaumedRahmani aha, not what i want, maybe i will post another cops.... T_T \$\endgroup\$ – tsh Jul 25 '17 at 2:21
  • \$\begingroup\$ @HaumedRahmani OK, just a mirror edit... codegolf.stackexchange.com/a/135562/44718 \$\endgroup\$ – tsh Jul 25 '17 at 2:25
1
\$\begingroup\$

J, 22 bytes, Cracked

$:@#~^:(0([=[e.{#])#~)

This will run forever assuming memory was unlimited, except when given a specific type of input.

\$\endgroup\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Conor O'Brien Jul 25 '17 at 2:46
  • \$\begingroup\$ You might want to suggest the user to test on TIO, this crashed my computer (at least on the windows version) \$\endgroup\$ – Conor O'Brien Jul 25 '17 at 2:51
  • \$\begingroup\$ @ConorO'Brien It continuously expands the array if it isn't the right input. It will continue to use more memory, and at least on my (Linux) machine, the process gets killed for using too much memory. \$\endgroup\$ – miles Jul 25 '17 at 2:54
  • \$\begingroup\$ Windows isn't that nice. (Also, the conditional fails for non-positive numbers and floats and infinity as well, all of which error) \$\endgroup\$ – Conor O'Brien Jul 25 '17 at 3:00
  • \$\begingroup\$ I think I found the intended solution and have edited into my answer \$\endgroup\$ – Conor O'Brien Jul 25 '17 at 3:03
1
\$\begingroup\$

Bash, 50 bytes (cracked)

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

Input is via command-line arguments.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ This may seem TIO specific, but it's not. The intended crack will work on all fresh Linux installs. \$\endgroup\$ – Dennis Jul 25 '17 at 3:32
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Veedrac Jul 25 '17 at 3:36
  • \$\begingroup\$ Well done, that was the intended solution. \$\endgroup\$ – Dennis Jul 25 '17 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\$
  • \$\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\$ – ETHproductions Jul 25 '17 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 Jul 25 '17 at 3:47
  • \$\begingroup\$ cracked! \$\endgroup\$ – Grant Davis Jul 25 '17 at 4:12
1
\$\begingroup\$

Befunge-98, 34 bytes, Possibly cracked

> #;de+294&:0\`#;_3*+*\-\0pqk$#q_

Unfortunately I couldn't get this to halt in TIO or CCBI, but it works in BefungeSharp. (If you can find a way to make it halt on TIO, mock me mercilessly) @ovs figured one out which depends on the fact that...

TIO does not implement the = instruction, making it behave like r. When the reversed IP encounters p, it deletes > from the program start, allowing the IP to run backwards to q_. This could be fixed by adding a leading space to the program (and replacing de+ with ee+).

To run the program:

  1. Save the above code to a file somewhere
  2. Run BefungeSharp (it will probably work under Wine)
  3. Press 2 (open file) and find the file you saved from before
  4. (Press any key to continue)
  5. Press a key from F2 to F5 to run (F2 = slow, F5 = fast)
  6. Hit F12 to stop execution, and alt-R to reload

The program won't halt on TIO or CCBI. (I blame ambiguous Funge-98 specs.) Inputs which crash BefungeSharp do not count.

& asks for a number, so input a number. To save you some time, the program ignores negatives.

\$\endgroup\$
  • \$\begingroup\$ It halts for 1 on TIO, but I don't think this is the intended solution. \$\endgroup\$ – ovs Jul 25 '17 at 11:39
  • \$\begingroup\$ Indeed, it is not, @ovs. Since I can't reproduce that in BefungeSharp, it's very difficult to figure out what's going on. I think that = causes the instruction pointer to reverse delta (proper way for an interpreter to handle unimplemented instructions). I hadn't thought of that, but I suppose it's valid! \$\endgroup\$ – Hactar Jul 25 '17 at 11:51
  • \$\begingroup\$ Does this have something to do with integer overflow? \$\endgroup\$ – pppery Jul 30 '17 at 3:08
  • \$\begingroup\$ @ppperry Nope. Just pure arithmetic and ASCII \$\endgroup\$ – Hactar Jul 30 '17 at 10:43
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
\$\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\$
  • \$\begingroup\$ Cracked \$\endgroup\$ – Cristian Lupascu Jul 25 '17 at 14:47
  • \$\begingroup\$ @w0lf intended solution doesn't involve using any custom objects, but nice job on that :) \$\endgroup\$ – Stephen Jul 25 '17 at 14:49
  • \$\begingroup\$ cracked \$\endgroup\$ – Dennis Jul 25 '17 at 14:50
  • \$\begingroup\$ @Dennis that's genius 0.o but not what I had in mind either \$\endgroup\$ – Stephen Jul 25 '17 at 14:51
  • \$\begingroup\$ cracked \$\endgroup\$ – Dennis Jul 25 '17 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\$
  • \$\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\$ – Eric Duminil Jul 25 '17 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 Jul 25 '17 at 9:22
  • 1
    \$\begingroup\$ codegolf.stackexchange.com/a/135687/967 \$\endgroup\$ – ecatmur Jul 25 '17 at 14:59
1
\$\begingroup\$

JavaScript (ES6), 119 bytes, Cracked

x=>{try{while(typeof x!="string");x=x.trim();while(!(x.length==6&&x[4]==" "&&eval(x)===undefined));}catch(e){for(;;);}}

While cracking this with the usual JavaScript prototype changing and object stuff is probably possible, the intended solution is a regular old string.

"void 0" evaluates to undefined.

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Cracked. Is this the intended solution? \$\endgroup\$ – programmer5000 Jul 25 '17 at 15:21
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
\$\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
\$\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\$

JS (ES6), 37 bytes (Cracked)

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

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

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

JavaScript, 52 bytes (Cracked again)

x=>{while(1){try{if(x&&1+x!==1+x)break;}catch(e){}}}
\$\endgroup\$
  • 1
    \$\begingroup\$ Cracked. \$\endgroup\$ – Veedrac Jul 25 '17 at 20:36
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\$
  • \$\begingroup\$ Bonus points for the provably smallest answer. \$\endgroup\$ – Veedrac Jul 25 '17 at 15:10
  • \$\begingroup\$ Really nice challenge! Cracked. \$\endgroup\$ – Cristian Lupascu Jul 25 '17 at 21:54
  • \$\begingroup\$ @w0lf Nice work yourself :). \$\endgroup\$ – Veedrac Jul 25 '17 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\$ – Cristian Lupascu Jul 26 '17 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\$ – Cristian Lupascu Jul 26 '17 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\$

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\$
1
\$\begingroup\$

R, 63 bytes (cracked)

f=function(x){set.seed(4);try(eval(x));x=rpois(1,1);while(x){}}
\$\endgroup\$
1
\$\begingroup\$

anyfix, 13 bytes Cracked

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

Try it online!

Another easy one, hopefully nobody just bruteforces it :(

-5

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

JavaScript, 28 bytes (Cracked here and here)

x=>{while(!(x&&1+x!==1+x));}

Both cracks were unexpected and I find them very clever (that's why I love this site). The crack I intended was {valueOf: function(){}}.

\$\endgroup\$
  • \$\begingroup\$ Cracked (the lazy way). \$\endgroup\$ – Veedrac Jul 25 '17 at 19:26
  • \$\begingroup\$ @Veedrac Great job! Although not exactly what I had in mind. I've added error handling - can you beat level 2? :) \$\endgroup\$ – Cristian Lupascu Jul 25 '17 at 20:13
  • \$\begingroup\$ Another Crack \$\endgroup\$ – tsh Jul 26 '17 at 5:37
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\$
  • \$\begingroup\$ 105263157894736842 \$\endgroup\$ – isaacg Jul 26 '17 at 6:21
  • \$\begingroup\$ @isaacg while true, can you make a post on the robbers thread that I can link to? \$\endgroup\$ – Magenta Jul 26 '17 at 6:41
  • \$\begingroup\$ This seems to work for more than one solution: 210526315789473684, 421052631578947368 and more \$\endgroup\$ – JAD Jul 26 '17 at 6:57
  • \$\begingroup\$ I added these solutions to a post on the robbers thread and edited the link. \$\endgroup\$ – JAD Jul 26 '17 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\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Veedrac Jul 26 '17 at 11:42
  • \$\begingroup\$ Also Cracked \$\endgroup\$ – Rift Jul 26 '17 at 11:44
  • \$\begingroup\$ @Rift oh damn, I thought I tested that, but I forgot the expression. \$\endgroup\$ – JAD Jul 26 '17 at 11:45
  • \$\begingroup\$ @JarkoDubbeldam you should not have included eval \$\endgroup\$ – Rift Jul 26 '17 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 Jul 26 '17 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\$
  • \$\begingroup\$ Help plz? Does the answer work on tutorialspoint.com/execute_smalltalk_online.php? For bonus niceness, does it halt within ~60s? \$\endgroup\$ – Veedrac Jul 26 '17 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 Jul 26 '17 at 21:50
  • \$\begingroup\$ "really easy". Why do I not trust you... :P \$\endgroup\$ – Veedrac Jul 26 '17 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 Jul 26 '17 at 22:40
  • 2
    \$\begingroup\$ Well I've found my new wallpaper. \$\endgroup\$ – Veedrac Jul 27 '17 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\$
  • \$\begingroup\$ Cracked. \$\endgroup\$ – Veedrac Jul 27 '17 at 1:20
  • \$\begingroup\$ @Veedrac Darn - not what I intended. I'll have to try again. \$\endgroup\$ – isaacg Jul 27 '17 at 2:29
1
\$\begingroup\$

Python 3, 67 characters (cracked)

An easy one, though this one is actually worth knowing so I thought I'd throw it in anyway.

import shutil,sys
while 1:shutil.copyfileobj(sys.stdin,sys.stdout)

Input goes in stdin.

\$\endgroup\$
  • \$\begingroup\$ Am I correct to assume that this will only work with certain locales? If so, cracked. \$\endgroup\$ – Dennis Jul 27 '17 at 3:32
  • \$\begingroup\$ @Dennis Yeah, I would have specified but I figured a hint wasn't needed on a question this simple. \$\endgroup\$ – Veedrac Jul 27 '17 at 3:43
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\$
  • \$\begingroup\$ Are we allowed to specify the template parameters to f when calling it? \$\endgroup\$ – Veedrac Jul 26 '17 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 Jul 26 '17 at 17:49
  • \$\begingroup\$ ... although my intended solution doesn't require any template arguments to be supplied. \$\endgroup\$ – ecatmur Jul 26 '17 at 18:10
  • 1
    \$\begingroup\$ Ugh, cracked I guess. \$\endgroup\$ – Veedrac Jul 26 '17 at 18:40
  • \$\begingroup\$ @Veedrac I didn't intend to allow reference types! Fixed to disallow those - want to have another go? \$\endgroup\$ – ecatmur Jul 26 '17 at 20:01
1
\$\begingroup\$

R, 134 bytes (cracked)

f=function(x)if(tryCatch(!is.function(x)|identical(x,q)|identical(x,quit)|identical(x,is.list)|!x(list()),error=function(e)1))repeat{}
\$\endgroup\$
  • \$\begingroup\$ Cracked? \$\endgroup\$ – Mischa Jul 26 '17 at 14:41
  • \$\begingroup\$ @MischaBehrend Not the intended solution, and arguably not even a solution, since the quitting happens in the definition of the argument, not while executing the function. \$\endgroup\$ – JAD Jul 27 '17 at 7:31
  • \$\begingroup\$ Cracked? by @CriminallyVulgar. \$\endgroup\$ – TheLethalCoder Jul 27 '17 at 13:01
  • \$\begingroup\$ Cracked. I didn't consider that option. Since my intended solution isn't found, I'll make a new version without showing it here. \$\endgroup\$ – JAD Jul 27 '17 at 13:12
1
\$\begingroup\$

CPython 3.6, 634 bytes, Cracked

Fixed a misplaced try: statement that allowed 1/0 and even no input to break things. Original.

try:j=input();__builtins__.__dict__["__import__"]=eval(j);import random,functools,itertools,zlib;exec("@functools.lru_cache(None)\ndef f():i=input();return(all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[::2])))if'_'not in x),sorted{}))\nand all(x is y for x,y in itertools.zip_longest((x for x in sorted(dir(eval(i[1::2])))if'_'not in x),sorted{}))and 8 and zlib.crc32(bytes(i,'ASCII'))==zlib.crc32(bytes(j,'ASCII')))".format(*eval('('+"(tuple(''.join(random.choice('abcdefghijklmnopqrstuvwxyz')for x in range%s)for x in range%s),),"%(("(random.randint(1,9))",)*2)*2+')')));f()
except:f=bool
while not f():8
\$\endgroup\$
  • \$\begingroup\$ Nice try, but cracked \$\endgroup\$ – pppery Jul 26 '17 at 15:48
  • \$\begingroup\$ @ppperry That is indeed a valid solution. \$\endgroup\$ – wizzwizz4 Jul 26 '17 at 15:54
  • \$\begingroup\$ @wizzwizz4 From the question: If a robber cracks your submission, please mark it as cracked and show the halting input (in a > ! spoiler quote). (this will make the included snippet behave correctly) \$\endgroup\$ – NieDzejkob Jul 27 '17 at 17:06
  • \$\begingroup\$ @NieDzejkob Oops! I forgot to do that. Fixed. \$\endgroup\$ – wizzwizz4 Jul 27 '17 at 17:21
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\$
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$ – Gregor - reinstate Monica Jul 27 '17 at 19:57
  • \$\begingroup\$ @Gregor nicely done! See if you can crack this! \$\endgroup\$ – JAD Jul 27 '17 at 20:36

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.