Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### PART 1 ####
- {
- split($0, ar, ",");
- left = nrSeq(ar[1]); right = nrSeq(ar[2]);
- if (left ~ right || right ~ left) { result ++; }
- }
- END { print result; }
- func nrSeq(seq, i,result, ar) {
- split(seq, ar, "-");
- for (i=ar[1]; i<=ar[2]; i++) {result =result "L" i "R"; }
- return result;
- }
- #### PART 2 ####
- {
- split($0, ar, ",");
- delete arLeft; fillAr(arLeft, ar[1]);
- delete arRight; fillAr(arRight, ar[2]);
- for (i in arLeft) {
- if (i in arRight) { result ++; break; }
- }
- }
- END { print result; }
- func fillAr(ar, seq, i) {
- split(seq, tmpAr, "-");
- for (i=tmpAr[1]; i<=tmpAr[2]; i++) {
- ar[i] = 1;
- }
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement