Commit graph

3 commits

Author SHA1 Message Date
William Carroll
c0268ed31a Refactor random-choice
Prefer initializing `result` to an empty array of size `m`, which makes the
algorithm a bit more elegant.
2020-11-17 23:54:54 +00:00
William Carroll
751b5327a9 Solve algorithms dealing with randomness
Tonight I learned that random sample where each element in the sampling corpus
has an equal likelihood of being chosen is a brand of algorithms known as
"reservoir sampling".

- Implement random.shuffle(..)
- Implement random.choice(..)

Surprisingly, candidates are expected to encounter problems like this during
interviews.
2020-11-17 22:28:24 +00:00
William Carroll
92ab94943e Start working on the "Hard" problems
Firstly, implement a function that adds two arguments together... without using
the `+` operator. I need to drill this problem. Thankfully I took a Coursera
course that taught me how to make a half-adder and a full-adder, but the
recommended solution for this is a bit more difficult.
2020-11-16 17:10:57 +00:00