浏览代码

Day 1b

main
Noëlle 4 年前
父节点
当前提交
211eb9c528
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24
    0
      day1b.py

+ 24
- 0
day1b.py 查看文件

@@ -0,0 +1,24 @@
def comp(nums):
for i in range(len(nums)):
a = nums[i]
r = nums[i+1:]
for j in range(len(r)):
b = r[j]
s = r[j+1:]
for k in range(len(s)):
c = s[k]
if a+b+c == 2020:
return (a,b,c)
return False

def main():
with open("input1a.txt") as file:
lines = file.readlines()
lines = [int(line.strip()) for line in lines]

a,b,c = comp(lines)
print(f"{a} * {b} * {c} = {a*b*c}")


if __name__ == "__main__":
main()

正在加载...
取消
保存