We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Random number generator
Random number generator
Sort by
recency
|
41 Discussions
|
Please Login in order to post a comment
Really interesting how controlled randomness works in this problem. It got me thinking about how similar concepts apply in other tools, like those used for creating text styles and design. In these tools, you enter your desired text, and it transforms it into different styles using Unicode mapping. One tool I came across online with a wide variety of text styles is fontesdeletras.com.br. Although the site is in Portuguese, but you can even put English text to generate styles.
first i thought its like a
return rand(0,99);
thing but it's not. seriously i spent like 1,5 hour to manage this :DI tried:
Seems that getting the fractions right is really tricky--a couple of my answers were off a tiny bit, and I'm not sure whether it's because the math I used leaves me with a wrong answer, or if the fractional answers are wrong.
I guess it is easy once you remember how one should approach the problem. It took me a while since my prob skills are rusty.
Solution:
A brief explanation: 1. Think of a coordinate system (x, y). Draw a rectangle of width
a
and heightb
. Set the bottom left of the rectangle as the origin. 2. Any combination of a and b that sum up to c can be expressed by a line: y= -x + c. The question becomes how to find the area under this curve that overlaps with the area of the rectangle. ... (That is what User: skypehopert and I are doing. 3. Find the area, divide it by the area of the rectangle. That is the probability we want. 4. After that, express the answer in the form HackerRank wants. This gave me some trouble. I still dont like the format of the output.I have a valid solution that cannot pass any of the tests. I have checked the output with other solutions that pass the hidden test cases. What am I doing wrong?