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.
Resources for learning a Functional Programing Language
Elm
https://guide.elm-lang.org/
OCaml
https://dev.realworldocaml.org/
Haskell
http://learnyouahaskell.com/chapters
Elm
https://guide.elm-lang.org/
OCaml
https://dev.realworldocaml.org/
Haskell
http://learnyouahaskell.com/chapters
๐5
Forwarded from KiNFiSH Farms
https://www.youtube.com/watch?v=iSmkqocn0oQ what is your guys think of this @frectonz
YouTube
Simon Peyton Jones - Haskell is useless
Simon Peyton Jones talking about the future of programming languages
KiNFiSH Farms
https://www.youtube.com/watch?v=iSmkqocn0oQ what is your guys think of this @frectonz
The video shows a bunch of language designers discussing their craft and talking about the tradeoffs various languages make.
The video is not meant to be a damnation of Haskell despite the click-bait title "Haskell is useless".
The definition of "use" Simon is talking about here, is actually being able to perform side effects, which one can define as modifying state outside of your program or depending on state outside your program.
Examples of side effects are IO operations, like
- Reading and writing to disk
- Opening network connections and making requests
and also things like random number generation, which make functions non deterministic.
Haskell is considered "useless" in this video because it doesn't allow you to make this side effect operations, because it's trying to be fully deterministic. The realization the peeps are talking about is that actually side effects are the whole point people write programs for, like you wanna make some request to server and show the response or you wanna read data from a file and do some computation on it, and Haskell by disallowing those things, it has made itself "useless"
But that's not really right in the current situation, because Haskell does allow you to do side effects but they do have their own structure of how one handles side effects which are called monads.
And btw Simon is one of the people that actually created Haskell.
And another note
Rust is actually the result of C/C++ folks trying to move closer to the Nirvana land he described in the video.
PS: I am not really a haskell guy, the last time I wrote haskell, is probably more than 2 years ago. I just thought I would share my views since you mentioned me.
The video is not meant to be a damnation of Haskell despite the click-bait title "Haskell is useless".
The definition of "use" Simon is talking about here, is actually being able to perform side effects, which one can define as modifying state outside of your program or depending on state outside your program.
Examples of side effects are IO operations, like
- Reading and writing to disk
- Opening network connections and making requests
and also things like random number generation, which make functions non deterministic.
Haskell is considered "useless" in this video because it doesn't allow you to make this side effect operations, because it's trying to be fully deterministic. The realization the peeps are talking about is that actually side effects are the whole point people write programs for, like you wanna make some request to server and show the response or you wanna read data from a file and do some computation on it, and Haskell by disallowing those things, it has made itself "useless"
But that's not really right in the current situation, because Haskell does allow you to do side effects but they do have their own structure of how one handles side effects which are called monads.
And btw Simon is one of the people that actually created Haskell.
And another note
Rust is actually the result of C/C++ folks trying to move closer to the Nirvana land he described in the video.
PS: I am not really a haskell guy, the last time I wrote haskell, is probably more than 2 years ago. I just thought I would share my views since you mentioned me.
๐2