Last active
December 1, 2022 21:00
-
-
Save fxn/910c514328d26dd2b32a4c9d5052475e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/os | |
import std/strutils | |
var max = 0 | |
var partial = 0 | |
for line in lines(paramStr(1)): | |
if len(line) != 0: | |
partial += parseInt(line) | |
else: | |
if partial > max: | |
max = partial | |
partial = 0 | |
echo max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/algorithm | |
import std/os | |
import std/strutils | |
var partials: seq[int] | |
var partial = 0 | |
for line in lines(paramStr(1)): | |
if len(line) != 0: | |
partial += parseInt(line) | |
else: | |
partials.add(partial) | |
partial = 0 | |
var sum = 0 | |
for partial in partials.sorted(SortOrder.Descending)[0..2]: | |
sum += partial | |
echo sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment