Frectonz
Advent of Code is back this year and It starts tomorrow, December 1 Every day at 2:00LT until December 25 you will get a two part programming puzzle with a christmas theme. https://adventofcode.com/ I first started doing it in 2021 but i only got to Day…
I just completed "Trebuchet?!" - Day 1 - Advent of Code 2023
Today's challenge mostly had to do with parsing the input correctly.
First part was easy, as always
In the second part i ran into a wall, all of the tests were passing but when i ran it with the main input, it didn't work (this is the worst situation to be in while doing AoC).
Today's challenge mostly had to do with parsing the input correctly.
First part was easy, as always
In the second part i ran into a wall, all of the tests were passing but when i ran it with the main input, it didn't work (this is the worst situation to be in while doing AoC).
😁1
Frectonz
I just completed "Trebuchet?!" - Day 1 - Advent of Code 2023 Today's challenge mostly had to do with parsing the input correctly. First part was easy, as always In the second part i ran into a wall, all of the tests were passing but when i ran it with…
I was using this parser combinators lib called nom. What you had to parse was turning words to digits like this
"one" = 1
'two" = 2
...
"nine" = 3
but the thing i didn't notice while i wrote the parser was that
"twone" = 2, 1
"oneight" = 1, 8
The words could overlap each other and the problem was this didn't conform with how nom and most other parser combinator libraries work. Parser combinator libs scan the input string eating away the things they have parsed out.
For example, "twone" with the first implementation of my parser, would be turned into (2, "ne"), see how the "o" got taken away, that was the problem.
FInding out that this was a problem took me sometime but i finally figured it out.
So the lesson here is, "don't use a parser combinator lib for everything, sometimes regex is enough"
"one" = 1
'two" = 2
...
"nine" = 3
but the thing i didn't notice while i wrote the parser was that
"twone" = 2, 1
"oneight" = 1, 8
The words could overlap each other and the problem was this didn't conform with how nom and most other parser combinator libraries work. Parser combinator libs scan the input string eating away the things they have parsed out.
For example, "twone" with the first implementation of my parser, would be turned into (2, "ne"), see how the "o" got taken away, that was the problem.
FInding out that this was a problem took me sometime but i finally figured it out.
So the lesson here is, "don't use a parser combinator lib for everything, sometimes regex is enough"
👍1
I've completed "Cube Conundrum" - Day 2 - Advent of Code 2023
https://adventofcode.com/2023/day/2
I did this one in Elm.
[Part 1 Solution] [Part 2 Solution]
https://adventofcode.com/2023/day/2
I did this one in Elm.
[Part 1 Solution] [Part 2 Solution]
🔥6
Frectonz
I've completed "Cube Conundrum" - Day 2 - Advent of Code 2023 https://adventofcode.com/2023/day/2 I did this one in Elm. [Part 1 Solution] [Part 2 Solution]
Model your data well and the algorithms you want will almost write themselves.
👍3
Frectonz
Model your data well and the algorithms you want will almost write themselves.
I know i said parser combinator libs are not always needed but i couldn't help myself.
Just look at it, it's beautiful.
The top level parser is
Just look at it, it's beautiful.
The top level parser is
game, and it has a nice hierarchy of small parsers.game calls into cubeSets calls into cubeSet calls into cube🔥3
I've completed "Gear Ratios" - Day 3 - Advent of Code 2023
I used OCaml 🐫 for this one.
[Part 1 Solution] [Part 2 Solution]
I used OCaml 🐫 for this one.
[Part 1 Solution] [Part 2 Solution]
🔥2👏1
Frectonz
I've completed "Gear Ratios" - Day 3 - Advent of Code 2023 I used OCaml 🐫 for this one. [Part 1 Solution] [Part 2 Solution]
|> is the bestevery language should have some way of composing functions by passing the output of one function as an input to another.