day 1: python
parent
bf735e1527
commit
14879c0d73
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
def main():
|
||||
content = list(map(str.strip, open(INPUT_FILE, 'r').readlines()))
|
||||
elfs = []
|
||||
cal_sum = 0
|
||||
for line in content:
|
||||
if line == '':
|
||||
elfs.append(cal_sum)
|
||||
cal_sum = 0
|
||||
continue
|
||||
cal_sum += int(line)
|
||||
print(max(elfs))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
def main():
|
||||
content = list(map(str.strip, open(INPUT_FILE, 'r').readlines()))
|
||||
elfs = []
|
||||
cal_sum = 0
|
||||
for line in content:
|
||||
if line == '':
|
||||
elfs.append(cal_sum)
|
||||
cal_sum = 0
|
||||
continue
|
||||
cal_sum += int(line)
|
||||
elfs.sort()
|
||||
print(sum(elfs[-3:]))
|
||||
if __name__ == '__main__':
|
||||
main()
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
def main():
|
||||
with open(INPUT_FILE, 'r') as f:
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue