A modern, data-driven lottery number generator using weighted algorithms based on historical NZ Lotto Powerball data.
This project consists of two main components:
- Modern React 18 + TypeScript application
- Weighted number generation algorithm
- Beautiful, responsive UI with Tailwind CSS
- Customizable generation preferences
- Real-time client-side processing
- Data scraping and cleaning utilities
- Excel to JSON conversion
- Historical data analysis
- Original Python-based lottery algorithm (lotto_V3.py)
cd Frontend
npm install
npm run devVisit: http://localhost:5173/LottoNz/
cd Backend
python convert_to_json.py⨠Smart Number Generation
- Frequency-weighted algorithm (1834 historical draws)
- Spread control: tight (β€20), wide (β₯15), or mixed
- Leaning bias: left (1-13), middle (15-25), or right (27-40)
- Consecutive number preferences
- Powerball: random 1-10
π¨ Modern UI
- NZ-themed green/blue color scheme
- Fully responsive design
- Smooth animations
- Collapsible preferences panel
- Latest draw display
π Data-Driven
- 1834 historical draws (2001-2025)
- Real-time frequency analysis
- Unique combination validation
LottoNz/
βββ Frontend/ # React application
β βββ src/
β β βββ App.tsx # Main component
β β βββ utils.ts # Generation algorithms
β β βββ dataService.ts # Data fetching
β β βββ types.ts # TypeScript types
β βββ public/
β β βββ results.json # Historical data (1834 draws)
β βββ package.json
β
βββ Backend/ # Python scripts
β βββ lotto_V3.py # Original Python algorithm
β βββ convert_to_json.py # Excel β JSON converter
β βββ datacleaner.py # Data cleaning utilities
β βββ lotto-data/
β βββ december.xlsx # Source data
β
βββ README.md # This file
The weighted algorithm follows these steps:
- Calculate Frequencies: Count occurrences of each number (1-40) in historical data
- Apply Leaning Bias: Multiply weights by 2x for preferred range
- Weighted Selection: Use cumulative probability for random selection
- Validate Constraints: Check spread and consecutive requirements
- Generate Powerball: Random number 1-10 (no weighting)
Max 1000 attempts to find valid combination, falls back to default if needed.
- Primary:
Backend/lotto-data/december.xlsx(Excel format) - Converted:
Frontend/public/results.json(JSON format) - Format:
{ date: string, numbers: number[], powerball: number }
Frontend:
- React 18, TypeScript, Vite
- Tailwind CSS, Lucide React
- Modern ES modules
Backend:
- Python 3.x
- pandas (Excel processing)
- Selenium (web scraping - optional)
cd Frontend npm run dev # Start dev server npm run build # Build for production npm run preview # Preview production build
cd Backend
python convert_to_json.pyThis reads lotto-data/december.xlsx and generates Frontend/public/results.json.
- Build the frontend:
cd Frontend
npm run build- Deploy
Frontend/dist/to your hosting service - Configure for GitHub Pages (base path:
/LottoNz/)
Private project - All rights reserved
Created for NZ Lotto Powerball analysis and smart number generation. π°
A customizable New Zealand Lotto Powerball number generator that uses historical data analysis and weighted probability to generate unique lottery number combinations.
- Historical Data Analysis: Analyzes past Lotto Powerball draws to calculate number frequencies
- Customizable Number Generation:
- Spread Control: Choose tight, wide, or mixed number spreads
- Range Bias: Favor low (1-20), high (21-40), or middle (15-25) numbers
- Consecutive Numbers: Include or exclude consecutive number pairs
- Duplicate Detection: Ensures generated combinations have never been drawn before
- Multiple Entries: Generate multiple unique number sets in one run
- Frequency Weighting: Uses historical frequency data to weight number selection
- Python 3.7+
- pandas
- openpyxl (for Excel file handling)
- Clone the repository:
git clone https://github.com/Jomar77/LottoNz.git
cd LottoNz- Install required packages:
pip install pandas openpyxl
- Ensure you have the historical data file in the correct location:
- File path:
lotto-data/december.xlsx - Sheet name:
Lotto Powerball
- File path:
python lotto_V3.py
The script will guide you through customization options:
- a) Tight spread: Numbers close together (e.g., 12, 15, 17, 19, 21, 23)
- b) Wide spread: Numbers spread far apart (e.g., 3, 12, 19, 28, 35, 40)
- c) Mixed spread: Balanced distribution
- l) Left leaning: Favors lower numbers (1-20)
- r) Right leaning: Favors higher numbers (21-40)
- m) Middle focused: Favors middle range (15-25)
- y) Yes: Ensures at least one pair of consecutive numbers (e.g., 14, 15)
- n) No: No preference for consecutive numbers
- Enter how many unique number sets you want to generate
π― CUSTOMIZE YOUR LOTTERY NUMBERS π―
==================================================
1. Number Spread Preference:
a) Tight spread (numbers close together)
b) Wide spread (numbers spread out)
c) Mixed spread (balanced)
Choose spread (a/b/c): b
2. Number Range Preference:
l) Left leaning (favor lower numbers 1-20)
r) Right leaning (favor higher numbers 21-40)
m) Middle focused (favor middle numbers 15-25)
Choose leaning (l/r/m): m
3. Consecutive Numbers:
y) Include at least one pair of consecutive numbers
n) No preference for consecutive numbers
Include consecutive numbers? (y/n): y
4. How many number sets would you like? 3
π Generating 3 customized number set(s)...
============================================================
π² ENTRY #1 - YOUR CUSTOMIZED LOTTO NUMBERS π²
============================================================
Main Numbers: 12, 15, 16, 22, 28, 35
Powerball: 8
Number Spread: 23 (Range: 12 - 35)
Consecutive Numbers: β Yes
============================================================
LottoNz/
βββ lotto_V3.py # Main number generator (latest version)
βββ lotto_V2.py # Previous version
βββ lotto_V1.py # Initial version
βββ datacleaner.py # Data cleaning utilities
βββ heatmap_Anx.py # Visualization tools
βββ findline.py # Helper utilities
βββ lotto-data/ # Historical lottery data
β βββ december.xlsx # Required data file
β βββ data.csv
β βββ lotto_results.csv
βββ dataScrape/ # Web scraping scripts
β βββ ds_selenium.py
β βββ ds.py
βββ *.ipynb # Jupyter notebooks for analysis
- Data Loading: Reads historical Lotto Powerball results from Excel file
- Frequency Analysis: Calculates how often each number has been drawn
- Weighted Selection: Uses frequency data to create probability weights
- Bias Application: Applies user-selected biases (spread, range, consecutive)
- Validation: Checks generated combinations against historical data
- Uniqueness Guarantee: Ensures the combination has never appeared before
The Excel file should have the following columns:
- Date
- Draw Number
- Num1, Num2, Num3, Num4, Num5, Num6 (Main numbers)
- Bonus Number
- Powerball Number
To modify the data source, edit the file path in lotto_V3.py:
file_path = r"lotto-data\december.xlsx" sheet_name = 'Lotto Powerball'
- lotto.ipynb: Jupyter notebook for data exploration
- powerball.ipynb: Powerball-specific analysis
- gaus-alx.ipynb: Statistical analysis using Gaussian methods
- heatmap_Anx.py: Generate heatmaps of number frequency
This tool is for entertainment purposes only. Lottery draws are random events, and past results do not influence future outcomes. Please gamble responsibly.
This project is open source and available for personal use.
Feel free to fork this repository and submit pull requests for improvements or new features!
Good luck! π