예제 #1
0
파일: d01.py 프로젝트: LAHumphreys/AOC
 def main():
     numbers = load_ints("input/d01.txt")
     print(count_increases(numbers))
     print(count_trios(numbers))
예제 #2
0
파일: d10.py 프로젝트: LAHumphreys/AOC
def load_adapters(path):
    adapters = load_ints(path)
    adapters.append(0)
    adapters.sort()
    adapters.append(adapters[-1] + 3)
    return adapters
예제 #3
0
 def test_load_negativeInts(self):
     ints = load_ints(GetTestFilePath("input/ints/negativeInts"))
     self.assertListEqual(
         ints, [
             50962, 126857, -127476, 136169, -62054, 116866, 123235])
예제 #4
0
 def test_detect_floats(self):
     with self.assertRaises(ValueError) as context:
         load_ints(GetTestFilePath("input/ints/hasFloat"))
예제 #5
0
 def test_load_ints(self):
     ints = load_ints(GetTestFilePath("input/ints/123"))
     self.assertListEqual(ints, [1, 2, 3])
예제 #6
0
 def test_load_biggerInts(self):
     ints = load_ints(GetTestFilePath("input/ints/biggerInts"))
     self.assertListEqual(
         ints, [
             50962, 126857, 127476, 136169, 62054, 116866, 123235])
예제 #7
0
 def main():
     values = load_ints("input/d09.txt")
     invalid_number = part_one(values, 25)
     print(invalid_number)
     print(part_two(values, invalid_number))
예제 #8
0
 def test_Example1(self):
     path = GetTestFilePath("samples/d09/example1")
     values = load_ints(path)
     self.assertEqual(part_one(values, 5), 127)
예제 #9
0
파일: d01.py 프로젝트: LAHumphreys/AOC
 def main():
     numbers = load_ints("input/d01.txt")
     print(find_product(numbers))
     print(find_trio_product(numbers))
예제 #10
0
 def test_Sample(self):
     numbers = load_ints(get_test_file_path("samples/d01.txt"))
     self.assertEqual(count_increases(numbers), 7)
예제 #11
0
def calc_rocket_fuel(mass):
    total_fuel = 0
    fuel = calc_fuel(mass)
    while fuel != 0:
        total_fuel += fuel
        fuel = calc_fuel(fuel)

    return total_fuel


def calc_total_fuel(masses):
    fuel = 0
    for mass in masses:
        fuel += calc_fuel(mass)

    return fuel


def total_rocket_fuel(masses):
    fuel = 0
    for mass in masses:
        fuel += calc_rocket_fuel(mass)

    return fuel


if __name__ == "__main__":
    print(calc_total_fuel(load_ints("input/d01.txt")))
    print(total_rocket_fuel(load_ints("input/d01.txt")))