User talk:Superdave

Truth-machine in NULL
About your recent addition of a truth-machine in NULL: are you sure they work? I tried both numbers 118711002 and 158776807097 and here is what I see, using to get prime factorizations. 118711002 = 2 * 3 * 47 * 61 * 67 * 103 ~ 2  3    2    7   11    41 ~ next prev next input subtract switch Hand-interpreting this program gives: En résumé: This program will terminate without output if input is '0', and will output '1' NUL NUL '1' NUL NUL indefinitely instead of 111111111... if input is '1'. Close enough but if that's really what it does I think you should at least specify it on the truth-machine page.
 * Move to next queue (x = 61 * 67 * 103, y = 2 * 3 * 47)
 * Input one byte and replace the front value with it
 * Assuming input is '0' (48)
 * Subtract that number from y (x = 103, y = 2 * 3 * 47 * 61 *67 - 48 = 1152486 = 2 * 3 * 3 * 43 * 1489)
 * Switch x and y (x = 2 * 3 * 3 * 43 * 103 * 1489, y = 1)
 * Move to previous queue (x = 43 * 103 * 1489, y = 2 * 3 * 3)
 * End the program.
 * Assuming input it '1' (49)
 * Subtract that number from y (x = 103, y = 2 * 3 * 47 * 61 * 67 - 49 = 1152485 = 5 * 53 * 4349)
 * Switch x and y (x = 5 * 53 * 103 * 4349, y = 1)
 * Output '1' (x = 53 * 103 * 4349, y = 5)
 * Move to previous queue (x = 103 * 4349, y = 5 * 53)
 * Switch x and y (x = 5 * 53 * 103, y = 4349)
 * Output NUL (because we moved to the previous queue, which is empty, so output does not output '1' any longer) (x = 53 * 103, y = 5 * 4349)
 * Move to previous queue (x = 103, y = 5 * 53 * 4349)
 * Switch x and y (x = 5 * 53 * 103 * 4349, y = 1)
 * Now we're in an infinite loop.

158776807097 = 23 * 23 * 23 * 31 * 61 * 67 * 103 En résumé: This program terminates without output if input is '0', and will output NUL NUL NUL NUL '1 '1' indefinitely if input is '1'. Again, close enough but not exactly a truth-machine.
 * Enqueue three zeroes to previous queue (x = 31* 61 * 67 * 103, y = 23 * 23 * 23)
 * Enqueue y mod 256 (that's 135) to current queue (x = 61 * 67 * 103, y = 23 * 23 * 23 * 31)
 * Replace 135 with one bye from input
 * Assuming input is '0' (48)
 * Subtract 48 from y (x = 103, y = 23 * 23 * 23 * 31 * 61 * 67 - 48 = 1 541 522 351 = 43 * 97 * 369581)
 * Switch x and y (x = 43 * 97 * 103 * 369581, y = 1)
 * End the program.
 * Assuming input is '1' (49)
 * Subtract 49 from y (x = 103, y = 23 * 23 * 23 * 31 * 61 * 67 - 49 = 1 541 522 530 = 2 * 5 * 5 * 30830447)
 * Switch x and y (x = 2 * 5 * 5 * 103 * 30830447, y = 1)
 * Move to next queue (x = 5 * 5 * 103 * 30830447, y = 2)
 * Output NUL twice (again, it's not a '1' any longer since we've moved to next queue) (x = 103 * 30830447, y = 2 * 5 * 5)
 * Switch x and y (y = 308847, x = 2 * 5 * 5 * 103)
 * This will be an infinite loop.

Assuming I haven't done any mistake, your programs lack output when input is '0', and include moving around the queue when input is '1', which disturbs output (because only one of the three queues will output the value '1'). I'm impressed by the use of the subtract instruction, though.

--Koen (talk) 11:05, 4 October 2012 (UTC)

Thanks for noticing that; back to the drawing board. Empirically, they worked with the Python implementation, but I just let it print out 1s to the screen for long enough to be sure it wouldn't overflow anything, and I didn't realize that it was outputting NULs. I was sure 0 worked last night but it doesn't work today. I should have called it quits for the night. I'll test it better and find one that works, and write an analysis of it.

Fixed it! Now it is: 17328365648, which factors to 2 2 2 2 11 61 71 127 179. The first 5 instructions are harmless junk; then input (7 cannot be used because '1' is divisible by 7, so you can't get rid of it easily from the loop); then add, output, and loop. The numbers when looping are 2 2 2 2 2 2 43 127 179 277 if 0 (six harmless switch-queues then halt); or 5 127 179 152461 if 1 (output twice and do it again--an optimized unrolled loop!) --Superdave (talk) 06:28, 5 October 2012 (UTC)