This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
https://gitlab.com/maximoburrito/advent2023/-/blob/main/src/day03/main.clj?ref_type=heads day 3 is very early in aoc to for such messy code...
crazy one! definitely feel like they're starting harder this year, tho i believe they try to assign harder problems on weekends vs weekdays https://github.com/russmatney/advent-of-code/blob/master/src/_2023/_03/core.clj
I might still do some tweaking to this, I sort of “over-built” my data maps and can probably streamline them a little bit. https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_03.clj
Already feel tired of seeing an "adjacent coordinate" puzzle in AoC again, so I'm just going to steal some of your solutions to test-drive squint :)
Also quite a mess, have to clean up a bit later 🙂 https://github.com/jantorestolsvik/advent-of-code-2023/blob/main/src/day03.clj
I stored the gear coordinates by concatenating x and y coordinates. Ofc there was an overlapping index then, so had to add a “-” in between
Apparently the grid is created with some assumptions that made the logic simpler, so was able to solve both parts with same algo basically: https://github.com/caseneuve/aoc2023/blob/master/day03/solution.clj
Hi all! I am a bit bored by parsing this year. Didn’t want initially post my solutions, but here we go. Maybe it’ll help someone https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2023/day_03.clj
Wrote a recursive parser that handled conjoining the nums from the start, so both parts were just fancy transductions: https://github.com/alexalemi/advent/blob/main/2023/clojure/p03.clj doesn't feel the cleanest.
@UGNFWPPGF https://squint-cljs.github.io/cherry/?boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2F3e871513ab6f2462841f75fc99668f841f33dabb%2Faoc_ui.cljs&repl=true&src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4CgooZGVmIGlucHV0ICgtPj4gKGpzLWF3YWl0IChmZXRjaC1pbnB1dCAyMDIzIDMpKQogICAgICAgICAgICAgc3RyL3NwbGl0LWxpbmVzKSkKCihkZWZuIGRpZ2l0PyBbeF0KICAoI3tcMSBcMiBcMyBcNCBcNSBcNiBcNyBcOCBcOSBcMH0geCkpCgooZGVmbiAtPmdyaWQKICAoW3Jhd10gKC0%2BZ3JpZCBuaWwgcmF3KSkKICAoW3ByZWQgcmF3XQogICAoLT4%2BIHJhdwogICAgICAgIChtYXAtaW5kZXhlZAogICAgICAgICAgKGZuIFt5IHJvd10KICAgICAgICAgICAgKC0%2BPiByb3cgKG1hcC1pbmRleGVkCiAgICAgICAgICAgICAgICAgICAgICAgKGZuIFt4IGNoYXJdCiAgICAgICAgICAgICAgICAgICAgICAgICAoaWYgcHJlZAogICAgICAgICAgICAgICAgICAgICAgICAgICAod2hlbiAocHJlZCBjaGFyKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIFtbeCB5XSBjaGFyXSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgW1t4IHldIGNoYXJdKSkpCiAgICAgICAgICAgICAgICAgKGZpbHRlciBzZXEpCiAgICAgICAgICAgICAgICAgKGludG8gW10pKSkpCiAgICAgICAgKGZpbHRlciBzZXEpCiAgICAgICAgKGludG8gW10pCiAgICAgICAgKGFwcGx5IGNvbmNhdCkKICAgICAgICAoaW50byB7fSkpKSkKCihkZWZuIHBhcnQ%2FIFtjaGFyXQogIChub3QgKG9yICg9IFwuIGNoYXIpIChkaWdpdD8gY2hhcikpKSkKCihkZWZuIC0%2BcGFydC1sb2NzIFtyYXddCiAgKC0%2BZ3JpZCBwYXJ0PyByYXcpKQoKKGNvbW1lbnQKICAoLT5wYXJ0LWxvY3MgaW5wdXQpCiAgKC0%2BZ3JpZCBpbnB1dCkKCiAgKC0%2BPiAiNDUuLiouNCIgKG1hcCAoZm4gW2NoYXJdIChkaWdpdD8gY2hhcikpKSkpCgooZGVmbiBuZWlnaGJvcnMgW1t4IHldXQogICN7W3ggKGluYyB5KV0KICAgIFt4IChkZWMgeSldCiAgICBbKGluYyB4KSB5XQogICAgWyhkZWMgeCkgeV0KICAgIFsoaW5jIHgpIChpbmMgeSldCiAgICBbKGRlYyB4KSAoZGVjIHkpXQogICAgWyhkZWMgeCkgKGluYyB5KV0KICAgIFsoaW5jIHgpIChkZWMgeSldfSkKCihkZWZuIHgtbnVtLW5laWdoYm9ycyBbZ3JpZCBbeCB5XV0KICAobGV0IFstPngtbmJycwogICAgICAgIChmbiBbLT54XQogICAgICAgICAgKGxvb3AgW25ldy1jb29yZCBbKC0%2BeCB4KSB5XSBuYnJzIFtdXQogICAgICAgICAgICAoY29uZAogICAgICAgICAgICAgIChuaWw%2FIChncmlkIG5ldy1jb29yZCkpIG5icnMKICAgICAgICAgICAgICAoZGlnaXQ%2FIChncmlkIG5ldy1jb29yZCkpCiAgICAgICAgICAgICAgKHJlY3VyIFsoLT4gKGZpcnN0IG5ldy1jb29yZCkgLT54KSB5XSAoY29uY2F0IG5icnMgW25ldy1jb29yZF0pKQogICAgICAgICAgICAgIDplbHNlICAgICAgICAgICAgICAgICAgIG5icnMpKSkKICAgICAgICBsZWZ0LW5icnMgICgtPngtbmJycyBkZWMpCiAgICAgICAgcmlnaHQtbmJycyAoLT54LW5icnMgaW5jKV0KICAgIChjb25jYXQgKHJldmVyc2UgbGVmdC1uYnJzKSBbW3ggeV1dIHJpZ2h0LW5icnMpKSkKCihjb21tZW50CiAgKHgtbnVtLW5laWdoYm9ycyAoLT5ncmlkIGlucHV0KSBbMyAyXSkKICAoeC1udW0tbmVpZ2hib3JzICgtPmdyaWQgaW5wdXQpIFsyIDJdKQogICh4LW51bS1uZWlnaGJvcnMgKC0%2BZ3JpZCBpbnB1dCkgWzAgMF0pCiAgKQoKKGRlZm4gY29vcmQtPm51bWJlciBbZ3JpZCBjb29yZF0KICAobGV0IFtudW0tY29vcmRzICh4LW51bS1uZWlnaGJvcnMgZ3JpZCBjb29yZCldCiAgICBbKGZpcnN0IG51bS1jb29yZHMpCiAgICAgKC0%2BPiBudW0tY29vcmRzCiAgICAgICAgICAobWFwIGdyaWQpCiAgICAgICAgICAoYXBwbHkgc3RyKQogICAgICAgICAgKHBhcnNlLWxvbmcpKV0pKQoKKGNvbW1lbnQKICAoY29vcmQtPm51bWJlciAoLT5ncmlkIGlucHV0KSBbMiAyXSkKICAoY29vcmQtPm51bWJlciAoLT5ncmlkIGlucHV0KSBbMCAwXSkKICApCgoKKGRlZm4gcGFydC1udW1iZXJzCiAgKFtyYXddIChwYXJ0LW51bWJlcnMgbmlsIHJhdykpCiAgKFtvcHRzIHJhd10KICAgKGxldCBbZ3JpZCAgICAgICgtPmdyaWQgcmF3KQogICAgICAgICBwYXJ0LWxvY3MgKC0%2BcGFydC1sb2NzIHJhdyldCiAgICAgOzsgc3ltYm9scy0%2BbmVpZ2hib3ItZGlnaXRzCiAgICAgKGNvbmQtPj4gcGFydC1sb2NzCiAgICAgICB0cnVlCiAgICAgICAobWFwIChmbiBbW2Nvb3JkIHN5bV1dCiAgICAgICAgICAgICAgW3N5bQogICAgICAgICAgICAgICAobGV0IFtuYnJzIChuZWlnaGJvcnMgY29vcmQpXQogICAgICAgICAgICAgICAgICgtPj4gbmJycwogICAgICAgICAgICAgICAgICAgICAgKGZpbHRlciAoZm4gW25icl0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAobGV0IFtjaGFyIChncmlkIG5icildCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZGlnaXQ%2FIGNoYXIpKSkpCiAgICAgICAgICAgICAgICAgICAgICAobWFwIChmbiBbbmJyXSBbbmJyIChncmlkIG5icildKSkpKV0pKQoKICAgICAgICg6c3ltYm9sIG9wdHMpIChmaWx0ZXIgKGZuIFtbc3ltIF9uYnJzXV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoI3soOnN5bWJvbCBvcHRzKX0gc3ltKSkpCgogICAgICAgdHJ1ZQogICAgICAgKG1hcCAoZm4gW1tfc3ltIG5icnNdXQogICAgICAgICAgICAgICgtPj4gbmJycwogICAgICAgICAgICAgICAgICAgKG1hcCAoZm4gW1tjb29yZCBfZGlnaXRdXQogICAgICAgICAgICAgICAgICAgICAgICAgIChjb29yZC0%2BbnVtYmVyIGdyaWQgY29vcmQpKSkKICAgICAgICAgICAgICAgICAgIChpbnRvIHt9KSkpKQoKICAgICAgICg6cGFydC1jb3VudCBvcHRzKQogICAgICAgKGZpbHRlciAoZm4gW3hzXQogICAgICAgICAgICAgICAgICg9ICg6cGFydC1jb3VudCBvcHRzKSAoY291bnQgeHMpKSkpKSkpKQoKKGNvbW1lbnQKICA7OyBwYXJ0IDEKICAoLT4%2BCiAgICAocGFydC1udW1iZXJzIGlucHV0KQogICAgKG1hcCB2YWxzKQogICAgKGFwcGx5IGNvbmNhdCkKICAgIChyZWR1Y2UgKykpCgogIDs7IHBhcnQgMgogICgtPj4KICAgIGlucHV0CiAgICAocGFydC1udW1iZXJzCiAgICAgIHs6c3ltYm9sICAgICBcKgogICAgICAgOnBhcnQtY291bnQgMn0pCiAgICAobWFwIHZhbHMpCiAgICAobWFwICMoYXBwbHkgKiAlKSkKICAgIChyZWR1Y2UgKykpICAKICAp
Code much more complicated than it should be, but everything passed on the first try (rather rare on my side!) : https://github.com/arnaudgeiser/advent-of-code/blob/master/2023/clojure/src/advent_of_code/day3.clj
Always happy to use (almost) the same code and processed data for both parts. https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day03.clj
I struggled a bit with scanning the input. Seeing where I went overboard when looking at your solution, @U6JS7B99S
@U0ETXRFEW I struggled too. I rewrote the parsing multiple times 😄
A bit late to the party but I'm pretty happy with how this turned out. Calculation done in a single pass transduction, and it's my first time using iteration
too. https://github.com/imrekoszo/advent-of-clj/blob/master/src/imrekoszo/advent/y23/day3.clj
Mine was actually quite clean: https://gitlab.com/mauricioszabo/advent-of-code-2023-clj/-/blob/master/src/advent_2023_clj/day03.clj?ref_type=heads
I learned how to use flags on regexes in clojurescript, it was ok after that and @U04V15CAJ’s tips related to javascript object keys.
@U05094X3J excellent, added it https://github.com/squint-cljs/squint/blob/main/examples/aoc/solutions.md!
@UK0810AQ2 I think re-matcher
might be of help for that.
I can stagger the lines then do something like
(let [m (re-matcher #"((...)?(.\d.)+(...)?)"
(str/join (map str/join (map vector
"..2......."
"467..114.."
"...*......"))))]
[(re-find m)
(re-find m)
(re-find m)])
then in each group look for one containing a symbol which marks it as a part, and extract the numbers from every 3rd index starting from the secondpart 1 in plain clojure with hyperfiddle rcf tests https://gist.github.com/corasaurus-hex/9cbe6a0190f1dce0acbe79ccfdcc9593