I’m having so much fun working on the “Protohackers” challenges, I never got into Advent of Code much but this has been amazing. The challenges are all centered around protocols, so far they’ve all required you build a TCP server (gen_tcp makes it easy).
Also it’s an area Erlang/Elixir really excels at, so it’s fun to build lower level things that leverage all the great Erlang stuff, something I don’t think most of us get to do too often! Good opportunities to play with gen_tcp, messing with bits and bytes, and using binary pattern matching.
There’s an #elixir channel in the protohacker discord if you decide to jump in!
Couple last things to mention:
ngrok doesn’t work, it seems to mess with TCP traffic, so I opened a port in my firewall and forwarded it to my laptop, then I provided that port along with my public IP. I liked that because I didn’t have to bother deploying my app to a VPS/Fly.io/etc. I just closed the port when I was done.
The Elixir intro actually has a section where you implement an echo server with gen_tcp, it’s perfect for getting started.
I have the same issue, but it was fine earlier yesterday (before this thread was posted). Feels like there’s still some development happening any maybe something got misconfigured.
EOF is when the stream ends. Traditionally socket implementations will give you EOL at least once when you try to read from a socket that has been closed by the other side.
Well the problem is unclear. If they close the socket I cannot echo back … And they say we must collect all the data they send before sending back. Anyway, buffer or not it does not work. Maybe my tunnel is bad, though it passes the first test.
Yeah I tried a couple tunnels before giving up an opening a port, same experience here.
Cool solution! I noticed by the 3rd challenge the “active” mode got in my way because I couldn’t reliably dictate how many bytes got read at a time so I felt back to explicitly calling “recv”, if you get it working I’ll be super curious, I’m still convinced I was just missing something
Exercise 6 is the opposite of fun really. I am always failing the large world test by between 1 and 10 tickets, over 800 tickets. I am not sure if it is an optimisation problem.
Hey! If anyone’s interested, here’s my solutions for problems to to 8: GitHub - ahamez/protohackers: Elixir solutions for https://protohackers.com.
It was a fun experience so far (except for problem 7, the specification lacks some details which nearly drove me nuts ).
Also, I’ve been able to use Nx for problem 8 by encoding the cipher as a matrix, it was very fun to do!