瀏覽代碼

Day 1a

main
Noëlle 4 年之前
當前提交
7696ded209
共有 1 個文件被更改,包括 22 次插入0 次删除
  1. 22
    0
      day1a.py

+ 22
- 0
day1a.py 查看文件

@@ -0,0 +1,22 @@
def comp(a, nums):
for el in nums:
if a + el == 2020:
return el
return False

def main():
with open("input1a.txt") as file:
lines = file.readlines()
lines = [int(line.strip()) for line in lines]
cur = -1
a, b = -1, -1
while len(lines) > 0:
a = lines.pop()
c = comp(a, lines)
if c:
b = c
break
print(f"{a} * {b} = {a*b}")

if __name__ == "__main__":
main()

Loading…
取消
儲存