[Community Puzzle] Complicated interpreter

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Ayza,validated by @rozbrajaczpoziomow,@Joey_G and @_NikJ.
If you have any issues, feel free to ping them.

Hello,

My code works on all tests but fails on validator 14. I guess it’s about an if statement but I don’t see what is wrong with my code.

Is there any specificity on this validator 14 ?

Regards

Try it then

Validator 14

Résumé

Input

4
x = 6
y = 5
if $x == $x and $y == 3 then x add 5
print

Output

6 5

Thanks, there was a huge mistake in my code…

Please use a spoiler tag to hide validators. Click the last button on the formatting toolbar, then look for “Hide Details”.

Alternatively, you may use private message to send details of validators.

Thanks! :wink:

okay ! sorry, i guess

(First time on forums, so hopefully using this correctly)

I’m passing all but validator 17. What’s the content of this validator, and is there a way to check validators for situations like these?

Validator 17 is similar to its corresponding test case “Nested loops”, except for more nested loops and a higher number of loops per “loop” keyword in the same line.

Validators are normally not provided except through PM or spoiler messages.

Validator 17

Input

5
x = 0
n function loop 50 do loop 50 do loop 50 do x add 1
n()
n()
print

Output
250000

That’s the validator incase you haven’t solved it yet.

regarding your question, you could search the puzzle name in CG Puzzle search and find it’s validators.

Thank you, my solution ended up being too inefficient, which I don’t think I could’ve ever debugged without an outside nudge lol. I had a regex matcher going for every iteration for every loop.

I enjoyed a lot resolving this puzzle. I wonder if you are thinking in a more advanced version, in which functions accept and returns values and multiple operations can be done inside a loop or a function.

1 Like

I’m failing validator 15, not sure where I am going wrong.

Problem solved through discord :+1:

2 Likes

Hello, I am also failing validator 15 (numbered 14?). Could somebody provide some help? Thanks!

Also, about the challenge itself, it is very interesting, but I think that some points should be added to the documentation:

  • Test 8: When the last instruction (z add $x) is executed, the z variable does not exist. In this case, the test expects us to consider add as an assign (=) operator. But when reading the documentation, I still think that this line should raise an error. Also, what would the behavior be for sub and mult?
  • Conditionals, loops, and functions: To me, it did not seem obvious at first read that the executed code inside an if, loop or function block is made of a single statement instead of a block of code.
  • Validator 15: Because it looks like I am not the only one to fail with this validator, maybe a related test case should be added :wink:

Hi Ankeraout, here is the contents of validator 15 and the difference between it and its testcase:

Validator 15

INPUT:

4
z = 5
y = 6
if $x == $z and y != $z then x add 0
print

OUTPUT:
ERROR

It’s the same as its testcase, one of the variables don’t exist. The only difference here is that an unequality operator is being used and instead of doing $y != $z it’s doing y != $z.

And for test 8: the z add $x actually doesn’t get executed because print stops the program execution, meaning all lines after it won’t get executed.

Thanks for the rest of the feedback

1 Like

hi,
validator 16 (test 15) fails whereas everything seems fine…
any hint on this validator ?