Sometimes the reason pi shows up in randomly generated values is obvious—if there are circles or angles involved, pi is your guy. But sometimes the circle is cleverly hidden, and sometimes the reason pi pops up is a mathematical mystery!
Pi is an infinitely long decimal number that never repeats. How do we know? Well, humans have calculated it to 314 trillion decimal places and didn't reach the end. At that point, I'm inclined to accept it. I mean, NASA uses only the first 15 decimal places for navigating spacecraft, and that's more than enough for earthly applications.
Which Algorithm Is This? If you step back, this maps almost perfectly to the Top K Frequent Elements problem.We usually solve it for integers in a list. Here, the "elements" are audience profiles age and body-type combinations. First, define what an audience profile looks like: case class Profile(age: Int, height: Int, weight: Int) What we want is a function like this:
Liam Delap has an interesting party trick that you wouldn't really expect a footballer to pull out of the bag. The Chelsea forward has gone on video a few times showing off his bizarre mathematical ability to quickly calculate the cube roots of large numbers.