Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
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)
Esempio n. 5
0
    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)