Skip to content

Instantly share code, notes, and snippets.

@fxn
Last active December 1, 2022 21:00
Show Gist options
  • Save fxn/910c514328d26dd2b32a4c9d5052475e to your computer and use it in GitHub Desktop.
Save fxn/910c514328d26dd2b32a4c9d5052475e to your computer and use it in GitHub Desktop.
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
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