-
Notifications
You must be signed in to change notification settings - Fork 86
Update day03.md - Discussing the solution #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
docs/2024/puzzles/day03.md
Outdated
| 5. And the substring should finish with the closing parentheses, escaped again, so `\)`. | ||
| That's it. Our whole regex looks like this: | ||
| ```scala | ||
| val mulPattern: Regex = """mul\((\d+)\,(\d+)\)""".r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, doesn't need to be quoted:
| val mulPattern: Regex = """mul\((\d+)\,(\d+)\)""".r | |
| val mulPattern: Regex = """mul\((\d+),(\d+)\)""".r |
Also, have you considered using java.util.regex.Pattern.quote or the \Q...\E escapes? They might not do much good for mul, but for do() and don't() that would probably make it easier to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nice. I focused on other parts and somehow I just though , needs to be escaped and didn't check it.
I thought that for this task it'd be more consistent if I didn't use any additional method calls. Since I already discussed escaping parentheses in "mul", then I just did the same for "do" and "don't".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made one more commit, removing the part about escaping commas.
KacperFKorban
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add yourself as the author of the solution, as with the first one? https://scalacenter.github.io/scala-advent-of-code/2024/puzzles/day01
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added my solution in a separate commit. It's already merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I think #590 is what Kacper meant)
No description provided.