Column
Data Science and AI

It Was AI Night Before Christmas…

Humanoid AI robot Santa Claus reading letters at home and preparing for Christmas

Claim your CPD points

Christmas is a time for data analysis with a festive theme . With the significant improvement in AI tools this year, a Christmas-themed coding challenge was in order.

Every year, Santa must visit millions of houses to deliver presents, and finding the most efficient route to minimise reindeer fatigue is obviously an important challenge. This is, of course, a pure version of the travelling salesman problem. I generated (almost) 5,000 points in a plane, and then asked three LLMs – ChatGPT’s GPT5, Claude’s Opus 4.1, and Google’s Gemini Pro 2.5 to solve. The exact prompt provided is below:

I have a dataset, happy_christmas_coordinates.txt, with 5000 coordinate points (first 10 rows included below). Please give me a piece of python code that:

- Reads in the dataset

- Writes an algorithm to solve the traveling salesman problem

- Applies the algorithm for this dataset (it should take no longer than 5min to run)

- Plots the path (but not the original points). The plot should be pretty, and Christmas themed

- Saves the plot, as well as the distance of the path, to the same directory.

# HAPPY CHRISTMAS coordinate points (holes excluded)

# Format: x, y

566.3315, 16.3386

611.0028, 71.8128

284.1099, 153.4495

173.9621, 121.7703

317.0611, 189.9698

176.2296, 165.9802

149.0849, 140.4316

16.1822, 187.6634

Code produced, including the code to generate the original point cloud is on this GitHub repository .

Overall, the exercise was a success

All three tools produced code that worked out of the box – by the standard of models even a couple of years ago this is impressive, although perhaps would be surprising given the famous nature of the coding challenge.

All three tools found the same algorithm – an initial nearest neighbour approach for an initial path, followed by a simple application of the 2-opt algorithm , which seeks to swap pairs of paths to see if the distance travelled decreases. This was a little disappointing – I’d secretly hoped one of the models would spice things up.

LLM

Distance Santa had to travel (km)

Gemini

12,322

Claude

14,129

GPT5

14,253

On distance travelled, Gemini was the clear winner. There is likely some luck to the results, however, Santa does not have time to run the algorithm many times to get a fair view of modern LLMs.

Figure: A message from Google’s Gemini

Figure: A message from Google’s Gemini

Getting into nitpicking:

  • ChatGPT gave the most compact code, but probably the worst algorithm – it was originally tied to a maximum iterations setup (exiting if there was no improvement after x steps), which was sometimes too quick to stop and sometimes over the five-minute limit. This was the only case where I materially edited the code – to add a time-based exit. ChatGPT also attempted to insert emojis into the chart title, which proved impossible for the default font of the charting package.
  • Gemini gave good comments and progress notes and correctly ran the algorithm. It did ignore the instruction to not plot the points, but the effect with tiny green dots is quite nice, so perhaps I’ll forgive it.
  • Claude managed to get the most into the festive spirit by including emojis in the code comments. It was the most verbose solution, twice the length of the others – more items wrapped in functions (here largely unnecessarily), plus a lot more detail in how the final plot was set up. It did have the prettiest plot output (aside from failed emojis), adding a nice colour palette to the path – see image at the top of the article.
  • None of the models produced a good aspect ratio for the plot – I manually made them wider so text was not distorted. So, there is one job remaining for the humans!

The winner

I’m going to give the win to Gemini today – it gave compact, well-laid-out code, saved Santa nearly 2,000 km of travel, and weirded me out slightly with a title that matches the image underneath. But it is also a celebration of a world where we have several high-quality coding assistants readily accessible.

You’ll be staggered to know that the point cloud was not entirely random – in fact, you may even see a not-so-secret message in the plots. As ever, it has been an absolute pleasure writing for Actuaries Digital again this year, and I look forward to being with you again next year. Hoping you all have a safe and re-energising holiday period.

Figure: A message from Open AI’s ChatGPT

Figure: A message from Open AI’s ChatGPT

Normal Deviance
About the authors
Hugh Miller
Hugh is a principal at Taylor Fry and the 2021 Actuary of the Year. He is also part of Institute of Actuaries of Australia’s Public Policy Council Committee, and is Data Analytics Editor of the Institute’s magazine Actuaries Digital and pens the column ‘Normal Deviance’.