Ad
  • Custom User Avatar

    I don't think it's equivalent. The trailing spaces could be part of a string. In that case, having trailing spaces or not does matter.

  • Custom User Avatar

    I will show that (a), (b), and (c), as defined above, create the same effect.

    Because NOP/no instruction is given for \0 or spaces, it doesn't matter which you pick, so (a) and (b) are effectively the same. (In your code, you should not need to make a case for spaces.)

    Now I will reason as to why (c) is the same as (a) and (b).

    Say you line has one '^' then one '>' then one '1' and 5 spaces only (as per (a) and (b)). If you were to run this code starting at the '>' char, you would set the direction to right, push 1, NOP 5 times, (wrap), then change direction to up. Because NOP is, by definition, doing nothing, this is equivalent to, set the direction to right, push 1, (wrap), then change direction to up.
    Now suppose you're running the same line of code but without spaces (as per (c)). If you were to run this code starting at the '>' char, you would set the direction to right, push 1, (wrap), then change direction to up.

    The same reasoning can be generalized for any instructions on the line and any starting location and any number of spaces. In every case, the final effect is the same between cases (a), (b), and (c).