예제 #1
0
    printMap(gMap, units)

    return simulate_battle(gMap, units)


def part2():
    # printMap(gMap, units)

    (gMap, units) = loadMap(input)
    starting_elves = len([e for e in units if e.type == 'E'])
    power = 3
    while (True):
        (gMap, units) = loadMap(input)
        power += 1
        print("\n---\nRunning with power: ", power)

        for elf in [u for u in units if u.type == 'E']:
            elf.power = power

        result = simulate_battle(gMap, units)
        print("Resulting units: ", [(u.type, u.hp, u.pos) for u in units])
        if len([s.type for s in units
                if s.hp > 0 and s.type == 'E']) == starting_elves:
            return result


if __name__ == "__main__":
    # template.funWrapper(part1, "Part 1")
    template.funWrapper(part2, "Part 2")
예제 #2
0
            arr.append(0)
        else:
            arr.append(diff)
            
            
    xs = list(freq.keys())
    ys = [freq[k] for k in xs]
    fig = px.scatter(x=xs, y=ys, log_y=True, log_x=True)
    fig.update_xaxes(title_text="Spoken Number")
    fig.update_yaxes(title_text="# of Times Spoken")
    fig.show()
    # print(arr[:20])
    # print(freq)
    # ks = list(freq.keys())
    # print(len(ks))
    # ks.sort()
    # with open("output15.csv", "w") as outFile:
    #     for k in ks:
    #         outFile.write('%d,%d\n'%(k,freq[k]))
    
    # print(arr[:10])
    return arr[n-1]
    

# --- #

if __name__ == "__main__":
    template.funWrapper(part1, "Part 1")
    # template.funWrapper(part2, "Part 2")
    template.funWrapper(ff, "Fun")
예제 #3
0
        prev_states.add(state)

        (deck1, deck2) = recursive_combat(deck1, deck2, i, gameId)

    if len(deck1) == 0:
        # print("Game %d over. Player 2 wins."%gameId)
        return (2, deck2)
    else:
        # print("Game %d over. Player 1 wins."%gameId)
        return (1, deck1)


def part2():
    deck1 = copy.copy(input[0])
    deck2 = copy.copy(input[1])

    (winner, deck) = recursive_combat_game(deck1, deck2, 1)

    print("GAME OVER...", winner, deck)
    global total_rounds
    print("Total Rounds: ", total_rounds)

    return score_deck(deck)


# --- #

if __name__ == "__main__":
    template.funWrapper(part1, "Part 1")
    # template.funWrapper(part2, "Part 2")
예제 #4
0
        chartState(np.array(state), 20, 20, 20, 1)
    
    return sum([v for layer in state for row in layer for v in row])
    
    
def viz2():
    state = [[0 if v == '.' else 1 for v in row] for row in input]
    nState = np.array([[state]])
    print(nState)
    
    cycles = 6

    for i in range(cycles):
        nState = simulate_cycle_4d(nState)
        print("Cycle %d done"%(i+1))
        chartState(nState, 20, 20, 20, 15)
        # print(nState)
    return nState.sum()
    

# --- #

if __name__ == "__main__":
    template.funWrapper(part1, "Part 1")
    template.funWrapper(viz1, "Visualization 1")
    template.funWrapper(part2, "Part 2")
    template.funWrapper(viz2, "Visualization 2")