# [Community Puzzle] What the Brainfuck!

Hi, love the turing machine simulator! It was a bit unclear tho as to how the bracket pairing works, with regards to nested brackets. I was under the understanding that the brackets would pair with whatever other bracket came before or after, not that they were paired together from the start. I also struggled with whether a single opening bracket could have multiple closing brackets for the same reason.

I think the problem description should list that each opening bracket will have EXACTLY ONE closing bracket. That would make it more clear and easier to understand.

The statement contains the following note:

Note: The [ and ] commands always come in pairs, and in case of nested [] the first [ always correspond to the last ].

Does that more or less carry the meaning of what youâve suggested to add? I mean if they come in pairs, each opening bracket will most certainly have exactly one closing bracket, right?

1 Like

Pierre has a good response for debugging.

I suggest you consolidate the instructions into one line of valid characters instead of jumping between line to line.
Itâll eliminate bugs that you donât really see in an obvious way that you do see if you make everything one dimensional.

I feel compelled to leave some feedback to this puzzle:

Loved it!

I have long been curious about the brainfuck language and thus was really happy with this opportunity to learn about it. I was expecting it to be much more complicated. And when I still had an error in the code and had to analyse the command string and finally realized that the brackets are used to construct loops âŚ loved it!

Thanks

1 Like

Hi,

I have exactly the same issue, difficult to figure out the issue hereâŚ

Could anyone help me by any specific test code or code check ?

thanks!

You may create custom cases as follows, and one of the combinations is the 6th validator (Incorrect value) itself:

Input
L = 1
1 â¤ S â¤ 9
N = 0
program consists of one character (i.e. > or < or + or - or . or , or [ or ]) only
no input to the said program

Output
INCORRECT VALUE (valid for that validator, or maybe for some of the input combinations)

When you say only one character you confirm the â.â for print is excluded?
If my understanding is right the error âINCORRECT VALUEâ can be prompt only if a print is required by one â.â in the code. So testing with the dot (as it is the only code based on your indication, it is printing ? as 0 is âNULâ in ASCII table. trying to change the min value to eclude the 32 first values, it doesnât suppress the validator fail.
Could you confirm my understanding ?

the error âINCORRECT VALUEâ can be prompt only if a print is required by one â.â in the code.

If you mean âoutputâ when you type âpromptâ, then nope, your statement is wrong. The statement states:

In some cases, errors might be encountered. When this happens you have to stop the execution of the program and print the correct error message

To my understanding, the ASCII code of range occurs only proceeding to its call.
So the value of the cell shall be checked to be lower than 256 at the moment of its affectation / incrementation ?

The statement states:

An array of S one byte cells initialized to 0, and indexed from 0.

âINCORRECT VALUEâ if after an operation the value of a cell becomes negative or higher than 255.

So, all cell values are correct at the beginning, and only after an operation the cell values should be checked to see whether any becomes âincorrectâ.

Ok it works thanks.