示例#1
0
    def test_run(self):
        #remember to set the assert to the known examples and place the example test into testInput.txt!

        inputImmune = common.loadInput('testimmune.txt',
                                       True)  #True = split, False = string
        inputInfection = common.loadInput('testinfection.txt',
                                          True)  #True = split, False = string
        testObject = Solution()
        self.assertEqual(51, testObject.solution(inputImmune, inputInfection))
示例#2
0
 def run(self):
     input_list = common.loadInput('input9.txt', True)
     print('Advent Day: Day9')
     p1 = self.part1(input_list, 25)
     print('Part1: %s' % str(p1))
     p2 = self.part2(input_list, p1)
     print('Part2: %s' % str(p2))
示例#3
0
 def test_run(self):
     #remember to set the assert to the known examples and place the example test into testInput7.txt!
     input_list = common.loadInput('testInput7.txt', True)
     testObject = Day7.Solution()
     testObject.generate_graph(input_list)
     self.assertEqual(4, testObject.part1())
     self.assertEqual(32, testObject.part2())
示例#4
0
 def run(self):
     input_list = common.loadInput('input4.txt', False)
     print('Advent Day: Day4')
     p1 = self.part1(input_list)
     print('Part1: %s' % str(p1))
     p2 = self.part2(input_list)
     print('Part2: %s' % str(p2))
示例#5
0
 def run(self):
     input_list = common.loadInput('input.txt', True)
     print('Advent Day: standard')
     p1 = self.part1(input_list)
     print('Part1: %s' % str(p1))
     p2 = self.part2(input_list)
     print('Part2: %s' % str(p2))
示例#6
0
 def run(self):
     inputList = common.loadInput('input.txt',
                                  True)  #True = split, False = string
     print('Advent Day: X')
     self.solution(
         inputList,
         '.#####.##.#.##...#.#.###..#.#..#..#.....#..####.#.##.#######..#...##.#..#.#######...#.#.#..##..#.#.#'
     )
示例#7
0
 def run(self):
     input_list = common.loadInput('input7.txt', True)
     print('Advent Day: Day7')
     self.generate_graph(input_list)
     p1 = self.part1()
     print('Part1: %s' % str(p1))
     p2 = self.part2()
     print('Part2: %s' % str(p2))
示例#8
0
 def run(self):
     inputList = common.loadInput('input.txt', True)
     print('Advent Day: %s', self.solution(inputList))
示例#9
0
 def run(self):
     inputImmune = common.loadInput('immune.txt',
                                    True)  #True = split, False = string
     inputInfection = common.loadInput('infection.txt',
                                       True)  #True = split, False = string
     print('Advent Day: %s' % self.solution(inputImmune, inputInfection))
示例#10
0
 def test_run_pt2(self):
     input_list = common.loadInput('testInput3.txt', True)
     testObject = Day3.Solution()
     self.assertEqual(336, testObject.part2(input_list))
示例#11
0
 def run(self):
     inputList = common.loadInput('input.txt',
                                  True)  #True = split, False = string
     print('Advent Day: %s' % self.solution(inputList))
示例#12
0
 def test_run(self):
     #remember to set the assert to the known examples and place the example test into testInput6.txt!
     input_list = common.loadInput('testInput6.txt', False)
     self.assertEqual(11, Day6.Solution.part1(input_list))
     self.assertEqual(6, Day6.Solution.part2(input_list))
示例#13
0
 def test_run(self):
     input_list = common.loadInput('testInput11.txt', True)
     self.assertEqual(37, Day11.Solution.part1(input_list))
示例#14
0
import sys
sys.path.append('../')
from scaffolding import common

inputList = common.loadInput('input.txt', True)  #True = split, False = string
inputNumbers = common.pullNumbersFromList(
    inputList, True)  #True = include signs, False: all numbers are positive

print("Advent 6b.")

gridSize = max(
    max(inputNumbers,
        key=lambda x: max(x))) + 1  #one bigger as the gridcount starts at 0
maxDistance = 10000
regionSize = 0

for n in range(gridSize):
    for m in range(gridSize):
        count = 0

        for point in inputNumbers:
            count = count + abs(n - point[0]) + abs(m - point[1])

            if count >= maxDistance:
                continue

        if count < maxDistance:
            regionSize = regionSize + 1

#print(max(sizes.iteritems(), key=operator.itemgetter(1))[0])
示例#15
0
 def test_run_pt2(self):
     input_list = common.loadInput('testInput4-p2.txt', False)
     testObject = Day4.Solution()
     self.assertEqual(4, testObject.part2(input_list))
示例#16
0
 def run(self):
     inputList = common.loadInput('test6.txt',
                                  False)  #True = split, False = string
     print('Advent Day: X')
     self.solution(inputList)
示例#17
0
    def test_run_2(self):
        input_list = common.loadInput('testInput10.txt', True)
        self.assertEqual(8, Day10.Solution.part2(input_list))

        input_list = common.loadInput('testInput10-2.txt', True)
        self.assertEqual(19208, Day10.Solution.part2(input_list))
示例#18
0
                getattr(self, cmd)(int(value))

            if self.pos < 0 or len(self.currentProgram) <= self.pos:
                return self.accumulator

        return -1

    def acc(self, value):
        self.accumulator = self.accumulator + value
        self.pos = self.pos + 1

    def jmp(self, value):
        self.pos = self.pos + value

    def nop(self, value):
        self.pos = self.pos + 1

    def run(self):
        print('Advent Day: Day8')
        p1 = self.part1()
        print('Part1: %s' % str(p1))
        p2 = self.part2()
        print('Part2: %s' % str(p2))


if __name__ == '__main__':
    input_list = common.loadInput('input8.txt', True)

    Solution(input_list).run()
示例#19
0
	def test_run(self):
		#remember to set the assert to the known examples and place the example test into testInput.txt!
		inputList = common.loadInput('testInput.txt', False) 
		testObject = Solution()
		self.assertEqual(138, testObject.solution(inputList))
示例#20
0
 def test_run(self):
     #remember to set the assert to the known examples and place the example test into testInput.txt!
     input_list = common.loadInput('testInput.txt', True)
     self.assertEqual(138, standard.Solution.part1(input_list))
示例#21
0
 def test_run(self):
     numbers = common.loadInput('testInput9.txt', True)
     self.assertEqual(Day9.Solution.part1(numbers, 5), 127)
     numbers = common.loadInput('testInput9-2.txt', True)
     self.assertEqual(Day9.Solution.part2(numbers, 127), 62)
示例#22
0
	def run(self):
		inputImmune = common.loadInput('immune.txt', True) 
		inputInfection = common.loadInput('infection.txt', True)
		print('Advent Day: %s' % self.solution(inputImmune, inputInfection))
示例#23
0
 def test_run(self):
     inputList = common.loadInput('testInput.txt', True)
     testObject = Solution()
     self.assertEqual(241861950, testObject.solution(inputList))
示例#24
0
 def test_run(self):
     inputList = common.loadInput('input.txt', True)
     self.assertEqual(896, Solution.solution(self, inputList))
示例#25
0
#from datetime import datetime
import re
import sys
sys.path.append('../')
from scaffolding import common

print("Advent 4.a")

inputList = common.loadInput('input.txt')
#numberList = common.pullNumbersFromList(inputList)

def processInput():
	actions = dict()
	for row in inputList:
		m = re.search('[^\[]+(?=\])', row)
		date = m.group(0).strip()	

		m = re.search('\](.*)', row)
		action = m.group(0)[1:].strip()

		actions[date] = action

	return actions

def processGuards(actions):
	guards = dict()
	currentGuard = 0;
	timeAsleep = None

	dates = list(actions.keys())
	dates.sort()
示例#26
0
	def test_run(self):
		#remember to set the assert to the known examples and place the example test into testInput.txt!
		inputList = common.loadInput('testInput.txt', 'True') 
		self.assertEqual('CABDFE', Solution.solution(self, inputList))
示例#27
0
 def test_run2(self):
     input_list = common.loadInput('testInput7-2.txt', True)
     testObject = Day7.Solution()
     testObject.generate_graph(input_list)
     self.assertEqual(126, testObject.part2())
示例#28
0
 def test_run(self):
     #remember to set the assert to the known examples and place the example test into testInput.txt!
     inputList = common.loadInput('testInput.txt', True)
     testObject = Solution()
     self.assertEqual(
         325, testObject.solution(inputList, '#..#.#..##......###...###'))
示例#29
0
 def test_run(self):
     #remember to set the assert to the known examples and place the example test into testInput3.txt!
     input_list = common.loadInput('testInput3.txt', True)
     testObject = Day3.Solution()
     self.assertEqual(7, testObject.part1(input_list))