Frectonz
3.47K subscribers
1.91K photos
83 videos
32 files
1.64K links
A place for me to talk about my projects, stuff i find on the internet and what I am currently thinking about.

By @frectonz
Download Telegram
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"
πŸ‘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]
πŸ”₯6
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 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]
πŸ”₯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 best

every 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
πŸ‘5
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.
πŸ‘2
I completely agree.

[the tweet]
πŸ”₯1πŸ’―1
Frectonz
I completely agree. [the tweet]
Capitalism is the only economic system that ensures human progress. It is one of the true super powers of humanity.

It holds societies together.
It even aligns nations to prosper together.

It is magnificent.
πŸ‘Ž7πŸ”₯6
I've completed "Scratchcards" - Day 4 - Advent of Code 2023

I did this one in golang. Part 2 took me way too long to figure out.

[Part 1 Solution] [Part 2 Solution]