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