Go to interview

>go to interview
>whiteboard wheeled in
>"Write a program that will decide whether it will stop or loop forever given an arbitrary input"

Attached: cb6f379c38ec8439187600d0a8418d92f1a96e27_full.jpg (184x184, 18K)

Other urls found in this thread:

en.wikipedia.org/wiki/Halting_problem
twitter.com/NSFWRedditVideo

sayori is my wife

That's easy as fuck tho

I fucked your wife.

>arbitrary
Brainlet here. How would even work without an exact input.

while(input & 1);
return 0;

import random
def StopOrLoop(x):
arbitaryInput = x
willitstop = random.random()
if willitstop > 0.5:
quit()
else:
while True:
print("This loop never stops")

>just solve the halting problem yo

Or trick it, set pointer null and any non null halts the program, else loop

def halts(input):
input()
return True

Today i had to do whiteboard questions over the phone

They were easy as shit solutions like use a hash table instead of list for better performance

I dont give them that answer tho because I cant think straight at all

you literally can't solve this problem. It's the halting problem.

>"Write a program that will decide whether it will stop or loop forever given an arbitrary input"
>whether it will stop
"It" is clearly referring to the program you're going to write here.
true

Works for arbitrary input.

I'm actually convinced the halting problem is solved by an grossly underpaid and underappreciated code monkey working on toaster firmware somewhere.

this, OP didn't specifying that the program needs to be a turing machine, which is part of the halting program
a program that just says "i'll stop" then stops given any input solves OP's question, but that's not what he was referring to

specify*
halting problem*

it's proven that you can't solve it..

en.wikipedia.org/wiki/Halting_problem

Sub Program(input As Int32)
If input Mod 2 = 0 Then
Return
Else
While True
End While
End If
End Sub

You saw it here first ladies and Jow Forumsents, this user knows how to solve the halting problem. We wait with bated breath until he shows us the solution that's, in his words, 'easy as fuck'.

it's not the halting problem it's "Write a program that will decide whether it will stop or loop forever given an arbitrary input"

Wrong. Your program isn't a decider, as it does not terminate on all inputs. The only valid solution to the problem as stated in the OP is to always terminate with acceptance. Sorry boyo, but you can't out-autist me when it comes to theory of computation.

I don't understand
What's an arbitrary input?
Why can't you just read an integer and then use it as condition for a while loop before the program exit?

Attached: 1505990428705.png (645x729, 71K)

I asked her she said you are lying

def is_halting(src):
raise NotImplementedError("can't do that you faggot")

func main() {
fmt.Println("press ctrl-c to stop")
select{}
}

Just write something that generates a paseudo-random number every time you give it an input, if it's even, stop the program and if it's odd, loop forever.

channels are nice, but you could use a pointer or mutex also.

func main() {
ch := make(chan bool)
go timer(ch)

for {
select {
case

I don't understand the halting problem. can someone explain please

I love Sayori
Thanks OP

That's not the halting problem
That's literally a while loop and whatever input your preferred programming language takes

Not sure if this is supposed to be the halting problem or not, but it's not. From how OP describes it, it can be solved with one simple line:

return 0;

It doesn't specify what the program is, and thus we define the program to simple exit at once regardless of the arbitrary input. And this solving the problem of whether it will loop or stop is easy: It will always stop and so it will always return the same thing.

OP your bait failed because you're literally too dumb.

Attached: icon (1).jpg (600x600, 43K)

That's not "deciding whether it will stop". e.g. you have to print true if the program would stop and false if the program would loop forever.

It is the halting problem

Okay, show me such a program in your preferred programming language that exits 0 if the input is a program that would stop and exits 1 if the input is a program that would loop infinitely.

template
bool doesItHalt ( T input )
{
return true;
}

Whats so hard about it? it sounds like it can be done with a few ifs

input("Enter arbitrary input:")
while 1:
print("I'm not going to stop moron!")

The general problem no, specific problems yes.

Non tractable