https://www.codingame.com/training/medium/what-the-brainfuck
Send your feedback or ask for help here!
Created by @anon72424297,validated by @dbdr,@Zorg1 and @JBM.
If you have any issues, feel free to ping them.
https://www.codingame.com/training/medium/what-the-brainfuck
Send your feedback or ask for help here!
Created by @anon72424297,validated by @dbdr,@Zorg1 and @JBM.
If you have any issues, feel free to ping them.
IMPORTANT UPDATE:
After viewing the @JBMâs stream (Replay here), reading his post (Here), and talking with him and @Zorg1, I decided to make a few changes on the puzzle.
First, the two kinds of input errors were more constraining than interesting, and were more about the puzzle format constraints than real interpreter problems. (At least concerning the missing input one.). So I removed them, and so the corresponding tests and validators.
Secondly, the 3 remaining errors validators are the exact inverses of their corresponding tests. To avoid incomplete solutions to pass, and also to check the correct management of the errors priority, I added the âMultiple errorsâ test/validator.
Despite this changes, the already validated solutions which totally fulfilled the puzzle requirements are still valids.
All this changes are also indicated in the statement and on the publication page.
Hi my code pass all the test but not the multiple errors validators.
What error does it check ?
i would think that there are many errors and that you did not stop at first error and output a wrong oneâŚ
My all test cases are running but validator showing error in âSyntax errorâ .what could go wrong ???
Make sure the error appears even if you donât jump when reaching []
Hi nopnop1,
Hi my code pass all the test but not the multiple errors validators.
What error does it check ?
You must respect the order of priority of errors.
If there are multiple errors, you should check and return the error with the highest priority first.
Errors Priority Order :
Hi,
When I run all test cases i fail the Multiple Errors test case because I ouput an INCORRECT VALUE firstly (However if that error didnât exist the POINTER OUT OF BOUNDS would be found).
For whatever reason i submitted and I scored 100% having that test case failed.
Why does it happen?
FYI: In other submissions I hitted correctly the POINTER OUT OF BOUNDS correctly.
EDIT: Assuming that my program is correct i have the feeling that the statement of the problem has a small problem here:
I think it should state if the value of a cell becomes negative at the output time, that is, after â.â is read.
Hi nopnop1,
Hi my code pass all the test but not the multiple errors validators.
What error does it check ?You must respect the order of priority of errors.
If there are multiple errors, you should check and return the error with the highest priority first.Errors Priority Order :
- "SYNTAX ERROR"
- "POINTER OUT OF BOUNDS"
- "INCORRECT VALUE"
I have done it but it still doesnât work; giving me some test value close to the validator would be great to help debugging
Hey.
The test and the validator about multiple errors are not the sames, and the errors order is different, so you can pass one and not the other if your error detection is not perfect.
And Iâm not sure to understand what you mean about the output time⌠Can you explain ?
Youâre probably missing something about the error priority⌠Read the statement carefully.
i have done it but i donât know why it doesnât work before
Thanks, i had a âsillyâ error (i didnt constrained my pointer correctly) which leaded to a confusing outcome. Thanks for your time. Nice and interesting problem.
Hi,
How is your test for this part ?
To confront your code, you can check test 7 and force the input to replace the only â[â by a â]â .
It helped me to fix my code (I had the same situation than you).
Fun challenge. But I canât stand itâs failing on one validator test. Can someone maybe steer me in the right direction?
Itâs the one syntax error validator (i do pass all the tests).
What I do to build, and later validate (before main program runs) my bracketMap:
def buildBracketMap(inputLine):
bracketPairs = []
for idx, char in enumerate(inputLine):
indent = 0
if char == "[":
bracketPairs.append({'open' : idx})
startIdx = idx
for idx2, char2 in enumerate(inputLine[startIdx:]):
if char2 == "[": indent +=1
if char2 == "]" and indent != 0: indent -=1
if char2 == "]" and indent == 0:
bracketPairs[len(bracketPairs) -1]["closed"] = idx2 + startIdx
break
return bracketPairs
for bracket in bracketMap:
if len(bracket) != 2:
print("SYNTAX ERROR")
exit(0)
if (inputLine.count('[') != len(bracketMap) or inputLine.count(']') != len(bracketMap)):
print("SYNTAX ERROR")
exit(0)
if bracket['closed']-bracket['open'] == 1:
print("SYNTAX ERROR")
exit(0)
What am I missing?
What happens when there are no opening brackets?
Aiaiai, yes I didnât know why I put this:
if (inputLine.count('[') != len(bracketMap) or inputLine.count(']') != len(bracketMap)):
print("SYNTAX ERROR")
exit(0)
Inside the bracketMap loop, ⌠thanks @RoboStac !
My Code passes all Testcases but fails in the final Syntax Error category. Is there any possibility to see the input which it fails against?
Edit:
Nevermind, Iâve found the mistake in my parser.
I think it would be valuable to explain the input list is a stack of inputs for the same program, I took ages to understand how wrong I was about the input treatment !
Iâm OK to clarify the statement if needed, but I donât see what you meanâŚ
The âInputsâ section states:
Line 1: Three integers L, S and I for the program line count, the needed array size and the inputs count.
Next L lines: A line of the Brainfuck program.
Next I lines: An integer input to the Brainfuck program.
It is not clear enough ?