3
// if x = y then {if_code}; else then {else_code}

,>,< / empty memory

[->-<]> / (x)'y

[>->]< / 0'(y-x)

+[
  {if_code}
  ->>
]< / {if x=y then} (0)'0; {else then} 0'y-x'(1)

[
  {else_code}
  [-]
]< / 0'(y-x)

/ empty memory

/ is to show what the memory should look like, ' is to separate values in the memory, () is used to show where the pointer is, // is for comments, and {} is for descriptions

Whenever I try to run this, no matter what I input, both the if_code and else_code is run.

4
  • I can't, but this is a very nice question for a newbie, and as I wouldn't touch brainfuck with even a very long stick, have an upvote! Commented Apr 19, 2022 at 13:37
  • thx for the support Commented Apr 19, 2022 at 13:40
  • btw the comments showing the memory show the memory before that line. Commented Apr 19, 2022 at 13:58
  • my mistake I was shifting around the comments to make them more clear and ended up doing the opposite Commented Apr 19, 2022 at 14:07

1 Answer 1

5

You have at least three '-' commands hidden in your "comments".

Sign up to request clarification or add additional context in comments.

2 Comments

Holy I didn't notice that
Thanks, it was a pretty stupid mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.