Taking the ‘Daily’ out of ‘Daily Programmer’

The past year, I’ve been actively participating in reddit’s r/dailyprogrammer subreddit. According to GitHub, I made 155 contributions. It is now time to reflect on what I’ve learned, take a small step back and take the ‘Daily’ out of ‘Daily Programmer’.

Being a part of the r/dailyprogrammer community has been a blast. I submitted some pretty sweet solutions, inspired others to step up their programming game and learned A LOT. I started submitting solutions to challenges, because I though it was a great - and fun - way to keep my problem solving brain ticking. I also wanted to step up my Python game and learn some algorithms by heart. Browsing through my commits, I can absolutely confirm what they say about training and flexing your programming muscles. If only it gave me abs, as well.

You know you have really made progress as a software engineer when you look back at your code from a year ago, sigh, and think: How could I have written this MESS?!” They

This is in part because of the community. I skipped a day here and there, but some of the active contributors really take the ‘Daily’ part of the subreddit’s name super serious. And it shows. They have amazed me with shiny one-liners and extremely efficient solutions. Oh, and there’s always a group of people submitting their solution in some ancient or weird language. Not to show off, but to showcase different coding paradigms. Okay, maybe to show off a little bit.

Take a look at this esoteric brainfuck solution to challenge 212 (easy), for example.

1
2
3
4
5
6
7
>>>>>+++>>>>++>>++>>++>>>>++>>++>>++>>>>++>>++>>++>>++>>++>>>>++>>++>>++>>++>>++>
>>>++>>++>>++>>>>++>>>>>>>>>>>>>>>>+>>+>>+>>>>+>>+>>+>>>>+>>+>>+>>+>>+>>>>+>>+>>+
>>+>>+>>>>+>>+>>+>>>>+---[+++<---]+++<<<<<>>>++++++++++[->+++++++++++<]>+<<<<,---
-------[++++++++++[->+>+<<]>>[-<<+>>]<<>>+++++[<<------------->>-]<<[->>>>>>+<<<<
<<]>>>>>>[[->>+<<]>>-]>[<++++---[+++<---]+++<<<<.>>>.>----[++++>----]>-[<++++---[
+++<---]+++<<<++++[-<++++++++>]>>>>----[++++>----]>-[>+<]]>[-<+>]<+[->+<]]>[-<+>]
<---[+++<---]+++<<<<.[-]<,----------]++++++++++.

If this is gibberish to you too, consider looking at my more human-readable solution in Python.

1
2
3
4
5
6
7
8
def encode(sentence):
    sentence_encoded = ""
    for c in sentence:
        if c.lower() in "aeiouåäö" or not c.isalnum():
            sentence_encoded += c
        else:
            sentence_encoded += c + 'o' + c.lower()
    return sentence_encoded

The challenge was simple: encode to and decode from the SUPER-SECRET Rövarspråket. This Swedish phrase roughly translates to Robber’s Language. In this spy language the sentence ‘Jag talar Rövarspråket!’ translates to ‘Jojagog totalolaror Rorövovarorsospoproråkoketot!’, for example. Military grade encryption, as you can see.

Another challenge I really loved working on was challenge 159 (hard). The goal was to build an artificial intelligence for the game Rock Paper Scissors Lizard Spock. If you don’t know that game, it’s basically a spiced up version of the universally played Rock Paper Scissors. It even has similar rules: Scissors cuts Paper, Paper Covers Rock, Rock crushes Lizard, Lizard poisons Spock, Spock smashes Scissors, Scissors decapitates Lizard, Lizard eats Paper, Paper disproves Spock, Spock vaporizes Rock and - as it always has - Rock crushes Scissors. Alternatively, a useful flowchart:

The rules to Rock Paper Scissors Lizard Spock

I went all-in with my solution: I built an interactive game in JavaScript with multiple AI-difficulties to choose from. You can play it on my website or check out the source code on my GitHub.

I honestly applaud the enthusiasm of the subreddit moderators. They put a lot of work in creating and posting new daily challenges. So far, for example, I’ve married off bachelors to eight sisters, built houses in ASCII and communicated with aliens. If you want to and have some great ideas for submissions, you are free to help the moderators out and post a challenge idea. I know I will.

As is hopefully clear by now, I’m still very excited about the r/dailyprogrammer community and being a part of it. Unfortunately, I cannot be as active a member as I used to be. My internship, my freelance work and my (larger) personal projects are taking up a lot of time at the moment. So for now, it is time to take a small step back and take the ‘Daily’ out of ‘Daily Programmer’.