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:
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