Given a list of integers between $0$ and $99$, create a function that will fit all the integers in the list.

77 Views Asked by At

Okay, so my friend LOVES to play the lottery. He makes bets often with bookies on the last $2$ digits, getting $90:1$ on his money, a losing bet.

He looks up 'systems' on social media on how to calculate what numbers will come up next based on previous draws. I wonder if it is possible to generate a 'system' to fit the existing data points, i.e. the previous $5$ draws. So that I could show him that just because you can fit a pattern on previous draws of randomly generated numbers doesn't mean that you can predict the next number.

1

There are 1 best solutions below

5
On

Well, it depends.

A random number generated by a computer uses what is known as a Random Number Generator (RNG) that creates new 'random' numbers. To create a number using an RNG, you need a single number called a seed. This could be the system time, a manually entered number, a previously generated number, or something unpredictable and random by itself.

If the seed is a previously generated number, you need to use a good, unpredictable algorithm. Weak RNGs can be predicted over time, due to the flaws in them. To do so, you must: 1. Know what algorithm has been used.
2. Hope that it is weak, or has a programming flaw (indexes of arrays are often confused).
3. Know how to find such flaws (meaning you need to be good at maths, as well as programming).
4. Pray that you are right (since it is almost impossible to really exploit an RNG without an expert's help).

Note that once you have cracked the method, you should be able to get the number right every time, otherwise you are wrong. It is all-in or nothing, so your friend is just wasting his money (or not, since he is losing only by a small margin, he might just get lucky, and stop playing after winning once).

If the RNG is of some in-built function by a reputed brand (say, a DOS command echo %random%), just accept that it can't be cracked.

And there is no other way to predicting a randomly generated number, it is mathematically impossible.