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 == '#'])
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 == '#'])
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])
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)
def printState(state): for l, layer in enumerate(state): print("Layer %d"%l) template.printMatrix(layer)