문제 이해 10분
풀이 35분
import random
numbs_of_balls = 6
def generate_numbers(n):
six_balls = []
count_ball = 0
while count_ball < n:
current_ball = random.randint(1, 45)
if current_ball not in six_balls:
six_balls.append(current_ball)
count_ball += 1
return six_balls
# print(generate_numbers(numbs_of_balls))
def draw_winning_numbers():
winning_numbs = generate_numbers(7)
result = sorted(winning_numbs[:6])
result.append(winning_numbs[6])
return result
# print(draw_winning_numbers())
def count_matching_numbers(list_1, list_2):
count = 0
for i in range(len(list_1)):
if list_1[i] in list_2:
count += 1
return count
# print(count_matching_numbers([2, 7, 11, 14, 25, 40], [ 14]))
def check(attempt_numbs, winning_numbs):
count = count_matching_numbers(attempt_numbs, winning_numbs[:-1])
if count == 5 and winning_numbs[-1] in attempt_numbs:
return 50000000 # 5천만
elif count == 6:
return 1000000000 # "10억 원"
elif count == 5:
return 1000000 # "100만 원"
elif count == 4:
return 50000 # "5만 원"
elif count == 3:
return 5000 # "5천 원"
else:
return 0
# numbers_test = [2, 4, 11, 14, 25, 40]
# winning_numbers_test = [4, 12, 14, 28, 40, 41, 6]
# print(check(numbers_test, winning_numbers_test))