A collection of code golfing solutions.
Code golf is the art of coming up with code that solves a challenge while making the length of code (usually counted in bytes) as small as possible.
Over the years, I've participated in multiple code golfing challenges in One Lone Coder (OLC) discord server. So I've decided that, I would like to accumulate solutions in a single place for future reference. And that place is this repository.
NOTE: I should mention, that final solutions for the challenges would usually end up as a shared effort. That is, when challenges appear, people on the discord server post solutions publicly and everyone can feel free to improve upon others solutions. As a result, multiple people contribute various small optimisations that shave off few bytes at a time, until a grand collective solution is produced. Therefore, I do not claim full ownership of the solutions collected in this repository.
I mainly use C language for code golf as I consider it the most fun. But I also occasionally use C++, Lua and Python.
For actively developing a golfed solution, I prefer Godbolt. For sharing final solution, I mainly use ideone or Godbolt (pro tip: for sharing gcc C/C++ with solutions, add -w to hide warnings).
For counting bytes I use mothereff.
On the last 5 days of 2021, first ever 5-day Golf With Gorbit code golfing event was hosted in the OLC server. As curious and excited as I was, I decided to give myself a go at it. In the event, each day for 5 days, a new code golf challenge would appear for which participants had 24 hours to make a submission. After intense 5-day session, I managed to come victorious in 2/5 challenges by crafting shortest solutions in C. Since Gorbit was feeling generous, winners were awarded with Steam game keys. Not knowing what I was getting myself into, I've picked Factor.io. Back then, I didn't play Steam's games, so to reclaim my prize, I had to create Steam account. Fast forward 2 years, and I have racked up 1000 hours on Factor.io and became one of the main developers of Factor.io pirate ship mod. A wild but enjoyable ride that was..
Here is a list of websites, that I consider worthy of checking out related to code golf:
- Exchange code golf challenges, solutions and tips:
- Submit code golf solutions online in language of your choice and get feedback immediately. As a bonus, it has code golf tips for each language, leaderboards, achievements and more: