Calculate Pi Using Random Numbers (Coding Interview Questions)

preview_player
Показать описание
How To Calculate Pi Using Random Numbers

This is an interesting job interview question from my Coding Interview series.
Рекомендации по теме
Комментарии
Автор

Your videos always make me feel a little smarter after watching. Ape see Ape do.

TheKorkahn
Автор

I thought this was undoable at first... but wow you made it look rly easy

weiti
Автор

Dude where wre you??? Please post new videos. Your videos are really good

tihoratiplak
Автор

dude you are underrated...
also, please make a video on binary search... i really love your style of explaining things...
love from india ❤️

rapidfire
Автор

I love the logical sequence you walked me through. I could follow the formulas rather easily thanks to you. Great job. Thank you, and I hope to see more videos from you soon.

SmartHobbies
Автор

Really learn a lot from your videos! Would you be doing other sorting algo like heap sort or depth first search? Also, you can also teach dynamic programming, flood fill, hash tables and so much more :)

tanyejie
Автор

You should continue making more videos!

iiju
Автор

Seems like you have okay Youtube SEO are you interested in more in depth SEO maybe?

weiti
Автор

Ok, I've paused it at 0:10 purely to embarrass myself by having a crack at it.

I'd make a Vector2 class with `x` and `y` initialised variables and rework `__len__` to `return sqrt(x*x+y*y)` I'd then import random (is that cheating?) because I want `randrange`. Actually no, that is cheating, your rules were clear, just use the function. Ok, I make a random number, I times it by 2 and minus 1. So from -1 to 1.

So, I make a Mine obj - and I instance it with a random Vector2. I then make an `inside_circle` bool set by the length being greater than 1.

So, when I'm done I count the objects inside the circle and those outside.

Ok, I'm pretty sure I need a factor here but PI is in there somewhere. I'm going to guess you divide by 4.

That's a guess. I sounds right though. I got dropped to the thicko class at school because the first time I hear the world "trigonometry" was in an exam on it and I got dropped to the thicko class where I belonged.

davidmurphy