Ad
  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    author had no intention on adding perf constraints on this one (see discussion below)

  • Custom User Avatar

    Approved by someone

  • Custom User Avatar

    Approved by someone

  • Custom User Avatar

    Some solutions show linear time complexity solutions are possible. Do you want to enforce perf constraints on this kata or not?

  • Custom User Avatar

    This one is actually having lowest complexity compared to all better rated solutions!

  • Custom User Avatar

    Of several tested, this was fastest.

  • Default User Avatar
  • Custom User Avatar

    Really nice kata and concise, step-by-step description. Thank you!

  • Custom User Avatar

    Shouldn't this kata also enforce performance requirement similar to Squared Spiral#1?

  • Custom User Avatar

    Missing edge cases for horizontal and vertical line segments colinear with one of the rectangular sides with different intersection patterns:

    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((-100, 10), (100, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, -100), (10, 100))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((-100, 10), (0, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, -100), (10, 0))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 10), (100, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 0), (10, 100))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((50, 10), (100, 10))), False)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 50), (10, 100))), False)
    

    Also missing edge cases where line has zero width:

    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 0), (0, 0))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 10), (10, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((0, 10), (0, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((10, 0), (10, 0))), True)
    test.assert_equals(line_crossing_area((0, 0, 20, 20), ((20, 20), (20, 20))), False)
    

    And edge cases with 0 rectangle area (technically 0 width only and 0 height only should be tested too, but I didn't bother to write tests for those):

    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((0, 0), (0, 0))), True)
    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((10, 10), (10, 10))), False)
    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((0, -10), (0, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((-10, 0), (10, 0))), True)
    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((10, -10), (-10, 10))), True)
    test.assert_equals(line_crossing_area((0, 0, 0, 0), ((-10, -10), (10, 10))), True)
    

    The author solution can correctly handle all these test cases without failing or throwing exceptions (due to division by 0). Every submission besides one fails against some of them.

  • Default User Avatar

    I tried to apply recursion in my solution for generate the coordinates, but it was difficult to make the solution small.

  • Custom User Avatar

    Was quite a good kata !
    IMHO not challenging enough in terms of performance..
    My sol, not optimized at all, runs in 2,5 secs ??

    Funny detail: 'UP' is y+=1 (quite strange for me, I used to be a "graphic" guy thus 'UP' means ... y-=1 to me...:-))
    For the maths: is there a closed form ?

  • Default User Avatar

    I'm getting this error: 8WXSY7WGXBM122383 should be invalid! expected:true but was:false
    When I run the code with my IDE I get true.

  • Loading more items...