DEV Community

Jeremy Grifski
Jeremy Grifski

Posted on

1 2

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!

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay