Ad
  • Default User Avatar

    "The part that says + is "only for corners" is not meant to imply the straight ahead path is disallowed" & "If you find yourself at a corner then you must turn" & ambiguousness rule = very confusing for me.
    After one hour reading several times all the comments I finally think that a "+" can really "draws" a path in every direction and even the straight ahead direction has to be considered for the ambiguousness rule. Am I right ?

  • Custom User Avatar

    What is your approach? If you use doubles instead of big integers you obviously will have precision problems

  • Custom User Avatar

    I don't think it's very realistic. If you drop an egg it surely gets some microtrauma even if it doesn't crack, making it more susceptible to crack in another throw.

  • Custom User Avatar

    I'm only commenting because I saw your comment elsewhere and I wanted to confront with your solution :D
    You also get O(n) complexity where n is the length of array. So for small arrays with big differences between min and max you might be correct but for large arrays and small differences your solution will be mercilessly left behind. I don't know python very well but I'd assume that cost of removing an item from a list is disproportionately more costly than iterating an integer so without array size/number difference constrainst I wouldn't say either solution is better than the other.

  • Custom User Avatar

    No, it's like this:

    • When you start at the top X and get to the middle + there is a choice of 2 paths - go left or straight ahead
    • When you start at the bottom X and get to the middle + there is a choice of 2 paths - go left or right
    • Since the path is ambiguous in BOTH directions the line is "invalid"

    (BTW - The part that says + is "only for corners" is not meant to imply the straight ahead path is disallowed. It is only saying that at least one of the outgoing paths from the + must be a turn. e.g. This is the reason for the 2nd bad-line example. If you think this Kata description is confusing please suggest something better for consideration).

  • Custom User Avatar

    Yes, it must be a corner because it is said that '+' means corners.
    The other rule, however, in fact justifies why this example is 'invalid'.

  • Custom User Avatar

    From kata description:

    Rules for valid lines:

    ...
    Every line "character" found in the grid must be part of the line. If extras are found then the line is not valid.

    I believe the bottom branch of that grid is classified as 'extras'

  • Custom User Avatar

    but if you start with the top one it's very simple because the second '+' must be a turn

    Must it?

  • Custom User Avatar
    X-----+  
          |  
    X-----+  
          |  
    ------+  
    

    It has been asked before but I can not see answer - why would that be invalid? Sure when you start with the lower X then the first corner is ambiguous but if you start with the top one it's very simple because the second '+' must be a turn

  • Custom User Avatar

    I was stuck on this for a long time because instead of an exception I was getting a timeout... my code went into an infinite loop because the "empty" matrix has one row of zero elements, which is NOT a square.