Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Code Golf is a fun form of programming competition where the aim is to produce the shortest source code that implements an algorithm. In this talk we will show how we tackle a complex problem: helping Santa schedule the work of his elves Army to deliver presents on Christmas Day. We will go step by step on how to find an algorithm to solve it and how to use Ruby’s language features to make it as short as possible. You’ll learn a few secret shortcuts built into Ruby that you probably don’t know about.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this engaging presentation at RubyConf 2021, Ely Alvarado explores the concept of "Golf Scripting" with Ruby, using a holiday-themed problem to illustrate the techniques involved in writing concise code. The central challenge presented is helping Santa schedule his elves for a complex Christmas delivery task, highlighting the intricacies of optimizing code for efficiency and brevity. **Key Points Discussed:** - **Introduction to Golf Scripting:** Golf scripting is a programming competition focused on writing the shortest source code to solve an algorithmic problem. Ely introduces the audience to the premise of helping Santa manage the elves’ deliveries, emphasizing the need for an algorithm under strict size constraints due to Santa's quantum computing system. - **The Problem Setup:** The task requires calculating the delivery time for a fixed number of elves, with specific details about the time it takes to deliver presents and lumps of coal. The nature of the problem relates to the well-known "bin packing" problem in computer science, which Ely explains in simple terms that are accessible to the audience. - **Algorithm Approach:** Ely shares how he initially develops a functional solution in Ruby, measuring its size and effectiveness, before diving into the process of "golfing" it down to fewer bytes. This iterative coding process involves various techniques to minimize code length, like using fewer characters in variable names, removing unnecessary method calls, and adopting alternative logical structures. - **Step-by-Step Code Golfing Technique:** The presentation covers step-by-step modifications made to shrink the code from around 4 kilobytes to approximately 392 bytes. Ely demonstrates common tactics in golf scripting, such as renaming variables to single characters, omitting whitespace, and utilizing Ruby’s built-in methods more effectively. - **Conclusion and Coding Philosophy:** Ely concludes by stating that while golf scripting is a fun and challenging exercise, it is not something to be used in professional code bases. He emphasizes the importance of creativity and problem-solving skills that come from such code golfing exercises, inviting the community to engage with coding challenges both creatively and pragmatically. - **Resources and Community Contribution:** Lastly, Ely references the Code Golf community on Stack Exchange, sharing links to problems and resources for those interested in improving their golfing skills in Ruby.
Suggest modifications
Cancel