28 lines
345 B
Awk
Executable File
28 lines
345 B
Awk
Executable File
#!/usr/bin/awk -f
|
|
|
|
function score() {
|
|
if(a["red"] <= 12 && a["green"] <= 13 && a["blue"] <= 14) sum1 += round
|
|
sum2 += a["red"] * a["green"] * a["blue"]
|
|
}
|
|
|
|
BEGIN {
|
|
RS="[:,;\n]"
|
|
}
|
|
|
|
$1=="Game" {
|
|
score()
|
|
round=$2
|
|
delete a
|
|
next
|
|
}
|
|
|
|
{
|
|
a[$2] = $1 > a[$2] ? $1 : a[$2]
|
|
}
|
|
|
|
END {
|
|
score()
|
|
print sum1
|
|
print sum2
|
|
}
|