Пример #1
0
    attempts_html = ""

    for attempt in tries:
        attempts_html += generate_attempt_html(attempt, winning_numbers)

    out_file.write(HEAD_HTML + MAIN_HTML.format(numbers=winning_numbers_html,
                                                attempts=attempts_html,
                                                total_prize=total_prize,
                                                total_cost=total_cost))
    out_file.close()


WINNING_NUMBERS = lottery.draw_winning_numbers()
NUM_TRIES = 100

TRIES = []
TOTAL_PRIZE = 0
TOTAL_COST = 0

for i in range(NUM_TRIES):
    ATTEMPT = sorted(lottery.generate_numbers(6, 1, 45))
    prize = lottery.check(WINNING_NUMBERS, ATTEMPT)
    TRIES.append((ATTEMPT, prize))

    TOTAL_PRIZE += prize
    TOTAL_COST += 1000

main(WINNING_NUMBERS, sorted(TRIES, key=lambda x: -x[1]), TOTAL_PRIZE,
     TOTAL_COST)
Пример #2
0
    for attempt in tries:
        attempts_html += generate_attempt_html(attempt, winning_numbers)

    # Output the file
    out_file.write(head_html + main_html.format(numbers=winning_numbers_html,
                                                attempts=attempts_html,
                                                total_prize=total_prize,
                                                total_cost=total_cost))
    out_file.close()


# define constants
WINNING_NUMBERS = lottery.draw_winning_numbers()
NUM_TRIES = 100

# define variables
tries = []
total_prize = 0
total_cost = 0

for i in range(NUM_TRIES):
    attempt = lottery.generate_numbers()
    prize = lottery.check(attempt, WINNING_NUMBERS)
    tries.append((attempt, prize))

    total_prize += prize
    total_cost += 1000

main(WINNING_NUMBERS, sorted(tries, key=lambda x: -x[1]), total_prize,
     total_cost)