# -*- coding: utf-8 -*-
"""
Created on Tue Dec  1 13:01:28 2020

@author: Darren
"""


# Day 1 Advent of Code 2020 Part 1
def report_repair():
    '''
    Before you leave, the Elves in accounting just need you to fix your
    expense report (your puzzle input); apparently, something isn't quite
    adding up. Specifically, they need you to find the two entries that sum to
    2020 and then multiply those two numbers together.

    For example, suppose your expense report contained the following:
        1721
        979
        366
        299
        675
        1456
    In this list, the two entries that sum to 2020 are 1721 and 299.
    Multiplying them together produces 1721 * 299 = 514579, so the correct
    answer is 514579.

    Of course, your expense report is much larger. Find the two entries that
    sum to 2020; what do you get if you multiply them together?

    Returns
    -------
    Float.

    '''
    import numpy as np
    f = open('AoC20201201.txt', 'r')
    data = np.loadtxt(f)
    f.close()
    for number in data:
        check = 2020 - number
        if check in data:
            return(number*check)
        else:
            continue


# Day 1 Advent of Code 2020 Part 2
def report_repair_3():
    '''
    The Elves in accounting are thankful for your help; one of them even
    offers you a starfish coin they had left over from a past vacation. They
    offer you a second one if you can find three numbers in your expense
    report that meet the same criteria.

    Using the above example again, the three entries that sum to 2020 are 979,
    366, and 675. Multiplying them together produces the answer, 241861950.

    In your expense report, what is the product of the three entries that sum
    to 2020?

    Returns
    -------
    Float.

    '''
    import numpy as np
    f = open('AoC20201201.txt', 'r')
    data = np.loadtxt(f)
    f.close()
    sortdat = sorted(data)
    for index in range(0, np.size(sortdat)):
        num1 = sortdat[index]
        for num2 in sortdat[(index+1):]:
            for num3 in sortdat[(index+2):]:
                if num1 + num2 + num3 == 2020:
                    return(num1*num2*num3)
                else:
                    continue
