by compsciphd · 8y ago · 0 comments
1. Estimate Pi using a unit circle inscribed in a unit square with the ability to increase/decrease accuracy.
For some reason I had calculus on the brain, so went with a reimann sum type approach (i.e. accuracy would be how wide the rectangles were.
What they wanted was a monte carlo approach. i.e. throw darts, measure how many are inside and outside the circle but within the square.
2. Write a regex matcher that can match letters/numbers/./*
#2 is basically from Kernighan and Pike's practice of programming, except as Kernighan comments elsewhere Rob Pike required an hour or 2 to figure it out (not something I think is reasonable to accomplish in 30-45m of time in an interview)
though after that, I decided to learn more about regex's and wrote my own full regex parser (including grouping, back and forward expressions....), wasn't performant (and could die in the well known pathalogical cases), but it was fun to learn.
No comments yet.