Example #1
0
def main(verbose=False):
    result = []
    perms = all_permutations(range(1, 11))
    for perm in perms:
        magic = magic_5_gon(perm)
        sums = [sum(triple) for triple in magic]
        if len(set(sums)) == 1:
            to_add = "".join("".join(str(ind) for ind in triple)
                             for triple in magic)
            result.append(to_add)
    return max(int(concat) for concat in result if len(concat) == 16)
Example #2
0
def most_consecutive(dig_cands, sign_cands):
    all_encountered = []
    for perm in all_permutations(dig_cands):
        for sign_set in sign_cands:
            for number in results(sign_set, perm):
                if number > 0 and number not in all_encountered:
                    all_encountered.append(number)
    biggest = 1
    while biggest + 1 in all_encountered:
        biggest = biggest + 1
    return biggest
Example #3
0
def main(verbose=False):
    data = [[int(dig) for dig in row] for row
            in get_data(79).split("\r\n") if row]

    all_values = list(set(reduce(operator.add, data)))
    for password in all_permutations(all_values):
        correct = True
        for left, middle, right in data:
            left_index = password.index(left)
            middle_index = password.index(middle)
            right_index = password.index(right)
            if not (left_index < middle_index < right_index):
                correct = False
                break
        if correct:
            break
    if not correct:
        raise Exception("No match found")
    return ''.join(str(key) for key in password)