From 670ab615472dfc1bf80c29e996c587341a78ed03 Mon Sep 17 00:00:00 2001 From: Ravi Shah <63246200+Rav4s@users.noreply.github.com> Date: Wed, 2 Dec 2020 08:47:14 -0600 Subject: [PATCH] Add files via upload --- day1.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 day1.py diff --git a/day1.py b/day1.py new file mode 100644 index 0000000..8b4cf69 --- /dev/null +++ b/day1.py @@ -0,0 +1,56 @@ +import time + +def split_into_list(file_path): + f = open(file_path, "r") + list_of_lists = [] + for line in f: + stripped_line = line.strip() + stripped_line = int(float(stripped_line)) + #line_list = stripped_line.split() + list_of_lists.append(stripped_line) + + f.close() + return(list_of_lists) + +def add_to_each(list_of_terms, num): + j = 0 + for i in list_of_terms: + print(i) + try: + k = j+1 + #print(k) + l = list_of_terms[k] + #print(l) + j=j+1 + total = 0 + total += list_of_terms[num]+l + print(list_of_terms[num]) + print(l) + print(total) + if (total) == 2020: + print("equal") + print("yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeet") + newlist = [] + newlist.append(list_of_terms[num]) + newlist.append(l) + return newlist + else: + print("not equal") + except IndexError: + print("done") + +def iterate_list(list_of_terms): + for i in range(len(list_of_terms)): + newlist = add_to_each(list_of_terms, i) + print(newlist) + if newlist != None: + return newlist + else: + continue + +list_of_terms = split_into_list("day1input.txt") + +answer_nums = iterate_list(list_of_terms) +print(answer_nums) +final_answer = (answer_nums[0]*answer_nums[1]) +print(final_answer)