Commit graph

10 commits

Author SHA1 Message Date
William Carroll
5820f6f459 Solve rand7
Write a random number generator for [0,7) using only a random number generator
for [0,5). Ensure the results are uniformly distributed.
2020-11-14 17:26:00 +00:00
William Carroll
a0e9e2b310 Solve unsorted-substring a second time
This solution operates in O(n) time instead of O(n*log(n)) time, which
surprisingly isn't *that* big of a difference...

Consider a size of n of 10M...
  1) ~10s
  2) ~0.5s

So, yes, the O(n*log(n)) will take 100x longer to complete, but for an enormous
input size of 10M elements, it can still complete in under a minute. The
difference between that and the second, faster, algorithm, is just 9s.
2020-11-14 15:28:23 +00:00
William Carroll
48fde5f278 Solve unsorted-substring
Write a function that returns the indices demarcating a substring, which if
sorted, would make the entire array sorted.
2020-11-14 15:08:25 +00:00
William Carroll
47c5c6ac05 Partially implement a Heap
Defining the insert (or "siftup") function described in the "Programming Pearls"
book.
2020-11-14 14:08:58 +00:00
William Carroll
c841527f61 Write encoded XML parser and pretty-printer
Write a function that reads a string of compressed XML and outputs the
decompressed version.

Note to self: Now that I'm growing more comfortable writing parsers, I'd like to
become equally comfortable writing pretty-printers.
2020-11-14 14:00:00 +00:00
William Carroll
bfd2180e6b Solve tic-tac-toe checker
Write a function that verifies whether or not a tic-tac-toe board is valid.
2020-11-13 17:45:07 +00:00
William Carroll
1b3f1b99f5 Solve box-stacking problem
Write a function to compute the highest stack of boxes that can be created from
a list of boxes.
2020-11-13 16:57:47 +00:00
William Carroll
7672049e1c Solve N queens
After a five year hiatus, I decided to attempt to solve the famous N queens
problem again. This time, instead of modeling the chess board using a
`[[Bool]]`, I'm using `[Integer]` where the `Integer` indicates which column has
a queen. This is a bit lighter in RAM.
2020-11-13 16:56:02 +00:00
William Carroll
14f6169fcf Document subset of BNF for regex engine
Adding some documentation for my future self.
2020-11-13 16:55:39 +00:00
William Carroll
aa66d9b83d Add coding exercises for Facebook interviews
Add attempts at solving coding problems to Briefcase.
2020-11-12 14:37:29 +00:00