aoc2022/d03/part1.awk

13 lines
236 B
Awk

{
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}