Beispiel #1
0
def countAndPrintStrings(condition):
    lines = util.getLines()
    count = 0
    for line in lines:
        if condition(line):
            count += 1
    print("Number of nice strings: {}".format(count))
Beispiel #2
0
def page():
    global currentStory
    global timex
    if request.method == "GET":
        return render_template("page.html", Title=currentStory, restOfLines=util.getLines(currentStory))
    else:
        if request.form.has_key("submit"):
            newLine = request.form["newLineBox"]
            util.addLine(newLine, currentStory)
            return redirect(url_for("page"))
        else:
            return redirect(url_for("home"))
def run(mode):
    lines = util.getLines()
    instructions = parseLines(lines)
    if mode == 1:
        lights = [OFF] * WIDTH * WIDTH
    else:
        lights = [0] * WIDTH * WIDTH
    performInstructions(instructions, lights, mode)
    if mode == 1:
        output = countLightsTurnedOn(lights)
    else:
        output = sumLightIntensity(lights)
    print("Output: {}".format(output))
Beispiel #4
0
def main():
    lines = util.getLines()
    tree = parseLines(lines)

    # Part One
    name = "a"
    value = getValue(name, tree) % (2**16)
    print("{}: {}".format(name, value))

    # Part Two
    resetTree(tree)
    tree["b"].value = value

    newValue = getValue(name, tree) % (2**16)
    print("{}: {}".format(name, newValue))
Beispiel #5
0
def run(func):
    lines = util.getLines()
    cities = parseLines(lines)
    distance = findShortestRouteDistance(cities, func)
    print("Distance: {}".format(distance))
def getReindeers():
    lines = util.getLines()
    return parseLines(lines)
def partTwo():
    lines = util.getLines("./input_with_me.txt")
    attendees = parseLines(lines)
    happinessChange = findMaxHappinessChange(attendees)
    print("Max happiness Change: {}".format(happinessChange))
    pass
def partOne():
    lines = util.getLines()
    attendees = parseLines(lines)
    happinessChange = findMaxHappinessChange(attendees)
    print("Max happiness Change: {}".format(happinessChange))
    pass