Skip to content

Commit f7a71fa

Browse files
authored
Update day18.md
1 parent c24ac14 commit f7a71fa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/day18.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ line as a sequence of tokens, and I need to decide whether to take action on any
2626
Let's parse the data. I want to take a String like `1 + (2 * (3 * 4) + 5)` and see it as a simple vector of
2727
values. The parentheses are always next to a number, but everything else is space delimited. For the numeric
2828
strings, let's turn them into `BigInteger`s right away, since we'll get overflow if we use `Long`s. The regex
29-
is a little ugly, but it's not bad. If I put in artifical spaces, you can see it's essentially one big `or`,
30-
and `re-seq` returns a sequence of tokens that match the regex. The `mapv` only attempts to parse values
31-
that aren't symbols; in theory, I could have done a try-catch parse for each token instead.
29+
is a little ugly, but it's not bad. If I put in artifical spaces to get `\d+ | \( | \) | \*`, you can see
30+
it's essentially one big `or`, and `re-seq` returns a sequence of tokens that match the regex. The `mapv`
31+
only attempts to parse values that aren't symbols; in theory, I could have done a try-catch parse for each
32+
token instead.
3233

3334
I won't spend any time going over [Clojure-Java interop](https://clojure.org/reference/java_interop), but
3435
suffice it to say that `(BigInteger. "123")`, with that extra period, calls the constructor of `BigInteger`
@@ -166,4 +167,4 @@ valid, so we don't have to worry about running out of operations.
166167
(ordered-arithmetic tokens other-ops)))
167168
```
168169

169-
So yeah, I had a ton of fun with this problem!
170+
So yeah, I had a ton of fun with this problem!

0 commit comments

Comments
 (0)