Draft

Knight and the Castle

Description
Loading description...
Geometry
Fundamentals
View
AllIssues4QuestionsSuggestionsShow Resolved
  • Please sign in or sign up to leave a comment.
  • maipatana Avatar

    It is a fun kata but it is still need some fix. Please have a look at https://i.imgur.com/hhdKi4v.jpg

    similar to what damjan had addressed before.

    • eqlion Avatar

      uh, thank you for your reply! i might actually take this kata down for some time to rethink my solution and generation of the test cases in order to fix this problem and prevent them from occuring!

  • damjan Avatar

    Sorry for submitting so many bug reports, but I really want this kata to work! It's quite fun.

    Random point: ([1, 99], {1: [76, 32], 2: [19, 43], 3: [84, 81], 4: [94, 68]}) (plot)

    ✘ 2 should equal 3

    But as you can see in the plot, the knight can only see two towers from his position in the upper left corner.

    • eqlion Avatar

      Thanks a lot! I've found the origins of this problem, it's more complicated, though. The kata will be unpublished for a while. However, I have an idea of solving it.

    • damjan Avatar

      Alright, I look forward to trying it again when it's finished. :) My solution only worked for convex polygons so I'll have to rethink that too. >_>

    • eqlion Avatar

      I've rewritten random test cases complitely, looking forward to your feedback!

      Issue marked resolved by eqlion 9 years ago
  • damjan Avatar

    I got this as a random test case: {1: [22, 81], 2: [41, 18], 3: [73, 1], 4: [29, 20]}

    This isn't a convex polygon, though. So you might want to either fix that or update the description.

  • damjan Avatar

    Very cool kata, but I think there's a bug -- either with the test cases or with my solution.

    Test case 2: O: [0, 0], A: {1: [0, 2], 2: [2, 4], 3: [5, 4], 4: [7, 0], 5: [4, 0]} Expected: 2

    Here, two towers and the knight are colinear, and only the first is counted. (The tower at (7,0) is blocked by the tower at (4,0)).

    Test case 3: O: [4, 0], A: {1: [0, 4], 2: [6, 5], 3: [5, 3], 4: [4, 2], 5: [3, 2], 6: [1, 3]} Expected: 6

    But in this case, the colinear tower at (0, 4) is counted despite being blocked by the tower at (1,3)!

    • eqlion Avatar

      Thanks for your note! You are right, there was a mistake in the third test case that has been fixed. Try it now!

      Issue marked resolved by eqlion 9 years ago
    • damjan Avatar

      Awesome! Thanks for fixing it so quickly. :) Unfortunately, I have another problem though... I'll add a separate comment for it.