Unlimited Coding Practice Courtesy of FiveThirtyEight

09 May 2017 · by bathompso · in  Data Science 

One of the hardest things about learning coding is the fact that there isn't a large base of fairly easy coding questions that let you learn a ton by doing, instead of reading enough books and other materials to tackle more challenging word problems. When asked by several friends to recommend methods of getting into Data Science, I always recommend learning how to code by doing rather than reading, however that's a difficult thing to do without any stand-out resources.

Well fret no more, as I've found a solid source of word problems that will get you rolling with even just a minimal amount of code knowledge: FiveThirtyEight's "The Riddler" puzzles. FiveThirtyEight is all about math and stats, so they have a weekly post that challenges people to solve some complex word problems with math. Take this example problem:

Imagine that it’s the beginning of time, and the Supreme Court’s nine seats are empty. Assume further that seats on the bench are filled only if the same party controls both the presidency and the Senate. Every election, each of the two parties has a 50 percent chance of gaining control of the executive or legislative branch. Outcomes of the elections are independent, and the length of time for which a justice serves is uniformly distributed between zero and 40 years. What is the expected number of vacancies on the bench in the long run?

This is a fairly complex problem to solve flat-out with math, especially for me who, although a math major in undergrad, has let a lot of that knowledge get pushed out of my brain. Instead of slogging through the math to try and come up with a solution, this is a pretty straightforward problem to solve via simulation. It actually requires very little advanced coding knowledge, yet should be challenging enough to a new coder to force you to learn some new techniques and increase your familiarity with coding.

Below is my walkthrough of the latest "The Riddler" Classic puzzle via simulation, just to show how I approach simulation of one of these types of questions. This type of approach isn't something that will get you mentioned on the blog, but it does give you many beginner-level coding problems that will help you to advance your skills and challenge some of the harder word problems you normally see in "learn to code" classes elsewhere.

Connect With Me
Recent Twitter Status