Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I think the problem is still not fixed. You might want to import a definition of in the test code.

  • Default 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.

  • Default 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).

  • Custom User Avatar

    The statement did not mention how to deal with input lines of different lengths. Should we
    a) Pad with trailing spaces so that they all have the same length?
    or b) Pad with '\0's?
    or c) Do not pad, in which case the behavior wrapping is not well-defined?

    Each interpretation has its pros and cons, and there is no evidence as to which one is meant by the author. Please clarify.