Esempio n. 1
0
 def test_example(self):
     data = solver.process([
         "#1 @ 1,3: 4x4",
         "#2 @ 3,1: 4x4",
         "#3 @ 5,5: 2x2",
     ])
     self.assertEqual(solver.solve(data), 4)
Esempio n. 2
0
    def test_sample1(self):
        self.assertEqual(
            1,
            first.solve("""b inc 5 if a > 1
a inc 1 if b < 5
c dec -10 if a >= 1
c inc -20 if c == 10"""))
Esempio n. 3
0
 def test_example(self):
     data = [
         (1, 1),
         (1, 6),
         (8, 3),
         (3, 4),
         (5, 5),
         (8, 9),
     ]
     self.assertEqual(solver.solve(data), 17)
Esempio n. 4
0
 def test_multiple(self):
     data = solver.process([
         "#1 @ 1,3: 4x4",
         "#2 @ 3,1: 4x4",
         "#3 @ 5,5: 2x2",
         "#4 @ 3,3: 2x2",
         "#5 @ 3,3: 2x2",
         "#6 @ 3,3: 2x2",
         "#7 @ 3,3: 2x2",
     ])
     self.assertEqual(solver.solve(data), 4)
Esempio n. 5
0
 def test_example(self):
     data = [
         "abcdef",
         "bababc",
         "abbcde",
         "abcccd",
         "aabcdd",
         "abcdee",
         "ababab"
     ]
     self.assertEqual(solver.solve(data), 12)
Esempio n. 6
0
 def test_example(self):
     data = [
         ('C', 'A'),
         ('C', 'F'),
         ('A', 'B'),
         ('A', 'D'),
         ('B', 'E'),
         ('D', 'E'),
         ('F', 'E'),
     ]
     self.assertEqual(solver.solve(data), 'CABDFE')
Esempio n. 7
0
    def test_example(self):
        self.assertEqual(
            first.solve("""pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
ugml (68) -> gyxo, ebii, jptl
gyxo (61)
cntj (57)"""), "tknk")
Esempio n. 8
0
 def test_example(self):
     data = solver.process([
         "[1518-11-01 00:00] Guard #10 begins shift",
         "[1518-11-01 00:05] falls asleep",
         "[1518-11-01 00:25] wakes up",
         "[1518-11-01 00:30] falls asleep",
         "[1518-11-01 00:55] wakes up",
         "[1518-11-01 23:58] Guard #99 begins shift",
         "[1518-11-02 00:40] falls asleep",
         "[1518-11-02 00:50] wakes up",
         "[1518-11-03 00:05] Guard #10 begins shift",
         "[1518-11-03 00:24] falls asleep",
         "[1518-11-03 00:29] wakes up",
         "[1518-11-04 00:02] Guard #99 begins shift",
         "[1518-11-04 00:36] falls asleep",
         "[1518-11-04 00:46] wakes up",
         "[1518-11-05 00:03] Guard #99 begins shift",
         "[1518-11-05 00:45] falls asleep",
         "[1518-11-05 00:55] wakes up",
     ])
     self.assertEqual(solver.sleepy(data), 10)
     self.assertEqual(solver.solve(data), 24 * 10)
Esempio n. 9
0
 def test_example(self):
     data = [2, 3, 0, 3, 10, 11, 12, 1, 1, 0, 1, 99, 2, 1, 1, 2]
     self.assertEqual(solver.solve(data), 138)
Esempio n. 10
0
 def test_example(self):
     self.assertEqual(solver.solve("aA"), 0)
     self.assertEqual(solver.solve("abBA"), 0)
     self.assertEqual(solver.solve("abAB"), 4)
     self.assertEqual(solver.solve("aabAAB"), 6)
     self.assertEqual(solver.solve("dabAcCaCBAcCcaDA"), 10)