Using Artificial Intelligence Techniques And SQL To Optimize A Lottery Application

Artificial Intelligence or “AI” can be defined as the “ability of a system to learn from previous experience in an attempt to predict future events”. While this might seem a forlorn hope in making lottery predictions, let’s see if this might be possible.

The big problem in analysing lottery results is the large number of possible combinations. In a standard “40 x 6” ball game there are 3,838,380 lines to choose from.

Generating A Starting Point For A Lotto AI System

It makes sense to reduce the possible number pool before we implement any AI possibilities. I’ll use the “Prime” probability system which assumes there will be 2 primes, 1 odd and 3 even numbers in each winning line.

We’ll try to use AI to group the prime results into some kind of pattern when they do occur.

vCard QR Code

vCard.red is a free platform for creating a mobile-friendly digital business cards. You can easily create a vCard and generate a QR code for it, allowing others to scan and save your contact details instantly.

The platform allows you to display contact information, social media links, services, and products all in one shareable link. Optional features include appointment scheduling, WhatsApp-based storefronts, media galleries, and custom design options.

For example, the last 6 weeks results of NZ Lotto were:


10,15,17,19,35,39
4,16,20,25,29,37
2,10,24,26,29,33
7,14,17,18,25,30
4,20,22,34,36,37
13,14,27,31,38,40

The numbers in results 2,3,4 and 6 meet the prime system criteria so we only want to look at those lines. If we can establish a pattern within the prime results then we can greatly reduce our combinations for when the prime system numbers come up.

We’ll use the Structured Query Language, or SQL, to query the prime system database of all possible lottery combinations; a total 575,586 lines of 6 numbers.

The structure of the database is as follows:


Number types: prime,prime,odd,even,even,even
Column name: n1,n2,n3,n4,n5,n6
For example:
3,5,9,10,14,28

Using A SQL Query To Recognize The Lottery Pattern

What I’ll do is create a SQL query that selects each line of winning prime system numbers. We can then combine the queries in an “and/or” statement to cover the different scenarios.

In this way, we can learn the commonalities between the different results, just like a real life AI application.

Most of the prime results above contained at least one number divisible by 4. We can cover that scenario with this query:


n4%4=0 or n5%4=0 or n6%4=0

Records returned: 525,690

The percent symbol is a special code in SQL which gives us the remainder from dividing the two numbers.

Each prime line appears to have at least two numbers within 4 of each other. We’ll cover that possibility like this:


(n6-n5<5)
or
(n5-n4<5)

Records returned: 305,316

We can now combine the queries with the following command:


(n4%4=0 or n5%4=0 or n6%4=0)
and
(
(n6-n5<5)
or
(n5-n4<5)
)

The combined query returned 276,210 combinations, a reduction of around 40%, which is fairly impressive.

I noticed the first even number was always equal to or less than 14 and when I factored that parameter in, the combinations returned were 165,726.

In future weeks I’ll look at other common factors, for example excluding numbers from recent results.

Summary

This article explored the possibility of using AI techniques and SQL to reduce possible combinations. By analysing results that meet certain parameters it should be possible to reduce line numbers and improve our lottery chances.


🕐 Top News in the Last Hour By Importance Score

# Title 📊 i-Score
1 Gen Z grads say their college degrees were a waste of time and money as AI infiltrates the workplace 🟢 85 / 100
2 Over 100 US university presidents sign letter decrying Trump administration 🔴 75 / 100
3 Canada's PM vows to boost military spending to protect against 'America's threats to our sovereignty' 🔴 72 / 100
4 Canada's top candidates talk up fossil fuels as climate slips down agenda 🔴 72 / 100
5 Columbia student suspended over interview cheating tool raises $5.3M to ‘cheat on everything’ 🔴 72 / 100
6 Map reveals the loneliest countries in the world… and America's shocking standing 🔴 67 / 100
7 Remove patio weeds ‘for good’ overnight with 40p natural item expert prefers over vinegar 🔵 45 / 100
8 Shocking moment Pat McAfee gets brutally choked out by WWE star on post-WrestleMania show 🔵 45 / 100
9 Pistons’ Cade Cunningham awakens to carve up Knicks, OG Anunoby for monster Game 2 🔵 35 / 100
10 George Clooney doesn’t care if Trump calls him a ‘fake movie actor’ 🔵 35 / 100

View More Top News ➡️