aoc2022/d03/part1.awk

13 lines
236 B
Awk
Raw Normal View History

2022-12-04 16:57:20 +00:00
{
split(substr($0,1,length($0)/2),arr,"")
r = substr($0,1+length($0)/2)
for (a in arr) {
c = arr[a]
if (index(r,c)>0) {
comm = c
}
}
S += index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", comm)
}
END {print S}