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.
Last week a podcast I listen to, the 404, discussed a math problem where you roll six 20-sided die and count how often you get a situation where at least one dice matches another dice. They discussed the math a little and came to the conclusion that it happens far more than you’d think. I thought it’d make a good monte carlo programming exercise so I’ve done just that. Below, you’ll find my C code (though it’s not great) and results for 2-20 dice.
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?”
A few years ago I was working on a project using a multi-rotor UAS to monitor weather. While out in the field, the user needed to be able to see the location of the UAS on a satellite map. The UAS had a GPS and was capable of transmitting that back to the laptop running custom ground station software; however, a constant connection to the internet would be necessary to get satellite maps from Google and many places this would be used won’t have a reliable signal. So I rolled my own solution to fetch the map from Google ahead of time and save it as an image file, which works fine since the location would be known in advance. The challenge was that I needed to have GPS coordinates associated with the image. Instead of having the GPS coordinates in a separate file, I decided to alter the pixels in the image to store the GPS coordinates so that only one file was necessary.
Over at One Mile At A Time, they did an analysis of the recent IHG Priceless Surprises Promotion where you could mail in 94 entrees and get back 94 plays in an online game. Most entrees only won 500 points but some won 1000, 2000, 5000, and a few won free nights or gift cards. I liked his analysis and it got me thinking about possible wins and the distribution. Instead of doing a bunch of math, it was easier to create a Monte Carlo Simulation and the results were a little surprising.
The best tip I can give for thesis writing is to use Latex. For large documents it will be far easier to use and look much better in the end. However, there is a bit of a learning curve with Latex and it does so much that it can sometimes be difficult to even know all the cool things it can do. This posts will cover some of the Latex tips and tricks I’ve learned while writing my thesis over the past
month year way too long. I’m not going to include all the stuff you usually see like how to include a figure or how to make things bold. I assume that you know how to use google and there are thousands of pages of tutorials for those common items. I’m just going to be discussing the lesser known tips that I found helpful for long documents like a thesis or dissertation.
I’ve been using I2C a lot lately and something that keeps popping up is the need to send large numbers. I2C normally only sends a single byte at a time so you are limited to 255 as the largest number. This post will show you how I break large numbers apart to send them over I2C and reassemble them on the other side.