Exemple #1
0
def day11_2(data):
    #data = read_input(2015, "111")
    oldPassword = '******'
 
    result = nextPassword(oldPassword)
    AssertExpectedResult('heqaabcc', result, 2)
    return result
Exemple #2
0
def day7_2(data):
    #data = read_input(2015, "701")

    wires, circuit = processInstructionsBooklet(data)
    wires['b'] = 956
    wires = emulateCircuit(wires, circuit)
    result = wires[wires['a']]
    AssertExpectedResult(40149, result, 2)
    return result
Exemple #3
0
def day11_1(data):
    #data = read_input(2015, "111")
    oldPassword = data[0]
    #newPassword = nextPassword(newPassword)
    
    #print("next:",nextPassword('abcdefgh'))
    #print("next:",nextPassword('ghijklmn'))
    result = nextPassword(oldPassword)
    AssertExpectedResult('hepxxyzz', result, 1)
    return result
Exemple #4
0
def day7_1(data):
    #data = read_input(2015, "701")

    wires, circuit = processInstructionsBooklet(data)
    #print(wires)
    wires = emulateCircuit(wires, circuit)
    #print(wires)
    result = wires[wires['a']]
    AssertExpectedResult(956, result, 1)
    return result
Exemple #5
0
def day9_2(data):
    #data = read_input(2015, "901")
    graph, cities = processInputAndBuildGraph(data)    
    cost = 0
    for i in itertools.permutations(list(cities.values())):
        r = path_cost(graph, i)
        if r > cost:
            cost = r
    result = cost
    AssertExpectedResult(804, result, 2)
    return result
Exemple #6
0
def day10_1(data):
    #data = read_input(2015, "101")
    
    rounds = 40
    result = data[0]
    for _ in range(rounds):
        result = playLookAndSay(result, rounds)
    
    result = len(result)
    AssertExpectedResult(329356, result, 1)
    return result
Exemple #7
0
def day10_2(data):
    #data = read_input(2015, "101")
  
    rounds = 50
    result = data[0]
    for _ in range(rounds):
        result = playLookAndSay(result, rounds)
    
    result = len(result)
    AssertExpectedResult(4666278, result, 2)
    return result
Exemple #8
0
def day6_2(data):
    #data = read_input(2015, "601") 

    rows, columns = 1000, 1000   
    grid = [ [ False for i in range(columns) ] for j in range(rows) ]    

    grid = executeInstructions(grid, data, 2)
    result = sum( [ grid[j][i] for i in range(columns) for j in range(rows) ] ) 

    AssertExpectedResult(14687245, result, 2)
    return result
Exemple #9
0
def day12_2(data):    
    #data = read_input(2015, "121")   
    testSamples()

    result = 0
    result = parseAndGetResult(data[0]) 
    
    # 54040 too low
    # 89528 too high
    # should be around 65k :\
    AssertExpectedResult(111754, result, 2)
    return result
Exemple #10
0
def day6_1(data):
    #data = read_input(2015, "601") 

    rows, columns = 1000, 1000   
    grid = [ [ 0 for i in range(columns) ] for j in range(rows) ]    

    grid = executeInstructions(grid, data)

    result = sum( [ grid[j][i] for i in range(columns) for j in range(rows) ] ) 

    AssertExpectedResult(543903, result, 1)
    return result
Exemple #11
0
def day9_1(data):
    #data = read_input(2015, "901")
    graph, cities = processInputAndBuildGraph(data)
    
    #print(cities)
    #for ds in graph:
    #    print(ds)
        
    path = solve_tsp(graph)
    print(path)
    result = path_cost(graph, path)
    AssertExpectedResult(207, result, 1)
    return result
Exemple #12
0
def day16_2(data):
    #data = read_input(2015, "151")  
    candidates = parseAunstSue(data, validatePropertyV2)     

    mostConditionsSatisfied = 0
    for aunt in candidates.keys():
        property = candidates[aunt]

        if len(list(property))  > int(mostConditionsSatisfied):
            mostConditionsSatisfied = len(list(property)) 
            auntSue = int(aunt)
   
    result = auntSue
    AssertExpectedResult(405, result)    
    return result
Exemple #13
0
def day12_1(data):
    #data = read_input(2015, "121")   

    tree2Json = TreeToJson()
    json_parser = Lark(json_grammar, parser='lalr', transformer=tree2Json)
    parse = json_parser.parse
    parsedTree = parse(data[0])
    
    tree2Json.visit_topdown(tree=parsedTree)
    print("sum:", tree2Json.sum())
    
    #print("sum:", parsedTree)
    
    result = tree2Json.sum()
    AssertExpectedResult(111754, result, 1)
    return result
Exemple #14
0
def day15_2(data):
    #data = read_input(2015, "151")  
    ingredients = parseIngredients(data)      

    combinations = [combination for combination in permutations(range(1,100), len(ingredients)) 
                        if sum(combination) == 100 and 
                        sum(np.multiply(combination, [i.calories for i in ingredients.values()])) == 500
                   ]
    bestScore = 0
    for recipe in combinations:
        score = computeCookieRecipeScore(ingredients, (zip(ingredients.keys(), recipe)))
        if score > bestScore:
            bestScore = score
   
    result = bestScore
    AssertExpectedResult(1766400, result)    
    return result
Exemple #15
0
def day15_1(data):
    #data = read_input(2015, "151")  

    ingredients = parseIngredients(data)       
    
    combinations = [combination for combination in permutations(range(1,100), len(ingredients)) if sum(combination) == 100 ]
    bestScore = 0
    for recipe in combinations:
        score = computeCookieRecipeScore(ingredients, (zip(ingredients.keys(), recipe)))
        if score > bestScore:
            bestScore = score
   
    result = bestScore
    
    result = 0
    AssertExpectedResult(21367368, result)    
    return result
Exemple #16
0
def day1_1(data):
    #data = read_input(2015, "251") 
    result, _ = followDirections(data[0])
    AssertExpectedResult(280, result, 1)
    return result
Exemple #17
0
def day2_1(data):
    #data = read_input(2015, "201") 
    boxes = processInputDay2(data)
    result = determineWrappingPaperOrder(boxes)
    AssertExpectedResult(1598415, result, 1)
    return result
Exemple #18
0
def day2_2(data):
    #data = read_input(2015, "201") 
    boxes = processInputDay2(data)
    result = determineRibbonOrder(boxes)
    AssertExpectedResult(3812909, result, 1)
    return result
Exemple #19
0
def day3_1(data):
    #data = read_input(2015, "301") 

    result = findHowManyUniqueDeliveries(data[0])
    AssertExpectedResult(2565, result, 1)
    return result
Exemple #20
0
def day5_2(data):
    #data = ['qjhvhtzxzqqjkmpb', 'xxyxx' , 'uurcxstgmygtbstg', 'ieodomkazucvgmuy']
    result = countNiceStrings(data, 2)
    AssertExpectedResult(55, result, 2)
    return result
Exemple #21
0
def day8_2(data):
    #data = read_input(2015, "801")
    _, result = processStringsAndComputeResult(data)
    AssertExpectedResult(2074, result, 2)
    return result
Exemple #22
0
def day8_1(data):
    #data = read_input(2015, "801")
    result, _ = processStringsAndComputeResult(data)
    AssertExpectedResult(1342, result, 1)
    return result
Exemple #23
0
def day4_1(data):
    #data = read_input(2015, "301") 
    result = findLowestPositiveNumber(data[0])
    AssertExpectedResult(254575, result, 1)
    return result
Exemple #24
0
def day4_2(data):
    #data = read_input(2015, "301") 
    result = findLowestPositiveNumber(data[0], 2)
    #result = findLowestPositiveNumber('pqrstuv', 2)
    AssertExpectedResult(1038736, result, 2)
    return result
Exemple #25
0
def day1_2(data):
    #data = read_input(2015, "251") 
    _, result = followDirections(data[0], True)
    AssertExpectedResult(1797, result, 2)
    return result
Exemple #26
0
def day3_2(data):
    #data = read_input(2015, "301") 

    result = findHowManyUniqueDeliveriesWithRoboSanta(data[0])
    AssertExpectedResult(2639, result, 2)
    return result
Exemple #27
0
def day5_1(data):
    #data = read_input(2015, "301") 
    result = countNiceStrings(data)
    AssertExpectedResult(255, result, 1)
    return result