Neopian Lottery calculator: behind the scenes

I got the idea to make this from the Neopian Times posted by htamale. The premise is that you can actually increase your odds the lottery by doing a bit of math.

Why is choice of lottery numbers important?

For your 20 tickets a day, suppose you naively pick a bunch of repeating tickets like so:
Ticket 1: 1 2 3 4 5 6
Ticket 2: 1 2 3 4 5 14
Ticket 3: 1 2 3 4 5 25
etc...

Your first ticket matches 6 numbers in 1 lottery draw, 5 numbers in 144 lotteries (6c5 * 24c1), and 4 numbers in 4140 lotteries (6c4 * 24c2). This is fine, but let's see what happens next. Your second ticket matches the same number of times, except 24 (24c1) of the 5-matches are the identical, and 1380 (5c4 * 24c2) of the 4-matches are identical.

That means you missed 1404 (33%) chances to win!

If you pick a set of 20 tickets with minimum overlap, that'll give you the maximum possible chance to win. My script basically shuffles the numbers around to do this since solving the real minimum overlap problem is pretty hard.

What are the chances of winning?

Calculating odds is also a hack since it depends on everyone else who's playing, but you make a pretty good estimate.

Each ticket has:
1:593,775 (0.00017%) chance of matching all 6
1:4123 (0.024%) chance of matching 5
1:143 (0.7%) chance of matching 4

Since the lottery is usually won with 5 or 4 (a fifth of the time) matches, let's estimate:
(.00017+.024+.7*.2)*20 = 3.3% chance of winning

If you pick good ticket numbers that means in total you have a 1:30 (3.3%) chance of winning. That's once a month!

Is it worth playing?

If you want to get the trophy, that'll cost about 60k NP (100NP * 20 tickets * 30 days) even if you win little to no NP.

Even if you don't care about the trophy, economically over the long term you should earn NP since this lottery gives back all NP paid + 5k (unlike real lotteries which are scams!)

Best part is, the more people play the better. You need to win 1 million NP to get the gold trophy and currently not enough people play to reach 1M. Economically, your odds decrease but the amount increases, so you still earn the same if more people play.