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

1 year ago
  1. BEGIN {
  2. sum = 0
  3. }
  4. {
  5. cardNo = $2
  6. delete winingNumbers;
  7. delete myNumbers;
  8. for (i = 3; $i != "|"; i++) {
  9. winingNumbers[i - 2] = $i;
  10. }
  11. for(c = 1;i+c <= NF;c++) {
  12. myNumbers[c] = $(i + c)
  13. }
  14. score = 0;
  15. for (i = 1; i <= length(myNumbers); i++) {
  16. good = 0;
  17. for (j = 1; j <= length(winingNumbers); j++) {
  18. if (myNumbers[i] == winingNumbers[j]) {
  19. good = 1;
  20. break;
  21. }
  22. }
  23. if (!good) continue;
  24. if (score == 0) score = 1; else score = score * 2;
  25. }
  26. sum = sum + score;
  27. }
  28. END {
  29. print sum;
  30. }