|
247 | 247 | "always X",
|
248 | 248 | "a X"
|
249 | 249 | ],
|
250 |
| - "Reference solution": "re.sub(r'test.+', r'X', flags=re.I)" |
| 250 | + "Reference solution": "re.sub(r'test.+', r'X', s, flags=re.I)" |
251 | 251 | },
|
252 | 252 | "15": {
|
253 | 253 | "question": "Split the given input strings to get the corresponding output as shown below.",
|
|
423 | 423 | "right column": [
|
424 | 424 | "redo X credible :X: rod X"
|
425 | 425 | ],
|
426 |
| - "Reference solution": "re.sub(r'\\bre[ae]?d\\b', 'X', s)" |
| 426 | + "Reference solution": "re.sub(r'\\bre[ae]?d\\b', r'X', s)" |
427 | 427 | },
|
428 | 428 | "25": {
|
429 | 429 | "question": "Change whole words starting with `hand` and ending with `s` or `y` or `le` to `X.",
|
|
540 | 540 | "flags": "0",
|
541 | 541 | "function": "re.split",
|
542 | 542 | "left column": [
|
| 543 | + "food:good", |
| 544 | + "food:good-cool", |
| 545 | + "food:good-cool;tool", |
543 | 546 | "42:no-op;10:car-tr:u-ck;SQ1"
|
544 | 547 | ],
|
545 | 548 | "right column": [
|
| 549 | + "['food:good']", |
| 550 | + "['food:good-cool']", |
| 551 | + "['food', 'cool', 'tool']", |
546 | 552 | "['42', 'op', '10', 'tr:u-ck', 'SQ1']"
|
547 | 553 | ],
|
548 | 554 | "Reference solution": "re.split(r':[^-]+-([^;]+);', s)"
|
|
557 | 563 | "right column": [
|
558 | 564 | "a\n1<> b 2<>"
|
559 | 565 | ],
|
560 |
| - "Reference solution": "re.sub(r'<[^>]+>', s)" |
| 566 | + "Reference solution": "re.sub(r'<[^>]+>', r'', s)" |
561 | 567 | },
|
562 | 568 | "34": {
|
563 | 569 | "question": "Match strings whose first non-whitespace character is not a `#` character. Any string made up of only whitespace characters should not be matched.",
|
|
611 | 617 | "right column": [
|
612 | 618 | "X not X X X took X"
|
613 | 619 | ],
|
614 |
| - "Reference solution": "re.sub(r'\\b(\\w|(\\w)\\w*\\2)\\b', 'X', s, flags=re.I)" |
| 620 | + "Reference solution": "re.sub(r'\\b(\\w|(\\w)\\w*\\2)\\b', r'X', s, flags=re.I)" |
615 | 621 | },
|
616 | 622 | "38": {
|
617 | 623 | "question": "Convert the given markdown anchors to hyperlinks as shown below.",
|
|
729 | 735 | "{{cherry-200",
|
730 | 736 | "2-42"
|
731 | 737 | ],
|
732 |
| - "Reference solution": "re.search(r'\\A({{)?[a-z]+-\\d+(?(1)}})\\Z', w)" |
| 738 | + "Reference solution": "re.search(r'\\A({{)?[a-z]+-\\d+(?(1)}})\\Z', s)" |
733 | 739 | },
|
734 | 740 | "46": {
|
735 | 741 | "question": "Replace all whole words with `X` unless it is preceded by `(` character.",
|
|
743 | 749 | "(apple) X X)",
|
744 | 750 | "X (mango) (grape"
|
745 | 751 | ],
|
746 |
| - "Reference solution": "re.sub(r'(?<!\\()\\b\\w+', 'X', s)" |
| 752 | + "Reference solution": "re.sub(r'(?<!\\()\\b\\w+', r'X', s)" |
747 | 753 | },
|
748 | 754 | "47": {
|
749 | 755 | "question": "Replace all whole words with `X` unless it is followed by `)` character.",
|
|
757 | 763 | "(apple) X berry)",
|
758 | 764 | "X (mango) (X"
|
759 | 765 | ],
|
760 |
| - "Reference solution": "re.sub(r'\\b\\w+\\b(?!\\))', 'X', s)" |
| 766 | + "Reference solution": "re.sub(r'\\b\\w+\\b(?!\\))', r'X', s)" |
761 | 767 | },
|
762 | 768 | "48": {
|
763 | 769 | "question": "Replace all whole words with `X` unless it is preceded by `(` or followed by `)` characters.",
|
|
771 | 777 | "(apple) X berry)",
|
772 | 778 | "X (mango) (grape"
|
773 | 779 | ],
|
774 |
| - "Reference solution": "re.sub(r'(?<!\\()\\b\\w+\\b(?!\\))', 'X', s)" |
| 780 | + "Reference solution": "re.sub(r'(?<!\\()\\b\\w+\\b(?!\\))', r'X', s)" |
775 | 781 | },
|
776 | 782 | "49": {
|
777 | 783 | "question": "Extract all whole words that do not end with `e` or `n`.",
|
|
875 | 881 | "hello,nice ice,42,2",
|
876 | 882 | "1,,stall small"
|
877 | 883 | ],
|
878 |
| - "Reference solution": "re.sub(r'(?<![^,])\\s+|\\s+(?![^,])', s)" |
| 884 | + "Reference solution": "re.sub(r'(?<![^,])\\s+|\\s+(?![^,])', r'', s)" |
879 | 885 | },
|
880 | 886 | "56": {
|
881 | 887 | "question": "Match strings that satisfy all of these rules:\n* at least two alphabets\n* at least 3 digits\n* doesn't end with a whitespace character",
|
|
995 | 1001 | "But Cool Te",
|
996 | 1002 | "it this ."
|
997 | 1003 | ],
|
998 |
| - "Reference solution": "re.sub(r'hat.*it', r'', flags=re.S|re.I)" |
| 1004 | + "Reference solution": "re.sub(r'hat.*it', r'', s, flags=re.S|re.I)" |
999 | 1005 | },
|
1000 | 1006 | "64": {
|
1001 | 1007 | "question": "Delete from `start` if it is at the beginning of a line up to the next occurrence of the `end` at the end of a line. Match these markers case insensitively.",
|
|
0 commit comments