I bought and analyzed the year-end jumbo lottery with Python that can be executed in Colaboratory

I see lottery 6 and numbers analysis codes, but I didn't see them in the jumbo lottery.

How much will the year-end jumbo lottery of 300 yen per sheet, the number of summer jumbo lottery purchases, and the number of winnings according to the number of purchases be? Have you ever wondered? How many cards should I buy to win the 1st or 2nd prize? I used to post a video about how much YouTuber bought a lottery ticket and how much it won, but it's not easy to buy it on the scale of millions or tens of millions. I haven't tried to win a really high price because there is a limit to the number of purchases. So, I created a code that works with Google Colaboratory, made it possible to enter the number of roses I want to purchase as input, and created a code that immediately shows what and how many pieces will hit and what the balance will be. In addition, it became heavy when I checked whether there was a lottery with the same number as the group purchased separately, so I uncommented this check. Even if you buy 10 million copies, you won't win the first prize or the front and back prizes. At best, it feels like one 2nd prize. I used the jumbo at the end of 2018 for the number of winnings and prize money. It was a good opportunity to study Python as well. Extract and match the last few digits, write out the numbers separated by commas ...

Image of output: 截屏2019-12-0312.51.02.png

Here is the source code that can be used with Python / Colaboratory (it's dirty because I created it because I thought it should work)!

from collections import Counter
import random
import numpy as np
import scipy as sp
import pandas as pd

#Tousen Bangou Ketasuu Chousei
def convert_int(number,decimals):
    return str(number).zfill(decimals)

# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

# Kounyuu maisuu to kounyuu kingaku keisan


val = input('Kounyu Maisu?: ')
n = int(val)
#n=10000

kumi_list = [random.randrange(1,200) for i in range(n)]
bangou_list = [random.randrange(100000,199999) for i in range(n)]

#Choufuku Check - Jikan ga kakarimasu!!
#choufuku_check = [str(kumi_list)+'-'+str(bangou_list) for i in range(n)]
#choufuku_maisuu = (Counter(choufuku_check).keys())

kounyu_kingaku=300*n

#print(kumi_list)
#print(bangou_list)
#print(kumi_list[0])
#print(bangou_list[0])

# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

#Tousen Bangou Chusen Kekka

kumi_1 = random.randint(1,200)
bangou_1 = random.randint(100000,199999)
if  bangou_1 == 199999:
 zengo_1=199998
 zengo_2=100000
elif bangou_1 == 100000:
 zengo_1=199999
 zengo_2=100001
else:
 zengo_1=bangou_1-1
 zengo_2=bangou_1+1

kumi_2_1=random.randint(1,200)
kumi_2_2=random.randint(1,200)
kumi_2_3=random.randint(1,200)
bangou_2_1=random.randint(100000,199999)
bangou_2_2=random.randint(100000,199999)
bangou_2_3=random.randint(100000,199999)
kumi_3_1=random.randint(1,9)
kumi_3_2=random.randint(1,9)
kumi_3_3=random.randint(1,9)
kumi_3_4=random.randint(1,9)
kumi_3_5=random.randint(1,9)
bangou_3_1=random.randint(100000,199999)
bangou_3_2=random.randint(100000,199999)
bangou_3_3=random.randint(100000,199999)
bangou_3_4=random.randint(100000,199999)
bangou_3_5=random.randint(100000,199999)
bangou_4_1=random.randint(1,9999)
bangou_4_2=random.randint(1,9999)
bangou_5=random.randint(1,999)
bangou_6=random.randint(1,99)
bangou_7=random.randint(1,9)
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

#print (kumi_list)
#print (bangou_list)
# Tousen Kekka Keisan

tousen_kingaku = 0

count=0
tousen_1tou = 0
tousen_zengoshou = 0
tousen_1toukumichigai = 0
tousen_2tou = 0
tousen_3tou = 0
tousen_4tou = 0
tousen_5tou = 0
tousen_6tou = 0
tousen_7tou = 0

for count in range(n):  
  if kumi_list[count] == kumi_1 and bangou_list[count] == bangou_1:   
    tousen_kingaku+=700000000
    tousen_1tou+=1
  if kumi_list[count] == kumi_1 and bangou_list[count] == zengo_1:
    tousen_kingaku+=150000000
    tousen_zengoshou+=1
  if kumi_list[count] == kumi_1 and bangou_list[count] == zengo_2:
    tousen_kingaku+=150000000
    tousen_zengoshou+=1
  if kumi_list[count] != kumi_1 and bangou_list[count] == bangou_1:
    tousen_kingaku+=100000
    tousen_1toukumichigai+=1
  if kumi_list[count] == kumi_2_1 and bangou_list[count] == bangou_2_1:
    tousen_kingaku+=10000000
    tousen_2tou+=1
  if kumi_list[count] == kumi_2_2 and bangou_list[count] == bangou_2_2:
    tousen_kingaku+=10000000
    tousen_2tou+=1
  if kumi_list[count] == kumi_2_3 and bangou_list[count] == bangou_2_3:
    tousen_kingaku+=10000000
    tousen_2tou+=1
  if kumi_list[count] % 10 == kumi_3_1 and bangou_list[count] == bangou_3_1:
    tousen_kingaku+=1000000
    tousen_3tou+=1
  if kumi_list[count] % 10 == kumi_3_2 and bangou_list[count] == bangou_3_2:
    tousen_kingaku+=1000000
    tousen_3tou+=1
  if kumi_list[count] % 10 == kumi_3_3 and bangou_list[count] == bangou_3_3:
    tousen_kingaku+=1000000
    tousen_3tou+=1
  if kumi_list[count] % 10 == kumi_3_4 and bangou_list[count] == bangou_3_4:
    tousen_kingaku+=1000000
    tousen_3tou+=1
  if kumi_list[count] % 10 == kumi_3_5 and bangou_list[count] == bangou_3_5:
    tousen_kingaku+=1000000
    tousen_3tou+=1
  if bangou_list[count] % 10000 == bangou_4_1:
    tousen_kingaku+=100000
    tousen_4tou+=1
  if bangou_list[count] % 10000 == bangou_4_2:
    tousen_kingaku+=100000
    tousen_4tou+=1
  if bangou_list[count] % 1000 == bangou_5:
    tousen_kingaku+=10000
    tousen_5tou+=1
  if bangou_list[count] % 100 == bangou_6:
    tousen_kingaku+=3000
    tousen_6tou+=1
  if bangou_list[count] % 10 == bangou_7:
    tousen_kingaku+=300
    tousen_7tou+=1

sashihiki = tousen_kingaku - kounyu_kingaku

print('Kounyu Maisuu: ' + str(f'{n:,}') + 'mai')
#print('Choufuku Maisuu: ' + str(len(choufuku_maisuu)-1) + 'mai')
print('Total Purchase: JPY' + str(f'{kounyu_kingaku:,}'))
print ('Tousen Kingaku: JPY' + str(f'{tousen_kingaku:,}'))
print ('Sashihiki: JPY' + str(f'{sashihiki:,}'))

# Tousen Bangou Insatsu
print('Tousen Kekka:')
print('1tou: ' + str(f'{tousen_1tou:,}') + 'mai')
print('1touzengoshou: ' + str(f'{tousen_zengoshou:,}') + 'mai')
print('1toukumichigai: ' + str(f'{tousen_1toukumichigai:,}') + 'mai')
print('2tou: ' + str(f'{tousen_2tou:,}') + 'mai')
print('3tou: ' + str(f'{tousen_3tou:,}') + 'mai')
print('4tou: ' + str(f'{tousen_4tou:,}') + 'mai')
print('5tou: ' + str(f'{tousen_5tou:,}') + 'mai')
print('6tou: ' + str(f'{tousen_6tou:,}') + 'mai')
print('7tou: ' + str(f'{tousen_7tou:,}') + 'mai')
print('Tousen Bangou:')
print('1: ' + str(convert_int(kumi_1,3))+'-'+str(bangou_1))
print('1_zengo1: ' + str(convert_int(kumi_1,3))+'-'+str(zengo_1))
print('1_zengo2: ' + str(convert_int(kumi_1,3))+'-'+str(zengo_2))
print('1_kumichigai: ' + str(bangou_1))
print('2: ' + str(convert_int(kumi_2_1,3))+'-'+str(bangou_2_1))
print('2: ' + str(convert_int(kumi_2_2,3))+'-'+str(bangou_2_2))
print('2: ' + str(convert_int(kumi_2_3,3))+'-'+str(bangou_2_3))
print('3: xx' + str(convert_int(kumi_3_1,1))+'-'+str(bangou_3_1))
print('3: xx' + str(convert_int(kumi_3_2,1))+'-'+str(bangou_3_2))
print('3: xx' + str(convert_int(kumi_3_3,1))+'-'+str(bangou_3_3))
print('3: xx' + str(convert_int(kumi_3_4,1))+'-'+str(bangou_3_4))
print('3: xx' + str(convert_int(kumi_3_5,1))+'-'+str(bangou_3_5))
print('4: ' + convert_int(bangou_4_1,4))
print('4: ' + convert_int(bangou_4_2,4))
print('5: ' + convert_int(bangou_5,3))
print('6: ' + convert_int(bangou_6,2))
print('7: ' + convert_int(bangou_7,1))

# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------

Recommended Posts

I bought and analyzed the year-end jumbo lottery with Python that can be executed in Colaboratory
I made a familiar function that can be used in statistics with Python
In Python3.8 and later, the inverse mod can be calculated with the built-in function pow.
The story that sendmail that can be executed in the terminal did not work with cron
I investigated the pretreatment that can be done with PyCaret
I made a shuffle that can be reset (reverted) with Python
Understand the probabilities and statistics that can be used for progress management with a python program
I set the environment variable with Docker and displayed it in Python
I wrote a tri-tree that can be used for high-speed dictionary implementation in D language and Python.
I want to create a priority queue that can be updated in Python (2.7)
I registered PyQCheck, a library that can perform QuickCheck with Python, in PyPI.
I tried to predict the horses that will be in the top 3 with LightGBM
Note that I understand the least squares algorithm. And I wrote it in Python.
Article that can be a human resource who understands and masters the mechanism of API (with Python code)
Python knowledge notes that can be used with AtCoder
Geographic information visualization of R and Python that can be expressed in Power BI
Set up an FTP server that can be created and destroyed immediately (in Python)
Morphological analysis and tfidf (with test code) that can be done in about 1 minute
A memo that I touched the Datastore with python
Limits that can be analyzed at once with MeCab
[Django] Field names, user registration, and login methods that can be used in the User model
How to display hover text and text that can be executed by clicking with Minecraft plugin
I also tried to imitate the function monad and State monad with a generator in Python
Dealing with the error that HTTP fetch error occurs in gpg and the key cannot be obtained
[Python] A program to find the number of apples and oranges that can be harvested
Why can I use the module by importing with python?
Goroutine (parallel control) that can be used in the field
I tried programming the chi-square test in Python and Java.
Goroutine that can be used in the field (errgroup.Group edition)
Scripts that can be used when using bottle in Python
[Python] Draw elevation data on a sphere with Plotly and draw a globe that can be rotated round and round
I made it because I want JSON data that can be used freely in demos and prototypes
I tried to expand the database so that it can be used with PES analysis software
A story that didn't work when I tried to log in with the Python requests module
[Python] A program that finds the maximum number of toys that can be purchased with your money
[For beginners] Baseball statistics and PyData that can be remembered in 33 minutes and 4 seconds ~ With Dai-Kang Yang
I compared the speed of Hash with Topaz, Ruby and Python
[Python] I made my own library that can be imported dynamically
I made a package that can compare morphological analyzers with Python
Movement that changes direction in the coordinate system I tried Python 3
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
Make a Spinbox that can be displayed in Binary with Tkinter
A timer (ticker) that can be used in the field (can be used anywhere)
[Python3] Save the mean and covariance matrix in json with pandas
Python standard input summary that can be used in competition pro
Make a Spinbox that can be displayed in HEX with Tkinter
Python standard module that can be used on the command line
I'm tired of Python, so I analyzed the data with nehan (corona related, is that word now?)
[Python] Code that can be written with brain death at the beginning when scraping as a beginner
I liked the tweet with python. ..
I played with PyQt5 and Python3
I wrote the queue in Python
I wrote the stack in Python
Fill the string with zeros in python and count some characters from the string
I replaced the numerical calculation of Python with Rust and compared the speed
I created a template for a Python project that can be used universally
How to get the date and time difference in seconds with python
Mathematical optimization that can be used for free work with Python + PuLP
Draw a graph that can be moved around with HoloViews and Bokeh
The file name was bad in Python and I was addicted to import
I tried using "Streamlit" which can do the Web only with Python