Consider Yourself a Developer? You Should Solve the Project Euler Problems

You Should Solve the Project Euler ProblemsBennett GarnerBlockedUnblockFollowFollowingDec 11I’m going to make a bold claim: every developer (and aspiring developer) should solve the first 50 Project Euler problems.The benefits of working on the Project Euler problems are too great to ignore:They’ll expose whether you understand the basic operations of the language you’re using, and they can be solved in any programming languageYou’ll learn how to write solid, standard, vanilla code..No libraries needed, so you won’t have crutches to rely onYou’ll have to think about how you store and access data in memoryYou’ll need to optimize processing speed and think hard about algorithmsIn this quick (<5 minute read) article, I’ll make my case for why you should solve the Project Euler problems in every programming language you want to learn.Start with the fundamentalsVince Lombardi with Bart Starr — Public DomainVince Lombardi, the legendary American football coach, would start every pre-season training with a (now famous) speech:“Gentlemen,” he’d say to a room of professional football players, “this is a football.” He’d go on to explain the fundamentals of playing and winning at the game — running, passing, tackling, and kicking.Lombardi’s ruthless focus on the fundamentals made him the winningest coach in the history of football, with more championships (5) than any other coach in history.The same principles apply to software development.Any coding challenge will test your ability to use variables, conditional statements, loops, and other common features of programming languages.Project Euler, however, is an especially rigorous test of your understanding and command of the fundamentals..You’ll have to combine the fundamentals in different permutations in order to solve the problems.And the fundamentals are all you’ll need..If you’ve been coding web apps, games, or other software, chances are you’ve become used to using certain libraries to accomplish specific, predictable tasks.Project Euler takes away those libraries and purely tests your ability to reason about simple logical problems and write simple code that addresses those problems.Training for something that’s hard to teach: Optimization IntuitionThere’s a reason why every Computer Science undergraduate program includes a course in Algorithms & Data Structures, and why so many companies test algorithmic thinking in their hiring process.At its core, writing good code is about applying the best solution to the logical problem at hand.The challenge is to know when to spend time optimizing and when to go with the simple solution.Sometimes the straightforward solution is the best solution.The solution that is the most readable to other humans and intuitively makes sense is often the best.The first few Project Euler problems will teach you this lesson..They involve simple computations with (relatively) small upper bounds..Computers are fast, and there’s no need to create work for yourself over-optimizing the first few solutions.Other times, you’ll need to optimize in order to see real performance gainsWhat a theoretical Algorithms class in university can’t teach you is what it feels like to wait for a slow algorithm to compute the answer to a problem.A great developer has intuition about efficiency..Over time, experienced devs develop a sixth sense for sub-optimal implementations of solutions to problems..You develop that intuition from experience, and the later Project Euler problems are great teachers of what efficiency intuition feels like.If an algorithm is going to get used often or on large inputs, spending time on optimization is worth it for the time savings down the line..In other cases though, it’s not worth the extra time to optimize a solution that will only be used on a small-scale.Judging that optimization trade-off is the intuition that experienced devs have, and it’s a skill that Project Euler can begin to teach.You’ll become more fluent and confident in your language of choiceSolving even a handful of Project Euler problems will work wonders on your confidence and fluency in a given language..It’s also a great way to pick up a new language or refresh a language you used to know.For instance, I’ve been coding in Python pretty exclusively for the past few months, and it has been a while since I wrote anything in C — a language I knew before Python.I started implementing the first few Project Euler problems in C to refresh my skills..It has worked wonders to bring back my skills and remind me of the syntax..Similarly, I used Project Euler to learn the basics of Java, since Java’s syntax is similar to but different in key ways from C.Great chance to practice documentation and testingIf you want to add something impressive to your portfolio, start a GitHub repository where you keep your solutions to the Project Euler problems.Then, when you complete a solution, check your variable and function names to make sure they’re intuitive and remove any code you don’t need.Next, add comments about why you made the decisions you did in your code.. More details

Leave a Reply