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