last day (20 days later) » 

14:10
6
Q: Generate all halting Smallfuck programs of length n

Challenger5Your task is to write a program that, given a number n, returns a list of all valid, halting Smallfuck programs of length n, in any order. Actually, we're using a variation of Smallfuck called F2, which is just Smallfuck with a right-unbounded tape. For the purposes of this challenge, a program ...

@Arnauld What I actually meant was the lowest n. Thanks for catching that.
Are you OK with a strategy that simulates each potential smallfuck program for an enormous amount of time?
@xnor As long as you can demonstrate that it gives the correct answers up to a certain n, I'm fine with that.
When you say "demonstrate", is a mathematical argument OK, or do you want to see the program actually produce the output?
@xnor Either one.
14:10
Only having 400 bytes available makes it hard to do anything interesting in a non-golfing language.
@user1502040 Fair, considering that you have to implement F2 in order to solve this. I changed it to 1000 bytes.
-1 for lying in the title.
@CalculatorFeline What do you mean?
You said Smallfuck in the title but this is about F2 :/
@CalculatorFeline I assumed that they were similar enough that this wouldn't be an issue, and many people don't know what F2 is, so the title "generate all halting F2 programs" is arguably less clear. And anyways, you know now, so why would you downvote it?
14:10
Oh. That makes sense.
@CalculatorFeline It moves the pointer left, as in F2.
I meant what does the program < do.
@CalculatorFeline "a program that moves left from the start of the tape is considered invalid."
(Note to self: Stop looking dumb.)
If someone posts a clever answer, then it should be fairly trivial to generate a shorter answer with the same n by e.g. taking the maximum run-time of the first answer and eliminating any programs which run longer. Perhaps you should instead use priority as a tie-breaker.
14:10
@user1502040 What do you mean by "priority"?
@Challenger5 Earliest wins.
if [][] is a valid n=4 solution, is [] not a valid n=2 solution?
G B
G B
is >[] valid for n=3? And is [<] invalid?
Does it have to work for length 0?
On the linked esolang page for smallfuck, it defines ] Jump back to matching [ Is there a condition for this? Is it the same as bf where it happens if the number in the current cell is 1, or does it mean always?
@nmjcman101 always, however it then runs said matching [, which will jump past the matching ] if the condition is met (the condition being current cell == 0)
14:10
@Mayube which should in effect be the same as only jumping back when the current cell == 1, correct? The semantics are different but the outcome seems to be the same
@GB You don't have to handle 0.
@GB [<] is not invalid because the loop never executes.
Generating all halting Smallfuck programs is possible by the way, as it does not require you to solve the halting problem.
Are [[]] >[]+, >[]< and >[]> valid for n=4? I'm procedurally generating them and these are the ones which are not in your list
@L3viathan: It does if you want your own program to halt. It's certainly possible to write a program that's guaranteed to output all halting programs and no non-halting programs, but it will necessarily get stuck in an infinite loop in the general case, and there's no way to know that it's not going to output some other program in future.
@ais523 There are infinitely many halting Smallfuck programs (I assume), so a program generating them all must neccessarily have infinite runtime. It would obviously run some kind of infinite loop, but it would be guaranteed to continue outputting more halting programs infinitely and never get stuck. Of course, there might be a long time between two programs being printed.
14:10
@L3viathan: There are only finitely many programs of a given length, though, which is what this question asks for. You might be interested in this question, which is what you just described.
@ais523 Of course. I'm not criticising (or misunderstanding) the question, I just took offense with "Since solving this for every n is impossible".

  last day (20 days later) »