You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

30 lines
634 B

BEGIN {
sum = 0
}
{
cardNo = $2
delete winingNumbers;
delete myNumbers;
for (i = 3; $i != "|"; i++) {
winingNumbers[i - 2] = $i;
}
for(c = 1;i+c <= NF;c++) {
myNumbers[c] = $(i + c)
}
score = 0;
for (i = 1; i <= length(myNumbers); i++) {
good = 0;
for (j = 1; j <= length(winingNumbers); j++) {
if (myNumbers[i] == winingNumbers[j]) {
good = 1;
break;
}
}
if (!good) continue;
if (score == 0) score = 1; else score = score * 2;
}
sum = sum + score;
}
END {
print sum;
}