As I mentioned at the end of my “Lucky” book review, the book said that Trump in 2020 was only 43K votes away from winning the election. In my 2020 updates to the State Election Map, I had also this calculation, but came up with a different number. (76K) I already knew there was one problem that I hadn’t addressed, which was breaking the vote down by congressional district for Maine and Nebraska, so decided to bite the bullet and fix it up.
Along the way I discovered there were another issue causing wrong results: the difference between an electoral vote tie and a win can be substantial in some cases, and I was just calculating for a win. (in the case of a tie the vote goes to the House of Representatives, but each state gets a vote so it’s complicated, but in 2020 Trump probably would have one)
Here’s the commit for these changes. It was a lot more work than I expected, and I’m actually in the middle of another project that I put on pause because I was so irritated these numbers were wrong 🙂
As an aside, the Rust code to calculate this got a bit more complicated and the more that happens the more I sprinkle in
.clone() calls just to make things work. Which is fine for correctness but not great for performance. In this case it’s fine, though, the script still runs in ~1 second, and I guess it’s nice to have markers where I can try to optimize things if necessary later!