Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

[New] ITT We determine if your programs halt

Name: Anonymous 2010-06-18 2:22

Give us your programs, and we'll tell you if they halt!

Bring em on!

Name: Anonymous 2010-06-18 2:25

(loop)

Name: Anonymous 2010-06-18 2:25

start:
  hlt

Name: Anonymous 2010-06-18 2:29

>>2
 Yes! That does not halt. I can say with 100% confidence.

>>3
 Yes! That also halts.

NEXT!

Name: Anonymous 2010-06-18 2:42

#include <stdint.h>
#include <stdlib.h>

int main(void)
{ for(uint32_t i = arc4random_uniform(2); i;);
  return 0; }

Name: Anonymous 2010-06-18 2:42

#!/bin/sh
yes That does not halt.

Name: Anonymous 2010-06-18 2:45

>>5
This halts eventually, given unlimited execution time.

Name: Anonymous 2010-06-18 2:51

>>5
 Does not halt. Not hard at all!

>>6
 Does not halt. Could have found this out by reading ``man yes''

NEXT!

Name: Anonymous 2010-06-18 2:53

>>8 Here
Just clarifying, >>5 does halt sometimes. However, most of the time it will not halt.

Thanks. NEXT!

Name: Anonymous 2010-06-18 2:54

#!/bin/sh
man yes

Name: Anonymous 2010-06-18 3:07


pushl $3
pushl $2       
call power       
addl $8, %esp       
pushl %eax                   
pushl $2       
pushl $5           
call power   
addl $8, %esp   
popl %ebx       
addl %eax, %ebx                   
movl $1, %eax       
int $0x80
 .type power, @function
power:
 pushl %ebp       
 movl %esp, %ebp   
 subl $4, %esp       
 movl 8(%ebp), %ebx   
 movl 12(%ebp), %ecx   
 movl %ebx, -4(%ebp)                   
power_loop_start:
 cmpl $1, %ecx   
 je end_power
 movl -4(%ebp), %eax   
 imull %ebx, %eax   
 movl %eax, -4(%ebp)   
 decl %ecx       
 jmp power_loop_start   
end_power:
 movl -4(%ebp), %eax   
 movl %ebp, %esp   
 popl %ebp       
 ret

Name: Anonymous 2010-06-18 3:08

main = print=<<($[0..])=<<(return.([return.return.head,return.tail]!!)=<<randomRIO(0,1))

>>7-9
wrong. read ISO/IEC 9899:1999 and the arc4random(3) man page.

Name: Anonymous 2010-06-18 3:22

main = print $ cycle "LO"

Name: >>2 2010-06-18 3:23

What about this

(defun does-this-halt (n x) 
  (labels ((f (n)
             (if (< n 2) t                  
                 (multiple-value-bind (div mod)
                     (truncate n x)                
                   (if (zerop mod)
                       (f div)
                       (f (+ (1- x) (* n (1+ x)))))))))
    (f n)))

(let* ((state (make-random-state))
       (n (random (ash 1 32) state))
       (x (random n state)))
  (does-this-halt n x))

Name: >>14 2010-06-18 3:24

Assume proper TCO is done on does-this-halt.

Name: Anonymous 2010-06-18 3:46

SET x TO 0;
SET y TO 1;
LABEL l;
IF x THEN GOTO l;
SET x TO 1;
SEND x TO 1~0~{y}=1;


The name of the language is TwoDucks.

Name: Anonymous 2010-06-18 4:19

SEND x TO MY ANUS

Also, this in FIOC:

def foo():
    foo()

Name: Anonymous 2010-06-18 6:54

Name: Anonymous 2010-06-18 8:07

#!/bin/sh
halt

Name: Anonymous 2010-06-18 9:14

>>16
If you actually write a program instead of just copying it from the wiki, I might consider.

Name: Anonymous 2010-06-18 9:26

?@#

Name: Anonymous 2010-06-18 9:54

while (halt());

Name: Anonymous 2010-06-18 11:31

((call/cc call/cc) (call/cc call/cc))

Name: Anonymous 2010-06-18 11:49

while (1) { fork() };

Name: Anonymous 2010-06-18 12:07

>>23
huh, I thought the fixed point of call/cc was call/cc. So I'd have expected this to return a function equivalent to call/cc

Name: Anonymous 2010-06-18 12:19

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
   srand(time(NULL));
   float a, b, c, d;
   while(true)
   {
      a = (float)rand();
      b = (float)rand();
      c = (float)rand();
      d = (float)rand();
      if((a/b) == (c/d))
      {
         break;
      }
   }
   printf("Halt!")
   return 0;
}

Actually, I don't think this will work ...

Name: Anonymous 2010-06-18 12:23

>>26
This will probably eventually halt, but I'm curious if there are any cases where it won't halt. It depends on rand's implementation.

Name: Anonymous 2010-06-18 14:37

Hey! What about >>21?

Name: Anonymous 2010-06-18 15:23

Guise, stop posting programs that invoke external functionality, it is impossible to evaluate if they will halt or not without looking up the external code which might very well be proprietary or out of reach.

Name: Anonymous 2010-06-18 15:38

>>29
Good point, RMS

Name: Anonymous 2010-06-18 15:53

>>20
look again, that program isn't on the wiki.

Name: Anonymous 2010-06-18 16:50

int main(int argc, char *argv[]) {
    while (0 == 1 == 0) ;
}

Name: Anonymous 2010-06-18 17:09

>>32
No.  Assembles to
40047f:       eb fe                   jmp    40047f <main+0xb>

Name: Anonymous 2010-06-18 22:56

current status of this thread:
programs posted: >>2,3,5,6,10-14,16-19,21-24,26,32 (19)
correctly answered (1 point each): >>2,3,6,26,32 (5)
incorrectly answered (-1 point each): >>5 (1)
not answered: >>10-14,16-19,21-24 (13)

your score: 4/19 (about 21%).

Name: Anonymous 2010-06-19 2:57

#include <stdlib.h>
#include <time.h>

int main(void) {
    int i;

    srand(time(NULL));
    i = rand() % 2;

    if(i) for(;;);
    return 0;
}

Name: Anonymous 2010-06-19 3:01

>>35 here.
I'd like the answer to be either "halts" or "doesn't halt".
No shit like probability.

Name: Anonymous 2010-06-19 3:52

>>35
Not enough information. We need to know the time upon execution.

Name: not OP 2010-06-19 4:08

>>36
If you consider the program's input the current time, it will halt in certain cases and not halt in the rest. It's no different from any range of functions depending on user input. Will halt for certain inputs and won't halt for other inputs. The actual values for which it would halt and which it wouldn't halt can be determined exactly if the rand implementation internals is known (depends on libc's code).

Name: Anonymous 2010-06-19 4:59

>>36
It does both depending on what time it was run.

Name: Anonymous 2010-06-19 7:16

@echo off
rem Double Dice
title Double Dice!
:S
echo Double Dice!
set money=100
echo.
:1
echo How much do you wager?
set /p wager=You have $%money%:
if /I %wager%==save goto :Score

if /I %wager%==help goto :Help
if /I %wager%==delete goto :Del
if /I %wager%==clear goto :Cls
if %wager% LSS 0 echo You can't wager a negative! &goto :1
if %wager% GTR %money% echo You don't have that money! &goto :1
set /a money="money-wager"
set /a DICE1=%random% %%6 + 1 >nul
echo You rolled a %DICE1%.
set /a DICE2=%random% %%6 + 1 >nul
echo You rolled a %DICE2%
if %DICE1%==%DICE2% goto :WIN!
echo.
if %money%==0 goto :F
goto :1
:F
echo Do you want to play again?(y/n)
set /p input=(y/n):
if /I %input%==y Cls &goto :S
if /I %input%==n goto :GO
goto :F
:WIN!
echo.
echo You Win! Here's your winnings!
echo.
set mem=%wager%
set /a wager="wager*6+wager"
set /a money="money+wager"
set /a wager="wager-mem"
echo You've won $%wager%!
set wager=0
echo.
goto :1
:GO
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
echo GAME OVER
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
ping 127.0.0.1 -n 1 >nul
echo.
echo.
:Score
set /p name=Type your name here:
echo %Name% : $%Money%>>Highscore.data
exit

:Help
echo.
echo Double Dice is a game of chance. If you get the same number twice,
echo the wager that you bet is returned sixfold. Otherwise you get nothing.
echo There are few commands in this program:
echo Save: This enters your profile into the highscore chart
echo Highscore: This loads the highscore if it is present
echo Delete: Removes the Highscore
echo Clear: Clears the screen
echo Help: Returns this information form.
echo.
goto :1

Name: Anonymous 2010-06-19 7:20

>>40
ping 127.0.0.1 -n 1 >nul
Holy shit, I'm raging so hard right now.

Name: Anonymous 2010-06-19 7:26

>>41
This wouldn't have been a problem if you didn't read code in a proportional font like me.

Name: Anonymous 2010-06-19 7:35

>>42
?

Name: Anonymous 2010-06-19 7:40

>>43
Code is posted without code tags ⇒ you don't read the code.

Name: Anonymous 2010-06-19 9:30

>>44
Ah, I see, but it doesn't look like that code uses any indentation in the first place, so code tags would add little.

Name: Anonymous 2010-06-19 10:31

>>45
You have much to learn, grasshopper.

Name: Anonymous 2010-06-19 10:39

I sure hope >>45 is trolling :/

Name: Anonymous 2010-06-19 12:56

>>44

back to /b/, please

Name: Anonymous 2010-06-19 14:50

>>47
Enjoy your pig disgusting proportional font while I enjoy my beautiful disproportional font.

Name: Anonymous 2010-06-19 23:53


// Program to tell if a program halts or not.
#include <stdio.h>
int main(int argc, char **argv) {
    if (argc < 2)
        exit(EXIT_FAULURE);
    system(argv + 1);
    printf("It halts.");
}

Name: Anonymous 2010-11-02 14:22

Name: Anonymous 2010-11-15 20:58

Don't change these.
Name: Email:
Entire Thread Thread List