I'm trying to create a function that takes two integer inputs (one < 30, one < 15), and which creates a pseudo-random value between 1 and 50.
My first attempt is something like this:
- sum the two numbers
- flip the digits around (with 2 becoming 20)
- if new number > 50, do -50
(I've fudged the numbers a little for the example, but that's my general idea.)
The "randomness" I introduce is of course the flipping of digits (subquestion: how to write down this easy operation for pattern analysts like humans, but difficult to turn into math?), but my entire method has the unfortunate effect that the summing of the integers ensures that some sums are reached more often than others.
I know I can just make the sum and divide by the max to get an equal spread, but it's not really random (as in: it's very predictable). Hence the flipping.
Do you know if there's another way to combine two integers, and return a pseudo-random integer? It doesn't have to be unique (which would be impossible), and it should be easy to do mentally.
Cheers!