def test_rectange_overlap(self): fabric = empty_fabric() for line in [ "#1 @ 0,0: 4x3", "#2 @ 2,2: 3x1", ]: Claim(line).add_claim(fabric) self.assertEqual(overlap_claims(fabric), 2)
def test_side_overlap(self): fabric = empty_fabric() for line in [ "#1 @ 0,0: 4x4", "#2 @ 0,3: 4x4", ]: Claim(line).add_claim(fabric) self.assertEqual(overlap_claims(fabric), 4)
def test_no_overlap(self): fabric = empty_fabric() for line in [ "#1 @ 0,0: 4x4", "#2 @ 10,10: 4x4", "#3 @ 0,10: 4x4", "#4 @ 10,0: 4x4" ]: Claim(line).add_claim(fabric) self.assertEqual(overlap_claims(fabric), 0)
def test_overlap(self): claims = [Claim('#1 @ 0,0: 5x4'), Claim('#2 @ 4,3: 5x4')] fabric = empty_fabric() for claim in claims: claim.add_claim(fabric) self.assertEqual(overlap_claims(fabric), 1)
def test_aoc_example(self): fabric = empty_fabric() for line in ["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x2"]: Claim(line).add_claim(fabric) self.assertEqual(overlap_claims(fabric), 4)