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

57
\$\begingroup\$

Malbolge, 128 bytes, cracked by KBRON111

(=&r:#o=~l4jz7g5vttbrpp^nllZjhhVfddRb`O;:('JYX#VV~jS{Ql>jMKK9IGcFaD_X]\[ZYXWVsN6L4J\[kYEhVBeScba%_M]]~IYG3Eyx5432+rpp-n+l)j'h%B0

Have fun!

(Yes, I learned Malbolge just for this. Yes, it took an absurdly long time to finally get working. And yes, it was totally worth it.)

Wrapped, so you can see it in its full, er, "glory":

(=&r:#o=~l4jz7g5vttbrpp^nllZjhhV
fddRb`O;:('JYX#VV~jS{Ql>jMKK9IGc
FaD_X]\[ZYXWVsN6L4J\[kYEhVBeScba
%_M]]~IYG3Eyx5432+rpp-n+l)j'h%B0

I used this interpreter to test it; I'm not sure if it matters, but I figured I'd specify just in case.

\$\endgroup\$
5
  • 2
    \$\begingroup\$ That's the interpreter TIO uses btw. \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 4:59
  • 2
    \$\begingroup\$ oh, "Have fun" is good addition \$\endgroup\$ Commented Jul 25, 2017 at 5:37
  • 27
    \$\begingroup\$ You're a jerk. Malbolge is mean. \$\endgroup\$ Commented Jul 25, 2017 at 13:21
  • 1
    \$\begingroup\$ I'm stamped... The farthest I got: out of 13 inputs before halt, only first and third have any impact. After thorough reverse-engineering, I found that first input has to be 6 and the third is one of the four: !, #, / and -. But the combination doesn't seem to fix the halt. I put it out here, maybe someone smarter finds a solution. If anyone wants, I will post tomorrow how I got to these inputs. EDIT: Now that I think about it, my program I wrote for purpose of reverse-engineering this might have a bug, and the first input may be something else than 6. Third character still stands. \$\endgroup\$ Commented Jul 26, 2017 at 22:56
  • 8
    \$\begingroup\$ Cracked by KBRON111. \$\endgroup\$
    – Veedrac
    Commented Jul 27, 2017 at 2:32
24
\$\begingroup\$

JavaScript (ES6), 17 bytes, Cracked

x=>{for(;x==x;);}

On TIO, since I dunno how to do Node.js readline on TIO, just stick the input in the function call. This is obvious to anyone who knows it, and not to anyone who doesn't.

Try it online!

Answer:

The answer is NaN, since in JavaScript, NaN != NaN.

\$\endgroup\$
8
  • 2
    \$\begingroup\$ Cracked. Nice usage of a language oddity! \$\endgroup\$
    – user58826
    Commented Jul 24, 2017 at 16:14
  • 3
    \$\begingroup\$ You bet :) I like how you were so confident that's what I picked that you edited it in for me :P \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 16:15
  • 14
    \$\begingroup\$ NaN == NaN is false in many languages other than JavaScript. I wouldn't call it a "language oddity". \$\endgroup\$
    – Nayuki
    Commented Jul 25, 2017 at 3:29
  • 11
    \$\begingroup\$ i believe NaN != NaN is a feature of floating point numbers \$\endgroup\$ Commented Jul 25, 2017 at 20:39
  • 2
    \$\begingroup\$ @undergroundmonorail: That's correct. The relation between two IEEE floating point numbers can be above, equal, below, or unordered. The comparison result is unordered if either or both operands are any kind of NaN. (IEEE 754 binary floating point has many NaN bit patterns: anything with the exponent all-ones and a non-zero mantissa is a NaN, regardless of the sign bit. There are some rules for which what goes into the "payload" of a NaN, and for propagating that through operations like + or max(), but most people don't care :P) \$\endgroup\$ Commented Jul 27, 2017 at 9:19
16
\$\begingroup\$

JS (ES6), 67 bytes (Cracked)

(x,y)=>{while(x!==y||Object.is(x, y)||!isFinite(x)||!isFinite(y));}

I think i didn't mess up, it might have an easy solution that I didn't see.

I appreciate any feedback, this is one of my first posts

(+0, -0) Yep, js has a negative 0

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Cracked \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 16:56
  • \$\begingroup\$ I realize now that I don't need to check if x and y are finite, but I won't edit since it was already cracked. Could have been 38 bytes \$\endgroup\$
    – Juan
    Commented Jul 24, 2017 at 17:22
12
\$\begingroup\$

Python 3.4, (40 bytes) Cracked

def f(x):
  while(x==x or not x==x):pass
\$\endgroup\$
6
  • 4
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ Commented Jul 24, 2017 at 20:56
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Jul 24, 2017 at 21:31
  • 14
    \$\begingroup\$ I feel like you should have stored x==x in a variable called to_be, so you could make a Hamlet reference. \$\endgroup\$ Commented Jul 27, 2017 at 9:26
  • 1
    \$\begingroup\$ @PeterCordes But that would have made the answer uncrackable \$\endgroup\$ Commented Jul 30, 2017 at 3:03
  • \$\begingroup\$ @ppperry: yeah, I noticed that after I looked at the crack. :P \$\endgroup\$ Commented Jul 30, 2017 at 3:06
10
\$\begingroup\$

Javascript (NOT node.js)

x=>{while(x+"h");}

The desired submission doesn't use throw.

Hint for desired crack:

The desired submission doesn't overwrite .toString(), or use Set() either.

Desired crack:

Object.create(null)

\$\endgroup\$
15
  • \$\begingroup\$ Correct crack link (not mine, just a link to Dom Hasting's answer) \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 19:56
  • \$\begingroup\$ Cracked#2 Cracked without using throw (still gives an error though) \$\endgroup\$ Commented Jul 24, 2017 at 20:27
  • \$\begingroup\$ Cracked again without using throw, I believe for real this time as Grant Davis' didn't work for me. Still TypeErrors. \$\endgroup\$ Commented Jul 25, 2017 at 1:19
  • 2
    \$\begingroup\$ You could do x=>{try{for(;x+"h";)}catch(e){for(;;)}} so that any errors will result in an endless loop so missing prototype function errors (or any errors) will result in an endless loop. \$\endgroup\$ Commented Jul 25, 2017 at 3:22
  • 1
    \$\begingroup\$ This one only works in the browser, not sure why it does though :D \$\endgroup\$
    – jadkik94
    Commented Jul 26, 2017 at 14:00
9
\$\begingroup\$

C (gcc), 75 bytes Cracked

#include<stdio.h>
int main(){char c[9];while(1){scanf("%8s",c);printf(c);}}

Try it online!

I've never posted in a cops-n-robbers before. Hopefully this isn't too obvious.

Solution:

An input of "%s" makes this segfault. There are several other ones that can be used; all of them are printf specifiers like "%n"
This is the classic printf vulnerability. Simply put, the format string comes straight from user input, so any printf specifiers get passed through, unsafely.

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

JavaScript (in Browser), 79 bytes Cracked

x=>{try{for(;x||x!=null||x!=void 0||x===null||x===void 0;);}catch(e){for(;;);}}

You should run it in a recent browser (like latest Firefox ESR, latest Firefox, latest Chromium). Running on old browsers (like Netscape 2, IE 4) do not count.

Note: Halted by browser due to time out do not count a halt here.

Always be careful not crash your browser when testing this codes, and happy robbing ^_^

document.all

\$\endgroup\$
7
  • \$\begingroup\$ Can i use setTimeout? \$\endgroup\$ Commented Jul 25, 2017 at 7:09
  • \$\begingroup\$ @ЕвгенийНовиков You may call this function with any parameter. But it seems use setTimeout as parameter do not works. \$\endgroup\$
    – tsh
    Commented Jul 25, 2017 at 7:15
  • \$\begingroup\$ idea is to do var key=(()=>{setTimeout(args);return null})() and then crackme(key) \$\endgroup\$ Commented Jul 25, 2017 at 9:55
  • \$\begingroup\$ seems like cheating \$\endgroup\$ Commented Jul 25, 2017 at 9:56
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Juan
    Commented Jul 25, 2017 at 16:33
7
\$\begingroup\$

PHP (cracked by Vicente Gallur Valero), 65 bytes

<?php
parse_str($argv[1],$_);
while(!$_['(-0_0)> deal with it']);

Try it online!

Harder than it may look. Edited to be possible on TIO, at the cost of a bunch of bytes. Takes input via $argv[1].

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

Bash 4.2, 14 bytes (cracked)

Let's try this again.

let ${1,,}
yes

This doesn't work on TIO, which uses Bash 4.3. Input is via command-line arguments.

On Linux and with gcc installed, Bash 4.2.53 can be downloaded and built as follows.

curl -sSL https://ftp.gnu.org/gnu/bash/bash-4.2.53.tar.gz | tar xz
cd bash-4.2.53
./configure
make -j
\$\endgroup\$
1
  • \$\begingroup\$ Cracked. Basically ended up reading the source. \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 2:39
6
\$\begingroup\$

Husk, 5 bytes Cracked

↑ε∞←ø

Try it online!

A bit of explanation, since this language is still pretty new:

←ø gets the first element of an empty list: this returns a value which can assume any type, be it a concrete type or a function, which will then be applied to the input. creates an infinite list composed by copies of the previous result (which in most cases will mean a list of infinite zeroes). ↑ε takes elements from this list as long as they are "small" i.e. their absolute value is ≤1; on an infinite list of zeroes this will never stop.

\$\endgroup\$
2
  • \$\begingroup\$ @Veedrac that was actually my intended solution \$\endgroup\$
    – Leo
    Commented Jul 26, 2017 at 8:02
  • \$\begingroup\$ Well, then, cracked! \$\endgroup\$
    – Veedrac
    Commented Jul 26, 2017 at 11:27
5
\$\begingroup\$

Braingolf, 4 bytes (Cracked)

[1+]

Try it online!

Suuuper easy, but let's see how long it takes

Answer:

-1, or any number less than 0.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – user58826
    Commented Jul 24, 2017 at 15:59
5
\$\begingroup\$

Ruby, 31 bytes (cracked by Eric Duminil)

0until(3.send(gets)==5rescue p)

Try it online!

Note that this needs to be run in an environment where there's no trailing newline in the result of gets, or else it's impossible to make it halt (I think) since anything ending in a newline will error and hit the rescue.

\$\endgroup\$
3
  • \$\begingroup\$ Cracked! \$\endgroup\$ Commented Jul 24, 2017 at 22:14
  • \$\begingroup\$ Nice one by the way! No method in 3.methods returns 5 or exits the loop. \$\endgroup\$ Commented Jul 24, 2017 at 22:29
  • \$\begingroup\$ Darn! I discovered the solution as well independently, but I was too focused on making it equal 5 to think that the correct answer would involve the function that it did... \$\endgroup\$
    – Value Ink
    Commented Jul 25, 2017 at 3:32
5
\$\begingroup\$

Bash, 25 bytes (Cracked)

export "$1"=help
/bin/yes

Inspired by Dennis'. Try it online.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked! \$\endgroup\$
    – Sisyphus
    Commented Jul 25, 2017 at 11:57
4
\$\begingroup\$

Retina, 78 bytes (Cracked) (Cracked with Intended Solution)

^
1
+`^1(1+)
$1¶$&
s`(?<=^|¶)(1+)(?=¶)(?!.*¶\1+$)

¶(?!1+$)

^(1+)¶\1$

+`1
11

Was pretty fun to write, hope it's fun to crack

Try it online!

Cracked with an unintended solution and the intended solution within a minute of each other. One posted first, one commented first.

Intended solution:

11111 or the unary representation of n-1 where n is any perfect number

\$\endgroup\$
4
  • \$\begingroup\$ Cracked \$\endgroup\$
    – mbomb007
    Commented Jul 24, 2017 at 16:32
  • \$\begingroup\$ Cracked \$\endgroup\$
    – user41805
    Commented Jul 24, 2017 at 16:32
  • \$\begingroup\$ So whose crack counts? (I posted the crack first, but mbomb007 commented first) \$\endgroup\$
    – user41805
    Commented Jul 24, 2017 at 16:33
  • \$\begingroup\$ @Cowsquack both \$\endgroup\$
    – user58826
    Commented Jul 24, 2017 at 16:35
4
\$\begingroup\$

Node.js, 23 bytes (Cracked)

var crackme =
i=>{while({[i]:NaN}){}}

Grant Davis solution

{__proto__:null}

My solution

{"toString":process.exit}

\$\endgroup\$
2
  • 2
    \$\begingroup\$ cracked! \$\endgroup\$ Commented Jul 25, 2017 at 2:08
  • \$\begingroup\$ @GrantDavis good job) Your solution works i browser too. I thought to surround it with try-catch, but refused this idea, to make a pretty code. \$\endgroup\$ Commented Jul 25, 2017 at 5:32
4
\$\begingroup\$

Java 8, 99 bytes, Cracked

s->{try{Integer i=Integer.parseInt(s),c=i+32767;i+=32767;for(;i!=c;);}catch(Throwable t){for(;;);}}

This is a lambda of the type Consumer<String>.

Ungolfed:

s -> {
    try {
        Integer i = Integer.parseInt(s), c = i + Short.MAX_VALUE;
        i += Short.MAX_VALUE;
        while (i != c) ;
    } catch (Throwable t) {
        while (true) ;
    }
}

Try it online! (note that the test program will crash on empty input, but the lambda itself would not!) (also, use 'arguments' not 'input' on TIO, as the test program uses arguments, not STDIN)

Intended Answer:

-32767; This works because Java keeps has two integer types, int and Integer. Integer is an object that wraps int. Also, Java keeps an cache of Integers that box -127 through 127. The != operator checks for identity, so through some un-boxing and auto-boxing any number x where x + 32767 is in [-127, 127] will end up being the same Integer object from the cache, and thus i != c will be false.

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

Bash 4.2, 10 bytes (Cracked)

let $1
yes

This doesn't work on TIO, which uses Bash 4.3. Input is via command-line arguments.

On Linux and with gcc installed, Bash 4.2.53 can be downloaded and built as follows.

curl -sSL https://ftp.gnu.org/gnu/bash/bash-4.2.53.tar.gz | tar xz
cd bash-4.2.53
./configure
make -j
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Cracked. You led me 'round in circles thinking this was shellshock related and linking me to a patched version :P. Count the unintended crack as petty revenge ;). \$\endgroup\$
    – Veedrac
    Commented Jul 25, 2017 at 10:36
  • \$\begingroup\$ Heh, not quite what I was going for. I posted a hardened version if you want to give it a try. \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 13:20
4
\$\begingroup\$

C, 140 bytes (Cracked)

n,i;f(){float x,y,z;for(scanf("%d %d",&n,&z,x=y=0);~((int)x-(int)(1/sqrt(y*2)));x*=(1.5-y*x*x))y=(x=z)/2,i=n-((*(int*)&x)/2),x=*(float*)&i;}

Hopefully there aren't too many not-even-close-to-the-intended-inputs that make it halt, but let's see.

Try it online!

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

Java: 1760 (Cracked)

I feel it's too mean to golf this one, so I just obfuscated the variable names, and made it 'messy'. As a matter of fact it's so mean, that I'm going to post hints over time, just so I may see it cracked.

Hint 1: this has theoretically infinite valid inputs, but there is one that is the most 'Correct'


public class Main {

	public static void main(String[] a) {
		try {
			while (a.length < 2) {
				int i = 0;
			}
			boolean invalid = 1 < 0;
			char l = '_';
			char h = '-';
			char[] DATATWO = a[0].toCharArray();
			char[] DATATOW = a[1].toCharArray();
			int length = DATATOW.length;
			if (DATATWO.length != length) {
				invalid = 1 > 0;
			}
			int transmissionStartIndex = 0;
			for (int i = 0; i < length; i++) {
				if (DATATWO[i] == l && DATATOW[i] == l) {
					transmissionStartIndex = i;
					break;
				}
			}
			int DATAONE = 0, reg = 0;
			boolean read = 1 < 0, full = 0 < 1;
			int bytes_read = 0;
			for (int i = transmissionStartIndex; i < length; i++) {
				if (DATATOW[i] == l && DATATOW[i + 1] == h) {
					bytes_read++;

					if (bytes_read == 8) {
						read = DATATWO[i] == h;
					} else if (bytes_read == 9) {
						invalid = (DATATWO[i] == h || invalid);
						System.out.println(invalid);
					} else if (bytes_read == 18) {
						System.out.println(invalid);
						invalid = (DATATWO[i] == h || invalid);
						if (invalid) {
							System.out.println("i36 " + DATATWO[i] + " " + h);
						}
						full = 1 > 0;
					} else if (bytes_read < 8) {
						DATAONE += (DATATWO[i] == h ? 1 : 0) << (7 - bytes_read);
					} else if (bytes_read < 18) {
						reg += (DATATWO[i] == h ? 1 : 0) << (8 - (bytes_read - 9));
					} else if (bytes_read > 18) {
						invalid = 1 > 0;
					}
					System.out.println(a[0]);
					System.out.println(new String(new char[i]).replace("\0", " ") + "|");
					System.out.println(a[1]);
				}
			}

			while (!(Integer.toHexString(DATAONE).equals("0x2b") && (read)
					&& Integer.toHexString(reg).equals("0xa6"))) {

				System.out.println(System.currentTimeMillis());
				try {
					Thread.sleep(1);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}

		} catch (Exception e) {
			while (true) {
			}
		}

	}
}

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Two empty arguments seem to work \$\endgroup\$
    – Okx
    Commented Jul 24, 2017 at 17:09
  • \$\begingroup\$ Also, mind adding a tio link? I think all you'd need to do is change main to Main \$\endgroup\$
    – Okx
    Commented Jul 24, 2017 at 17:24
  • 1
    \$\begingroup\$ Cracked, apart from a bug. \$\endgroup\$ Commented Jul 24, 2017 at 17:40
  • \$\begingroup\$ Cracked - no version specific bug. \$\endgroup\$
    – Okx
    Commented Jul 24, 2017 at 17:41
3
\$\begingroup\$

Braingolf, 18 bytes Cracked

1+[#£-0!e>:$_1>|]

Try it online!

Liiiitle bit harder than the last one, I'll start writing a real one after this

The answer is 163

\$\endgroup\$
5
  • \$\begingroup\$ Man, this is probably the only surviving submission atm. Note: i doesn't work. \$\endgroup\$ Commented Jul 24, 2017 at 17:14
  • \$\begingroup\$ Warning: this is actually 19 bytes (£). And why doesn't -1 work? This is tricky. \$\endgroup\$ Commented Jul 24, 2017 at 17:20
  • \$\begingroup\$ @EriktheOutgolfer It's 17 characters and 18 bytes. \$\endgroup\$ Commented Jul 24, 2017 at 17:25
  • \$\begingroup\$ @totallyhuman I swear I had read "19 UTF-8 bytes, 18 chars" (userscript is enabled)... \$\endgroup\$ Commented Jul 24, 2017 at 18:09
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Adnan
    Commented Jul 24, 2017 at 18:14
3
\$\begingroup\$

JavaScript (ES7), 41 bytes (Hacked & Cracked)

Edit: fixed to prevent it from crashing when given no input at all (thanks @totallyhuman for noticing)


Several solutions probably exist, but the expected one is relatively simple.

(x=0)=>{for(;~x/x.length**3!=-2962963;);}

Intended solution:

"8e7" (a number in scientific notation passed as a string)
Because: ~"8e7"/"8e7".length**3 = -80000001/3**3 = -80000001/27 = -2962963

\$\endgroup\$
4
  • 2
    \$\begingroup\$ No input works on this one too, but I don't want to bother cracking it like that... Unless, that's the intended solution. :P \$\endgroup\$ Commented Jul 24, 2017 at 17:30
  • \$\begingroup\$ @totallyhuman Well, it's not the intended solution. :-) \$\endgroup\$
    – Arnauld
    Commented Jul 24, 2017 at 17:37
  • \$\begingroup\$ Hacked codegolf.stackexchange.com/a/135432/71612 \$\endgroup\$ Commented Jul 24, 2017 at 18:24
  • 2
    \$\begingroup\$ Update: got intended 3 bytes long solution \$\endgroup\$ Commented Jul 24, 2017 at 19:53
3
\$\begingroup\$

Bash + Utils (Cracked by Dennis), 74 bytes

I hope you enjoy tar, because it's the only utility you can use.

cp /bin/tar .
env -i PATH=$PWD I=$? /bin/bash -r -c "$1"
while :;do :;done

Try it online!

Intended crack

tar -cf --checkpoint=1 --checkpoint-action=exec="/bin/kill $I" .

\$\endgroup\$
2
  • 1
    \$\begingroup\$ cracked \$\endgroup\$
    – Dennis
    Commented Jul 25, 2017 at 6:45
  • \$\begingroup\$ @Dennis Nice! I posted my intended crack, which was a bit more complex. \$\endgroup\$
    – Sisyphus
    Commented Jul 25, 2017 at 6:49
3
\$\begingroup\$

Mathematica, 36 26 bytes (cracked)

#0[#;$IterationLimit=∞]&

A very short loop #0[#;∞] that will just keep running itself over and over until it crashes your kernel... (The $IterationLimit is just to make sure you get stuck forever for most inputs).

Try it on Wolfram Sandbox! - if you are stuck in an infinite loop, you can wait until you time out, or you can press the square "abort evaluation" icon to the left of the notebook title (unnamed).

NOTE: this function changes your $IterationLimit settings.

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

JavaScript (Node.js), 18 bytes (Cracked)

x=>{while(x+"h");}

Try it online! Answer:

new Buffer(268435440) throws an error when .toStringed.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 19:05
  • \$\begingroup\$ Also, Symbol() would work. \$\endgroup\$ Commented Jul 27, 2017 at 22:28
3
\$\begingroup\$

C#, 118 bytes (Cracked)

using System;_=>{while(1>0){try{if(Nullable.GetUnderlyingType(Type.GetType(Console.ReadLine()))!=null)break;}catch{}}}

I don't expect this to last too long but it is more awkward than it appears to be.

Basically any Nullable classes full name works but it is awkward to find out as it looks like the below :
System.Nullable`1[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
An easier way to find this string out is to do typeof(int?).FullName.

\$\endgroup\$
1
  • \$\begingroup\$ Cracked \$\endgroup\$
    – Luc
    Commented Jul 25, 2017 at 21:15
3
\$\begingroup\$

JavaScript (ES7), 73 bytes (Cracked!)

q=>{r=(n,i=0)=>i>1e3?n:r(n*16807%(2**31-1),i+1);while(r(q)!=627804986){}}

Not wanted solutions: brute force. Desired crack involves math.

Note that there are many solutions (4194304) because of modulo.

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

brainfuck, 170 bytes cracked!

>>,>,>,>,>,[-----------<-<+<--<--->>>>]<++<<+<++[----->+<]>[----------------->+++++++<]>[----->>+<<]>>[-<->]<[--->++++++<]>[--->+<]+>-[-----------------<+>]<[-->-<]>+[+-]

Try it online!

\$\endgroup\$
6
  • \$\begingroup\$ Welcome to the site! You could save 11 bytes by removing the newlines from your code. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 29, 2017 at 18:00
  • \$\begingroup\$ I forgot it was code golf, thanks! \$\endgroup\$
    – Jerry
    Commented Jul 29, 2017 at 18:05
  • \$\begingroup\$ Cracked \$\endgroup\$
    – user202729
    Commented Jul 30, 2017 at 5:21
  • \$\begingroup\$ Valid solution! I estimate there are quite a bit of them. For anyone solving/brute-forcing, the intended one is [a-z]. \$\endgroup\$
    – Jerry
    Commented Jul 30, 2017 at 13:15
  • \$\begingroup\$ For each 4 characters, there are exactly 1 value of the last character makes the program halt. Therefore there are 256^4 = 4294967296 solutions assuming you can enter nul into brainfuck. BTW you can remove two first > save 2 bytes. \$\endgroup\$
    – user202729
    Commented Jul 30, 2017 at 15:20
3
\$\begingroup\$

Swift 3, 14 bytes (Cracked)

while !false{}

To solve this, put your code before or after this statement.

  • Your solution must:
    • keep this statement intact, without modifying its code
    • actually let this statement run
      • Simply commenting it out, calling fatalError(), etc. before it doesn't count.
    • modify the behavior of this statement to prevent it from looping forever
  • The solution does not involve crashing the program.
\$\endgroup\$
5
  • \$\begingroup\$ I don't know Swift, but I think adding a timer before this code to exit after a few seconds would meet the criteria. \$\endgroup\$
    – user15259
    Commented Jul 28, 2017 at 10:03
  • \$\begingroup\$ @Yimin heh, clever, but it doesn't modify the semantics of this statement, which is what I was really looking for when I said "modifies the behaviour of this statement" \$\endgroup\$
    – Alexander
    Commented Jul 28, 2017 at 14:32
  • \$\begingroup\$ Are you sure that the solution works? The interpreter is yelling ambiguous semantics at me. \$\endgroup\$
    – Daniel
    Commented Jul 28, 2017 at 15:21
  • \$\begingroup\$ @Dopapp that's what I thought would happen in my previous attempt. For some reason, it's legal to redefine new infix operators with the same type signatures as those that already exist, but attempting to do the same with a unary operator throws a compile time ambiguity error. This is intentional, and I'm sure I have a working solution \$\endgroup\$
    – Alexander
    Commented Jul 28, 2017 at 15:24
  • \$\begingroup\$ Cracked. \$\endgroup\$
    – Veedrac
    Commented Jul 31, 2017 at 3:20
2
\$\begingroup\$

cQuents, 2 bytes (Cracked 1) (Cracked 2)

:A

Note that this will quickly hit the 128 KiB output limit on TIO, causing it to stop, but when run locally it will loop forever, except on the input that breaks it. Finding that input should be fairly easy. Until you do, :A will keep sticking its triangular tongue out at you.

Note also that this should be just A but I broke implicit modes last night. On older interpreter versions A would work fine.

Cracks:

Empty input/newline on input is a valid crack. However, barring that, by passing multiple (space separated) inputs to the program, you'll terminate it (if you give 2) or error out (if you give 3 or more).

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Cracked? (Errors out with empty input) \$\endgroup\$
    – Luis Mendo
    Commented Jul 24, 2017 at 16:47
  • \$\begingroup\$ Cracked? \$\endgroup\$
    – user41805
    Commented Jul 24, 2017 at 16:47
  • \$\begingroup\$ @crackers yep, that's a valid crack. I'll give my upvote to someone who finds the non-empty-input crack though. \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 16:48
  • \$\begingroup\$ Cracked (the intended way?) \$\endgroup\$ Commented Jul 24, 2017 at 17:11
2
\$\begingroup\$

JavaScript (Node.js), 28 bytes Cracked

x=>{while(!x||x.__proto__);}

Try it online!

Know of anything truthy that dosen't have the __proto__ property?

\$\endgroup\$
5
  • \$\begingroup\$ Cracked \$\endgroup\$ Commented Jul 24, 2017 at 22:36
  • \$\begingroup\$ I'm curious, what was the intended solution? Or do you feel like waiting for someone to find it? \$\endgroup\$ Commented Jul 24, 2017 at 22:51
  • \$\begingroup\$ @ConorO'Brien trying to use the intended ans on something else. \$\endgroup\$
    – user58826
    Commented Jul 24, 2017 at 22:54
  • 1
    \$\begingroup\$ Cracked (not by me, user with not enough rep to comment) \$\endgroup\$
    – Stephen
    Commented Jul 24, 2017 at 23:02
  • 1
    \$\begingroup\$ Cracked \$\endgroup\$
    – Neil
    Commented Jul 25, 2017 at 11:43

Your Answer

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