Simulating the 2025 Copa Libertadores Draw

Mar 10, 2025

The 2025 Copa Libertadores draw was held on March 17, 2025.

But before that, being a huge soccer fan (and because my team was participating), I set out to simulate the draw using Python with the help of Artificial Intelligence.

My code editor for this exercise was Cursor AI, which allowed me to write code faster and more efficiently, powered by Anthropic's Sonnet 3.7 model.

Considering that the draw has some basic rules, I decided to write them down and establish them from the beginning to optimize the simulation and be able to run it thousands or millions of times.

The first approach wasn't very optimal, as it took a long time to run. So, I decided to optimize it. To get 1,000 repetitions, the code took about 10 minutes... Way too long!

After optimizing the code for a couple more hours, I managed to get it to run 100,000 repetitions in under 5 minutes. That was already a lot, but I wanted to reach one million.

I dedicated more hours to it, and the result was as follows: I was able to run the simulation 1 million times in just over 2 minutes. Incredible!

I shared it on my Twitter, and I was surprised to see that many users found it interesting and useful.

It was even published in various media outlets, and I was invited to talk about the project.

Simulación de sorteo Copa Libertadores: (Primer intento) con cosas por ajustar y corriendo solo 100mil simulaciones. Seguiré probando y depurando el código para tener más ajustes, así como también para poder ejecutar más simulaciones. Esto solo quiere decir que luego de

Image
Erasmo Hernández
Erasmo Hernández
@ErasmoHernandez

Podemos jugar a hacer predicciones del sorteo, siguiendo las reglas. Hay tiempo de hoy al lunes para hacer una app de esto. 🤔

20
Reply

The important thing here is that I learned that code is a means to solve problems, and that with time and practice, it can be optimized and improved. The simulation result only correctly predicted one of the opponents, the most repeated one for Deportivo Táchira: Central Córdoba.

Thanks to my friends Leo Carrasquero and Kiko Perozo for featuring me in their media outlets.

Here are the links:

Erasmo Hernández