Skip To Content

Using Construct
to Game FiveThirtyEight’s Riddler

Reading time: 4 minutes

By Jon MacMillan, Product Manager

If you haven’t checked out the FiveThirtyEight website, you don’t know what you are missing. The website is home to some of the most interesting and engaging statistical analyses, ranging from politics to sports. I recently discovered that they also hold a weekly mathematical riddler competition. I happened to discover this in a week that featured the sixth edition of the Battle for Riddler Nation.

The link above explains the problem in greater detail, but in essence, you are a warlord with 100 armies available to attack ten castles. Castle 1 is worth 1 point if conquered, castle 2, 2 points, and so on up to the 10th castle, which earns you 10 points. You may send any number of armies to each castle. As long as you send more than your competitor, you win that castle. The one additional wrinkle in this edition is that you may send fractional armies rounded to the nearest tenth. For instance, you could send five armies to a castle, but you could also send 4.9 or 5.1 if you prefer.

Breaking the Riddler Down

I always struggle to wrap my head around riddles like these, but the beauty of this challenge is that they also made the previous submission data available. This meant I could test my army’s fortitude against actual previous submissions and decide what might work best.

My initial thought was that there was some clear logic to exploit. We have ten castles that offer a potential of 55 total points. A score of 28 would ensure victory, so focusing on some combination of castles adding up to this value would probably be an intelligent play. This means a winning strategy would be to focus on groups of castles that award 28 total points: castles 10, 9, 5, and 4, or castles 9, 8, 6, and 5. If you put all your armies towards winning these castles, you could safely concede the rest and still win the war.

Reading through previous submissions, this proved to be the most common strategy used. Since my plan wouldn’t be unique, I decided to deploy a tool that my opponents might not have access to: Construct.

Bringing in the Big Gun

Using Construct, I created a job that randomly assigns army allotments to each castle, allowing me to analyze a huge range of possible placements. I had to ensure that the random assignments would add up to 100 armies, which the Construct job checks for and guarantees by correcting for any rounding errors. Construct then compares these assignments to the previous submissions that FiveThirtyEight made available on Github. Construct then scores the win rate for each random assignment. 

I created, validated, and ran this job with 5,000 random assignments, tested against nearly 3,500 previous submissions in under an hour. FiveThirtyEight Construct Job

The results were mixed, but I expected that with a random assignment. My best lineup out of the 5,000 random lineups beat 64.9% of the previous submissions. However, the average win rate among all lineups was 38.5%. So while my top lineup is a force to be reckoned with, I still had some work to do.


Improving Upon the Assignments

Since I wanted to improve the results, I ran a few tests with some slight modifications of the random assignments. I reused the job I had already set up to point the random assignments to the castles of interest, then used three other strategies. 

First, I prioritized the higher-level castles, giving them the larger armies that were randomly assigned. This means that Construct still randomly assigned the amounts, and then I just pushed the largest army to castle 10, the second largest to castle 9, and so on. I also worked on two separate strategies where I focused on different combinations of castles that would equal 28 points in total, which we know would ensure victory. Using the same logic as above, I focused on castles 10-9-5-4 and created another iteration focusing on castles 10-7-6-3-2. 

Not all of my modifications improved on my initial results. In fact, focusing solely on the higher point castles was the least successful method, with an average win rate of 36.4%. That’s 2% lower than the random assignments. The 10-9-5-4 castle priority proved to be the best method, coming in with an average win rate of 50.2%.

FiveThirtyEight Table

In the end, the lineup that I submitted had beaten 70.3% of the previous submissions. and focused on winning castles 10-9-5-4. Here is the full lineup:

Final Results

Awaiting the Results

These riddles are often overwhelming to me. Given the added wrinkle of fractional armies, the number of possible lineups for this edition is unfathomable. It is somewhere around three sextillion possible lineups. That is a 3, followed by 21 zeros. That is too many zeros. 

The benefit of having an in-house analytics tool like Construct is that I could easily automate this process for testing, then apply my own analytical skills to improve the results. I didn’t have to think of even one of the potential three sextillion lineups. Instead, I was able to quickly test 20,000 random lineups and choose the best from among them. Working from the raw results, I made specific refinements to improve the outcome.

We will soon find out if I am the new ruler of the riddler nation. In the meantime, if you’re interested in learning more about Construct, click here and send us a question!

Notify of
Inline Feedbacks
View all comments