Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Part 1
- BEGIN { thing="A XB YC ZA YB ZC X"; }
- { total += index(thing, substr($0, 3, 1)) / 3 + (int((index(thing, $0) + 8) / 9)) * 3; }
- END { print total; }
- # Part 2
- BEGIN { scores="ABC"; outcomes="XYZ"; }
- {
- i = index(outcomes, substr($0, 3, 1));
- total += (index(scores, substr($0, 1, 1)) - 1 + ((i + 1) % 3)) % 3 + 1 + (i - 1) * 3;
- }
- END { print total; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement