Beispiel #1
0
def test():
   # Part 1
   tests = {
         '1': len('11'),
         '11': len('21'),
         '21': len('1211'),
         '1211': len('111221'),
         '111221': len('312211'),
         }
   testing.runTests(lambda x: advent10.process(x, 1), tests)
Beispiel #2
0
def test():
   tests = {
         ("20 15 10 5 5", 25): 4,
         }
   testing.runTests(lambda x: advent17.process(x[0], x[1],
      advent17.getCombinations), tests)
   tests = {
         ("20 15 10 5 5", 25): 3,
         }
   testing.runTests(lambda x: advent17.process(x[0], x[1],
      advent17.getMinContainers), tests)
Beispiel #3
0
def test():
    tests = {
            '>': 2,
            '^>v<': 4,
            '^v^v^v^v^v': 2,
            }
    testing.runTests(lambda x: advent3.walk(x,1), tests)

    tests = {
            '^>': 3,
            '^>v<': 3,
            '^v^v^v^v^v': 11,
            }
    testing.runTests(lambda x: advent3.walk(x,2), tests)
Beispiel #4
0
def test():
   # Part 1
   tests = {
         '""': 2,
         '"abc"': 2,
         '"aaa\\"aaa"': 3,
         '"\\x27"': 5,
         }
   testing.runTests(advent8.diff, tests)

   tests = {
         '""': 4,
         '"abc"': 4,
         '"aaa\\"aaa"': 6,
         '"\\x27"': 5,
         }
   testing.runTests(advent8.encode, tests)
Beispiel #5
0
def test():
    lines = [
        [
            "Alice would gain 54 happiness units by sitting next to Bob.",
            "Alice would lose 79 happiness units by sitting next to Carol.",
            "Alice would lose 2 happiness units by sitting next to David.",
            "Bob would gain 83 happiness units by sitting next to Alice.",
            "Bob would lose 7 happiness units by sitting next to Carol.",
            "Bob would lose 63 happiness units by sitting next to David.",
            "Carol would lose 62 happiness units by sitting next to Alice.",
            "Carol would gain 60 happiness units by sitting next to Bob.",
            "Carol would gain 55 happiness units by sitting next to David.",
            "David would gain 46 happiness units by sitting next to Alice.",
            "David would lose 7 happiness units by sitting next to Bob.",
            "David would gain 41 happiness units by sitting next to Carol.",
        ]
    ]
    tests = {"0": 330}
    testing.runTests(lambda s: advent13.process(lines[int(s)]), tests)
Beispiel #6
0
def test():
   # Part 1
   tests = {
         'ugknbfddgicrmopn': True,
         'aaa': True,
         'jchzalrnumimnmhp': False,
         'haegwjzuvuyypxyu': False,
         'dvszwmarrgswjxmb': False,
         }
   testing.runTests(advent5.check1, tests)

   # Part 2
   tests = {
         'qjhvhtzxzqqjkmpb': True,
         'xxyxx': True,
         'uurcxstgmygtbstg': False,
         'ieodomkazucvgmuy': False,
         }
   testing.runTests(advent5.check2, tests)
Beispiel #7
0
def test():
    tests = {
            '[1,2,3]': 6,
            '{"a":2,"b":4}': 6,
            '[[[3]]]': 3,
            '{"a":{"b":4},"c":-1}': 3,
            '{"a":[-1,1]}': 0,
            '[-1,{"a":1}]': 0,
            '[]': 0,
            '{}': 0,
            }
    testing.runTests(advent12.sumAllNumbers, tests)

    tests = {
            '[1,2,3]': 6,
            '[1,{"c":"red","b":2},3]': 4,
            '{"d":"red","e":[1,2,3,4],"f":5}': 0,
            '[1,"red",5]': 6,
            }
    testing.runTests(advent12.skipRed, tests)
Beispiel #8
0
def test():
    # Part 1
    tests = {
            '(())': 0,
            '()()': 0,
            '(((': 3,
            '(()(()(': 3,
            '))(((((': 3,
            '())': -1,
            '))(': -1,
            ')))': -3,
            ')())())': -3,
            }
    testing.runTests(advent1.count, tests)

    # Part 2
    tests = {
            ')': 1,
            '()())': 5,
            }
    testing.runTests(advent1.findBasement, tests)
Beispiel #9
0
def test():
    tests = {"aaaaaaaa": "aaaaaaab", "aaaaaaaz": "aaaaaaba", "aaaaazzz": "aaaabaaa", "zzzzzzzz": "aaaaaaaa"}
    testing.runTests(advent11.incrementString, tests)

    tests = {"hijklmmn": False, "abbceffg": False, "abbcegjk": False, "abcdffaa": True, "ghjaabcc": True}
    testing.runTests(advent11.checkValid, tests)

    tests = {"abcdefgh": "abcdffaa", "ghijklmn": "ghjaabcc"}
    testing.runTests(advent11.findNext, tests)
Beispiel #10
0
def test():
    tests = {
            '2x3x4': [2,3,4],
            '1x1x10': [1,1,10],
            }
    testing.runTests(advent2.getDimensions, tests)

    tests = {
            (2,3,4): 58,
            (1,1,10): 43,
            }
    testing.runTests(advent2.calculatePaper, tests)

    tests = {
            (2,3,4): 34,
            (1,1,10): 14,
            }
    testing.runTests(advent2.calculateRibbon, tests)
Beispiel #11
0
def test():
    tests = {"abcdef": 609043, "pqrstuv": 1048970}
    testing.runTests(lambda x: advent4.findMatch(x, "00000"), tests)