blob: ef270116a2a2624d88685f71fc3ac8786c5e837d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import math
import sequtils
import sets
import strutils
func priority(group: seq[string]): int =
let sets = group.map_it it.to_hash_set
var common = sets.foldl a * b
result = common.pop.ord - 96
if result < 0:
result += 58
let
elves = split_lines strip read_all stdin
groups = elves.distribute elves.len div 3
echo sum groups.map priority
|