Anyone else doing the Protohackers challenges?

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! :slight_smile:

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/ 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.

What you say sounds interesting, though the link you gave gives me a fat red warning that the certificate was invalid…

Ignoring it in a sandboxed Browser just shows “ok”…

Weird :thinking: No cert issues here, my browser is showing a valid cert issued by Let’s Encrypt.

I did update the URL, I had “/results” on there by accident (doesn’t explain your TLS issue though)

The cert I see is for, not including the upper level or any siblings.

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.

Between “first coffee” and “first coffee in office” something seems to have changed and now it works for me.

Lets assume there have been propagation or configuration issues.

As they posted problem 2 recently, the site doesn’t seem to be very old.

I don’t understand the smoke test. What do they mean with “end of file”? I receive data and send it back, but then they close the connexion.

So that works with test content.0 but not content.1 but I can’t figure out what they want. Any help?

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.

If they close their end, you still have your end. Thats why they say in the FAQ that you can’t use ngrok for the smoke test.

If you push up a repo with your code somewhere I’d be happy to take a look.

Lots of people free to help on the Discord too :slight_smile: There are channels for each problem.

Okay, today I learnt :smiley: Thank you. I do not use ngrok but it seems that all commercial tunnel software will suffer from the same problem.

@mattbaker here is my last attempt protohackers/smoke_test.ex at main · lud/protohackers · GitHub .

1 Like

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 :joy:

I’ve been doing them! My question 2 (means to an end) solution needs work, but otherwise been having a blast so far.

1 Like

I’ll share my repo too!

I liked the way you wrote about each problem so I copied your format and did the same, that was a nice touch

I finished my attempt to the smoke_test yesterday and tinkered a bit with the repo setup over the day.

1 Like

I just finished my deployment setup, and the smoke test passes.

Unfortunately I had to build with OTP 23 because the GLIBC version of my server (debian bullseye) seems old. But OTP 23 does not compile on my machine :smiley:

So I had to build inside a docker container and copy the release back to the host. Now it works well and the smoke test passes.

I’ve been cloning the repo to my server, and wrote a little script to book into an iex shell w/the application running ( protohackers/ at main · jackharrhy/protohackers · GitHub )

been working good so far!

1 Like