Beispiel #1
0
def main():
    logging.basicConfig(level=logging.DEBUG)
    logging.info('Started')
    lv = LoadValues()
    numbers = lv.list_to_intlist()
    logging.debug(len(numbers))
    preamble = 25

    for i in range(len(numbers) - preamble - 1):
        number = numbers[i + preamble]
        candidates = numbers[i:i + preamble]
        res = is_sum(number, candidates)
        if not res:
            break
    print("Star 1 : ", number)

    (start, end) = find_contiguous(number, numbers)
    logging.debug((start, end))
    logging.debug(numbers[start:end])
    min_val = min(numbers[start:end])
    max_val = max(numbers[start:end])

    print("Star 2 : ", min_val + max_val)

    logging.info('Finished')
Beispiel #2
0
def main():
    lv = LoadValues()
    numbers = lv.list_to_intlist()
    logging.debug(len(numbers))
    adapters = [0] + numbers + [max(numbers) + 3]
    logging.debug(adapters)

    adapters.sort()
    logging.debug(adapters)
    diff = [adapters[i + 1] - adapters[i] for i in range(len(adapters) - 1)]
    logging.debug(diff)

    one = sum([i == 1 for i in diff])
    three = sum([i == 3 for i in diff])
    logging.debug((one, three, one * three))
    print("Star 1 : ", one * three)

    pr.enable()
    number = count_paths_list(0, len(adapters) - 1, adapters)
    print("Star 2 : ", number)
    pr.disable()
    logging.info('Finished')