DEV Community

Jeremy Grifski
Jeremy Grifski

Posted on

Does Anyone Still Code Golf? The 280 Character Challenge

Awhile back, I had written a program to play Rock Paper Scissors in Python. It's a pretty simple program, but I really liked how eloquent the solution was.

Flash forward a couple years and you'll find me, two years into a PhD program looking for anything to do but read more research. While browsing Twitter, I saw a tweet asking folks to share their favorite technical article:

Now, I've been consistently writing two articles a week for the last four years, so I've amassed quite the collection of articles. But, for some reason, that article on Rock Paper Scissors is one that always sparks joy, so I decided to revisit it.

As many of you know, revisiting your old work is always a little weird. In this case, part of me was really excited to read it again because there's obviously a bit of nostalgia associated with it. Unfortunately, as I've learned while playing Super Mario 64 recently, sometimes you remember things as better than they were.

Well, when I was reading through that article, I noticed that there were ways I wrote the code that I wouldn't today. It was nothing major, but there were definitely things I would change.

Of course, instead of editing the existing article, I decided to start a new one. This one would pick up where the last one left off two years ago.

That said, instead of writing an article where I would slightly modify the code, I thought it would be fun to take a code golf approach. In other words, how small could I make the program while still maintaining some readability.

Unfortunately, when you go down this road, there's only one place it leads: incomprehensible code in as few characters as possible.

While laying in bed after managing to shrink the program 25%, I had an idea: how cool would it be if I could shrink the program down to 280 characters, so I could post it in its entirety on Twitter?

Alright, so maybe late night ideas aren't that great, but I went through with it anyway. Here's what that looks like:

It's pretty wild, but those 280 characters are enough to execute a Rock Paper Scissors game in Python 3.8 against a computer. Go ahead! Try it!

Top comments (0)