Random solutions are sometimes better

randoms solutions

Sometimes you don't need elaborate mathematics because the precision of the result required would not fit or merit going into complex calculations. To say that the method of resolution is directly tight to the precision of the result you need.

If you are asked to calculate the percentage of area occupied by these two surfaces,

Of course, you can use high-cost computation like iterative integrals which could let you know the surface of these areas precisely but if the precision of the result isn’t so important why not just using random tests by picking randomly dot and seeing in what area it belongs. With the law of probability, you will get the percentage of occupation of each portion. The precision will increase according to the number of tests you will do. That’s a law. A programmer, a Designer, or an Engineer adopts a solution which fits the outputs required. I am tempted to call that cost optimization.

I saw a competitive programmer, a very good one, diving deep into his code elaborating a very nice and complex solution that passed almost all test cases for giving the results asked but his program was slow. He tried during all the remaining time to improve his beautiful code without success. After the end of the challenge, he just reviewed again the statement of the program asked and saw that the outputs required were of 10⁶ precision. He just was … because if he had this in mind he would have got a faster code. Like me, he is bad at reading a statement.

Read your statement again and know the precision of the outputs. Maybe you don't need an elaborate solution.

​Papa makhtar Diop is before anything a geek or a nerd or both if you want. Geek and nerd are now overused but they used to name a knowledge driven person.