# Will it halt? (Robbers)

Your challenge is to crack a cop's submission by finding an input that makes it halt. You don't have to find out why, or all inputs that make it halt if there's more than one, or the input the cop intended, just one input will do.

Once you have cracked a submission, post a link to it in a comment or edit to the cop's post. You can also flag your submission for a mod to edit it in the cop's post. Also, post the input used and a link to the cop's post in an answer in this thread. The robber that cracks the most submissions wins.

Multiple people can post cracks to the same cop submission, as long as they are different.

(If SE converted your duplicate answer to a comment, you may want to vote on this feature request)

# 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.innerText = 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>

• Does different mean different inputs (say, all inputs ending with 2 crack the cop's post - can you different people post different numbers ending in 2?) or different families of inputs, or different types of inputs? Jul 24 '17 at 17:03
• Multiple people can post cracks to the same cop submission... Please define different. Jul 25 '17 at 13:41
• @NoOneIsHere codegolf.meta.stackexchange.com/q/13437/58826
– user58826
Jul 25 '17 at 15:26

# Husk, Leo

Pass 4 arguments! It only works with 0-3. You can't do it with less because the arguments aren't actually used.

Try it online.

# JavaScript, programmer5000

window[0]


Works on the Code Golf StackExchange page on Firefox (i.e. while(window[0] + "h"); throws a Error: Permission denied to access property Symbol.toPrimitive error in the console and exits)

• window apparently doesn't implement the [Symbol.toPrimitive] function (which is used when converting an object to a string) - nice find! Jul 26 '17 at 14:02
• @Birjolaxew it's not window; see !!(window + "h") === true. Not sure what it is. Found it by looking at all the window attributes. I was sure one would fail because of a security exception or cross domain stuff. Jul 26 '17 at 14:06

# BASIC, Stilez

https://www.youtube.com/watch?v=9NcPvmk4vfo


This input halts the program. Weird choice, but it works.

• Ah nooooo! And its the 8 b8t version!! :) Jul 26 '17 at 17:34

# Swift 3, Alexander

extension Bool {
prefix static func !(val: Bool) -> Bool {
return false
}
}


• Wow, defining the operation in an extension on Bool doesn't cause an ambiguity error, but defining it as a free function does. Odd. This wasn't what I had in mind, but well done, though! Jul 31 '17 at 3:43

# brainfuck, Jerry

B0000


Try it online!

Edit: This is the list of all 5-character input that makes the program halts, in range [a..z]: (Warning: large text file)

And this is all input in WordData[] of Mathematica 10:

{"aesop", "agape", "annon", "cloak", "daunt", "fagus", "filch", \
"gomel", "hijab", "jakes", "jerry", "rebut", "rover", "ruddy", \
"sewed", "trine", "villa"}


Perhaps jerry is the expected input.

Explanation:

First, we can see that there are 5 , signs in the program, therefore 5 characters are required. Call their character code {i0, i1, i2, i3, i4} respectively.

And, to "decrypt" the code:

>>,>,>,>,>,                     m0 = i0; m1 = i1; m2 = i2; m3 = i3; m4 = i4;
[-----------<-<+<--<--->>>>]    m3 -= m4 / 11; m2 += m4 / 11; m1 -= 2*m4 / 11; m0 -= 3*m4 / 11; m4 = 0;
<++<<+<++                       m3 += 2; m1 ++; m0 += 2;
[----->+<]                      m1 += m0 / 5; m0 = 0;
>
[----------------->+++++++<]    m2 += 7*m1 / 17; m1 = 0;
>
[----->>+<<]                    m4 += m2 / 5; m2 = 0;
>>
[-<->]                          m3 -= m4; m4 = 0;
<
[--->++++++<]                   m4 += 6*m3 / 3; m3 = 0;
>
[--->+<]                        m5 += m4 / 3; m4 = 0;
+>-                             m4 ++; m5 --;
[-----------------<+>]          m4 += m5 / 17; m5 = 0;
<
[-->-<]                         m5 -= m4 / 2; m4 = 0;
>+                              ++m5;
[+-]                            while (m5 != 0);


Where initially the tape has the form

... m-2 m-1 m0 m1 m2 m3 m4 m5 ...
^ (data pointer at initial position = m-2)


So, input

m5 = 0;
m0 = i0; m1 = i1; m2 = i2; m3 = i3; m4 = i4;
m3 -= m4/11; m2 += m4/11; m1 -= 2*m4/11; m0 -= 3*m4/11; m4 = 0;
m3 += 2; m1++; m0 += 2;
m1 += m0/5; m0 = 0;
m2 += 7*m1/17; m1 = 0;
m4 += m2/5; m2 = 0;
m3 -= m4; m4 = 0;
m4 += 6*m3/3; m3 = 0;
m5 += m4/3; m4 = 0;
m4++; m5--;
m4 += m5/17; m5 = 0;
m5 -= m4/2; m4 = 0;
++m5;


(note: over modulo 256, all divisions will halt, except the m5 -= m4/2 is because of at that point m4 is even)

into Mathematica gives

m5 = (117414 + 77 i0 + 385 i1 + 935 i2 - 4675 i3 + 419 i4)/238425


m5 == 0 can be transformed to (mod 256)

i4 := Mod[222 + 177 i0 + 117 i1 + 211 i2 + 225 i3, 256]


Loop i0, i1, i2, i3 through all combination of a..z gives 46413 results, of which 17 of them are English words.

# JS (Node.js)

NaN


In JS, NaN !== NaN

# Retina

A newline followed by a 1 works. I found it right away.


1

Try it online

• Ninja'd by a minute Jul 24 '17 at 16:33
• @Cowsquack The question says multiple cracks for the same cop post are allowed. Jul 24 '17 at 16:40
• I knew I should have removed newlines from the input as a first step Jul 24 '17 at 16:46

# JS (ES6)

"   "


Any character with a code less than 10 should work; I've used a tab character above, which SE converts to spaces.

• Ninja'd
– user58826
Jul 24 '17 at 16:26
• Sorry :( plus I think you'd need quotes around it for it to be a string Jul 24 '17 at 16:27
• @programmer5000, so I see :( Jul 24 '17 at 16:27
• No problem, @StepHen; nature of the game. I took the quotes to be implicit, but I'll edit them in. Jul 24 '17 at 16:27
• @Shaggy I dunno what the ruling is, but f(<tab>) is valid syntax (empty input) and we'd have to differentiate between f(1) and f("1") anyway Jul 24 '17 at 16:30

# JavaScript (ES6), programmer5000

"\0"


The condition was !x||x>="\n". Any single char in an ASCII table with a code less than \n will work.

• Yes, I thought this was it, wasn't sure... Jul 24 '17 at 16:27

# cQuents, Step Hen

Anything followed by a space and a positive integer. The space separates inputs, and the extra input becomes the number of the term to output.

Try it online!

• I was just about to post a 1! You ninja'd me :/ Jul 24 '17 at 17:12
• @Mr.Xcoder I typed this on mobile, hoping that nobody would ninja me :P Jul 24 '17 at 17:13

# MATL, Luis Mendo (not the intended solution)

The empty input stops the program and thorws the following error:

Try it online!

# MATL, Luis Mendo

0/0


MATL evaluates 0/0 as NaN. Since NaN != NaN it does not loop

Try it online!

# Octave, Stewie Griffin

Any undefined input such as a will work: Try it online!

Defined values would not work, because | in a while environment is short-circuiting, so when it sees 1, it will already become true, no matter what the value of x is. So, the only way to make it halt is to make x=input('') halt, i.e. by giving it undefined inputs.

• +1 for teaching me that | short-circuits in while environments Jul 27 '17 at 15:22

## Javascript (NOT node.js)

Feel like this is cheating based on the last answer...

{toString:_=>{throw''}}

• IMO this is perfectly fine :) Jul 24 '17 at 19:53

# C (gcc), Justin

With input %s, the program crashes.

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


Try it online!

# RProgN 2, ATaco

Cracked, with input #. I have no idea why, I think C evals, and # is a comment.

 .iS‘"{".C


Try it online!

• O_o Unintended solution. # isn't a comment, but it pushed the "{" function literally when it eval'd, rather than executing it. +1. Jul 24 '17 at 23:14
• @ATaco Oh cool lol Jul 24 '17 at 23:15

# Javascript, Conor O'Brien

NaN


Yes, typeof NaN returns "number".

• Darn. I forgot about that. Jul 24 '17 at 23:48
• "Not a number" is a "number"? So it's basically in some kind of quantum state where it might or might not be a number depending on how you observe it. Jul 25 '17 at 6:38

# C (gcc), dj0wns

The intended solution is probably:

%n


This treats char *a as a writable unsigned int, but since it is assigned to a constant string, this invokes undefined behaviour which on TIO gives me:

/srv/wrappers/c-gcc: line 5: 18569 Segmentation fault (core dumped) ./.bin.tio "\$@" < .input.tio

• Wow shows how much I suck at having a problem with one solution. Still not it! Nice job though. That was a really cool get, I didn't know about this at all Jul 25 '17 at 0:50

# JavaScript (Node.js), tsh

The answer is '0'.

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

f('0')


Try it online!

# Node.js, Евгений Новиков

input:

{__proto__:null}


Try it online!

The input gets applied to an object. My input is an object with the same name as the native functions (__proto__) which will get applied to the object in the while condition and will override the native functions (such as toString and valueOf), causing an error when the program tries to cast the object to true/false for the while loop (because the necessary functions are missing and broken).

# JavaScript (Node.js), Haumed Rahmani

JavaScript uses floats for everything, so...

f(100000000000000000)


Try it online!

# Java 8, Socratic Phoenix

-32760


Try it online.

The hardest part was recognising that taking >1s didn't mean it was stuck in a loop :P.

This is just due to the constant cache; the equality check is actually for identity.

# JavaScript, Step Hen

" "


Try it online!

# Python 3, Veedrac

>>> import sys
>>> class A(type): pass
...
>>> for _ in range(sys.getrecursionlimit()+1):
...   class A(type, metaclass=A): pass
...
>>> T(A)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in T
File "<stdin>", line 2, in T
File "<stdin>", line 2, in T
[Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

• Brute force, I like it! Jul 25 '17 at 16:14

# JavaScript, w0lf

This is the same hack as many others, really. There's probably a smarter solution, but this works.

{toString:1}


This just throws an error when calling toString.

# JavaScript, w0lf v2

Same deal, no exception.

function(){ let x=0; return {toString: () => x++} }()


I'm pretty sure that's not the normal way to make anonymous objects with locals, but I figure someone will correct me in the comments.

# Python 3, Veedrac

One value for which the program stops (with a ZeroDivisionError) is:

324835776096020208287573140963456


Try it online!

Edit: I'm not completely sure this is the smallest such value, but I will continue to check.

Edit2: OK, I've been looking for smaller solutions and haven't been able to find any. I cannot demonstrate that this is the smallest such value, but I'm pretty confident that it is.

### Explanation

The algorithm does the following (considering the binary representations of the numbers):

• p, n, and c are initialized to 0 (no bits set)
• at each step, it consumes the 12 rightmost bits from x (the input)
• out of these 12 bits, the 3 leftmost are discarded (&511) and only the remaining 9 bits are used. The value represented by these 9 bits is assigned to b.
• out of the 9 bits, at most one must be set (b must be 0, or a power of 2), otherwise b&(b-1) will make the inner while loop forever.
• the bit that is currently set in b will be set in p, n, and c
• p is shifted 1 bit to the right (p>>=1)
• n is shifted 1 bit to the left (n*=2)
• in the next iteration, the bit set in b must be set in neither p, n, nor c (otherwise the (p|c|n)&b condition will make the inner while loop forever)

The objective is at the end to have all 9 bits in c set (it will be equal to 511 and therefore the last line will fail with the ZeroDivisionError), otherwise the last while will loop forever.

So, I was looking for a minimal way to make x out of 12-bit chunks, such that:

• every chunk will have one of the rightmost 9 bits set
• no chunk will "collide" diagonally with any of the former ones

The code I used to generate x with the smallest value I found is this:

chunks = [
0b000000000001,
0b000000000100,
0b000000010000,
0b000001000000,
0b000100000000,
0b000000000000,
0b000000000010,
0b000000001000,
0b000000100000,
0b000010000000,
]

x = 0
for c in (chunks):
x += c
x <<= 12
x >>= 12

print(x)


# Javascript (Node.js), programmer5000

Object.prototype


Object.prototype is the root prototype for all other objects, but it can't obviously have a prototype itself, because that would create a loop. Edit: I think this also works:

Object.create(null)


# JavaScript, programmer5000

Symbol.split


Try it online!

# Pyth, isaacg

Seems to halt every time. Input:

.q


Try it here!

• Two seconds faster, lol. Jul 26 '17 at 11:38

# Pyth, isaacg

.q
`

This quits the program.

Try it online.