Exemple #1
0
def part1():
    # template.printMatrix(input)
    data = copy.copy(input)
    done = False
    while not done:
        (done, data) = processRound(data, False)
        # print(done)
        # template.printMatrix(data)
    # print(data)
    template.printMatrix(data)

    return len([v for row in data for v in row if v == '#'])
Exemple #2
0
def part2():
    data = copy.copy(input)
    done = False

    (done, data) = processRound(data, True)

    getNewSeat2(3, 2, data)

    while not done:
        (done, data) = processRound(data, True)
        print(done)
        # template.printMatrix(data)
    print(data)
    template.printMatrix(data)

    return len([v for row in data for v in row if v == '#'])
Exemple #3
0
def part1():
    state = [[0 if v == '.' else 1 for v in row] for row in input]
    print("Initial Value: ")
    template.printMatrix(state)
    print()
    
    state = [state]
    # print(state)
    
    cycles = 6
    
    for i in range(cycles):
        state = simulateCycle(state)
        print("Cycle %d done"%(i+1))
        # printState(state)
    
    return sum([v for layer in state for row in layer for v in row])
Exemple #4
0
def printMap(map, units):
    cMap = copy.deepcopy(map)
    print([(u.type, u.pos, u.hp) for u in units])
    for u in units:
        cMap[u.pos.y][u.pos.x] = u.type
    template.printMatrix(cMap)
Exemple #5
0
def printState(state):
    for l, layer in enumerate(state):
        print("Layer %d"%l)
        template.printMatrix(layer)