Exemple #1
0
def part2():
    data = tuple(read_input(int))
    for i, value in enumerate(data[:-2]):
        for j, value2 in enumerate(data[i + 1:-1]):
            for value3 in data[j + 1:]:
                if value + value2 + value3 == 2020:
                    return value * value2 * value3
Exemple #2
0
def main():
    gen = read_input(transform_function=transform_function)
    data = next(gen)
    data = data[np.newaxis, :]
    for row in gen:
        data = np.vstack((data, row[np.newaxis, :]))
    print(f"part1: {part1(data)}")
    print(f"part2: {part2(data)}")
Exemple #3
0
def main():
    lines = read_input(transform_function=transform_function)
    data = format_input(lines)
    print(f"part1: {part1(data)}")
    print(f"part2: {part2(data)}")
Exemple #4
0
def main():
    lines = read_input(transform_function=transform_function)
    data = format_input(lines)
    solve(data)
Exemple #5
0
def main():
    data = tuple(read_input(transform_function=transform_function))
    print(f"part1: {part1(data)}")
    print(f"part2: {part2(data)}")
Exemple #6
0
    tr_type = sys.argv[6]
    perms_fname = None
    if 'monotone' == tr_type:
        out_dir = sys.argv[7]
    elif len(sys.argv) < 9 or 'lattice' != tr_type:
        print error
        sys.exit()
    else:
        perms_fname = sys.argv[7]
        out_dir = sys.argv[8]
    return sys.argv[1], sys.argv[2], int(sys.argv[3]),\
        sys.argv[4], int(sys.argv[5]), tr_type, perms_fname, out_dir


if __name__ == '__main__':
    if len(sys.argv) < 8:
        print error
        sys.exit()

    source_sentences_fname, phrase_tables_dir, sentences_count, weights_fname, derivations_count,\
        translation_type, permutations_fname, output_dir = parse_arguments()

    source_sentences, phrase_table_fnames, weights, permutations_per_sentence =\
        ir.read_input(source_sentences_fname, phrase_tables_dir, sentences_count, weights_fname, permutations_fname)

    # Create output folder
    common.makedir(output_dir)

    tp.translate(source_sentences, phrase_table_fnames, weights, translation_type,
                 permutations_per_sentence, derivations_count, output_dir)
Exemple #7
0
def part1():
    data = tuple(read_input(int))
    for i, value in enumerate(data[:-1]):
        for value2 in data[i + 1:]:
            if value + value2 == 2020:
                return value * value2