Project Euler Problems 1-10 in Python

I’m working to bone up on my python skills so I decided to spend my Sunday doing problems 1-10 from Project Euler.  I’ve done them before with C or Java but this was my first time with Python.  Here are the problems and my commented code for each one in case it interests anybody.

Continue reading “Project Euler Problems 1-10 in Python”

Riddler Classic – 11-4-2016 – Will You Decide the Election?

Here’s my solution to this week’s Riddler Classic puzzle FiveThirtyEight.  Here’s the question: ” You are the only sane voter in a state with two candidates running for Senate. There are N other people in the state, and each of them votes completely randomly! Those voters all act independently and have a 50-50 chance of voting for either candidate. What are the odds that your vote changes the outcome of the election toward your preferred candidate?  More importantly, how do these odds scale with the number of people in the state? For example, if twice as many people lived in the state, how much would your chances of swinging the election change?”

Continue reading “Riddler Classic – 11-4-2016 – Will You Decide the Election?”

Riddler Express – 10-14-16 – Turning Coins Over

Here’s my solution to this week’s Riddler Express question from FiveThirtyEight.  Here’s the question: “You place 100 coins heads up in a row and number them by position, with the coin all the way on the left No. 1 and the one on the rightmost edge No. 100. Next, for every number N, from 1 to 100, you flip over every coin whose position is a multiple of N. For example, first you’ll flip over all the coins, because every number is a multiple of 1. Then you’ll flip over all the even-numbered coins, because they’re multiples of 2. Then you’ll flip coins No. 3, 6, 9, 12 … And so on. What do the coins look like when you’re done? Specifically, which coins are heads down?”

Continue reading “Riddler Express – 10-14-16 – Turning Coins Over”