about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorFilesLines
2020-11-19 Implement a suffix treeWilliam Carroll1-0/+64
While it took me awhile to implement, this exercise was definitely worth doing. I think there should be a more elegant way to construct the tree using maybe a stack, but I couldn't find it. All of this was part of a larger effort to search a string for a variety of patterns. The solution is to compile the string into a suffix tree and then search the suffix tree for each of the patterns. I'm glad I didn't gloss over this exercise.
2020-11-17 Refactor random-choiceWilliam Carroll1-2/+2
Prefer initializing `result` to an empty array of size `m`, which makes the algorithm a bit more elegant.
2020-11-17 Solve algorithms dealing with randomnessWilliam Carroll2-0/+46
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-16 Solve "nearby words" functionWilliam Carroll1-0/+33
Given an input like "gello" suggest an correction like "hello". This is a proof-of-concept problem for writing a simplistic auto-correction algorithm for a mobile device.
2020-11-16 Implement the Rabin Karp string matching algorithmWilliam Carroll1-0/+27
This algorithm is pretty interesting because it runs in linear time with respect to the length of the `corpus` string. It does this by using a sliding window hash. This hash -- because it's a sliding window -- runs in constant time for each iteration; we're only adding and subtracting one character each time and not re-hashing the whole "window". When our hashes match, only then do we compare the "window" to the `pattern`. String comparisons are linear because they compare each character to each character one at a time. But because we only compare strings when are hashes match (a check which runs in constant time), this spares us the performance hit.
2020-11-16 Prefer mutative variant of delete for HashTableWilliam Carroll1-3/+16
Instead of calling `filter(..)`.
2020-11-16 Add another solution to the "move zeroes to end" problemWilliam Carroll1-15/+51
Support the optimally performance solution of which I'm aware.
2020-11-16 Solve "find pairs for sum"William Carroll1-0/+19
I have encountered this problem 3x in the wild thus far: 1. www.InterviewCake.com 2. Cracking the Coding Interview 3. www.Pramp.com
2020-11-16 Start working on the "Hard" problemsWilliam Carroll1-0/+22
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 Implement a simple hash function and hash tableWilliam Carroll1-0/+59
I was always curious how hashing functions were implemented, so I read about the "polynomial rolling hash function", and I decided implementing it would be a good exercise. After writing that, writing a hash table was simple.
2020-11-15 Find the intersection (if any) between two linked listsWilliam Carroll1-0/+34
As with most linked list questions, this one involves an arcane trick from the neck-bearded playbook.
2020-11-15 Solve "Move Zeroes to End"William Carroll1-0/+26
Write a function to modify an array of integers in-place such that all of the zeroes in the array are at the end, and the order of the other integers is not changed.
2020-11-14 Include re-roll strategy for rand7William Carroll1-8/+11
After seeing the solution that my book advocated, I implemented it using recursion.
2020-11-14 Solve rand7William Carroll1-0/+22
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 Solve unsorted-substring a second timeWilliam Carroll1-5/+51
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 Solve unsorted-substringWilliam Carroll1-0/+21
Write a function that returns the indices demarcating a substring, which if sorted, would make the entire array sorted.
2020-11-14 Partially implement a HeapWilliam Carroll1-0/+30
Defining the insert (or "siftup") function described in the "Programming Pearls" book.
2020-11-14 Write encoded XML parser and pretty-printerWilliam Carroll2-0/+135
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-13 Solve tic-tac-toe checkerWilliam Carroll1-0/+99
Write a function that verifies whether or not a tic-tac-toe board is valid.
2020-11-13 Solve box-stacking problemWilliam Carroll1-0/+50
Write a function to compute the highest stack of boxes that can be created from a list of boxes.
2020-11-13 Solve N queensWilliam Carroll1-0/+46
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 Document subset of BNF for regex engineWilliam Carroll1-0/+10
Adding some documentation for my future self.
2020-11-12 Add coding exercises for Facebook interviewsWilliam Carroll66-0/+2994
Add attempts at solving coding problems to Briefcase.
2020-11-12 Sort Emacs depsWilliam Carroll1-6/+6
Group Emacs dependencies like ivy together.
2020-11-12 Mark additional movies as watchedWilliam Carroll1-0/+0
Making progress...
2020-11-12 Style habit screen to accommodate footerWilliam Carroll1-3/+3
Add spacing to the bottom to make space for the footer.
2020-10-11 Tweak stylesWilliam Carroll1-2/+2
Add spacing to help the app breathe.
2020-10-11 Support multiple HabitTypesWilliam Carroll2-73/+196
I could have and should have broken this change into smaller pieces, but when I came up for air, I had changed too much, and most of the changes are intermingled. Oh well... this is an exciting change! Include habits for: - Morning - Evening - Payday (the 25th) - First of the Month - First of the Year Since the Morning and Evening routines might be a bit noisy, I'm excluding them from the output using a flag, `include{Morning,Evening}`, which I support in the UI to toggle their visibility. I made *much* more progress on this app that I expected to today, and I *think* -- short of supporting a database and a server -- I'm close to being *completely* finished. Wahoo!
2020-10-11 Support Msg to clear all completed tasksWilliam Carroll2-5/+45
Add a simple button to clear all completed tasks.
2020-10-11 Render time remaining in UIWilliam Carroll1-2/+38
Show the number of minutes remaining before completing all of the tasks.
2020-10-11 Move tailwind function into Utils moduleWilliam Carroll2-17/+63
Instead of accepting `List (String, Int)`, accept `List Strategy` where `Strategy` defines whether or not the string of selectors should be applied to the element. I'm also renaming it `class` so I can just use `Utils.class`; `tailwind` has little to do with the function itself.
2020-10-11 Expand Habit typeWilliam Carroll2-48/+127
Include: - habitType: Daily, Weekly, Yearly... what's the trigger? - minutesDuration: Estimation of how long it'll take to complete
2020-10-11 Watch a few moviesWilliam Carroll1-0/+0
Here's what I watched: - Ran - Children of Heaven - Lawrence of Arabia Only 78/250 movies to go!
2020-10-11 Tweak stylesWilliam Carroll1-3/+6
- Change header to blue - Change habit to gray when completed - Prefer app font for footer instead of monospaced font
2020-10-11 Create UI module for common componentsWilliam Carroll2-17/+27
Create UI.elm to house components like `button`, which is a simple HTML button with `focus:outline-none` applied as a `class`, which is an accessibility feature that I don't need for this touch-screen application. I like this pattern more than my more opinionated patterns for UI modules in Elm where I'd define all of the arguments as a record type (i.e. kwargs).
2020-10-11 Prefer handwritten fontWilliam Carroll2-2/+8
Use the Google Fonts API to fetch a handwritten font, which gives the app a modicum of personality. There are more "best practices" ways to do this, such as: - Download the font once, and include it in the bundle - Extend the Tailwind configure to recognize the font - Ditch the inline <style> block But I don't need the performance benefits that the first bullet provides. And the second two bullets are more relevant for a larger application with more than one font. So I think in this case, the easiest solution is best. Also: - Use `container` and `mx-auto` to constrain content for wide screens
2020-10-10 Support viewing different daysWilliam Carroll2-12/+124
Allow users to browse the habits of the other days of the week.
2020-10-10 Ensure weekday is updatedWilliam Carroll2-2/+8
This ensures us that our view is consistent within ~1 minute of reality.
2020-10-10 Tweak stylesWilliam Carroll1-3/+3
- Increase font size for header - Prefer a bulleted list - Reduce horizontal padding
2020-10-10 Add a footerWilliam Carroll1-0/+4
With personal information and information about the project's stack.
2020-10-10 Remove Nap from Saturday; prefer Yin YogaWilliam Carroll1-1/+1
Since Warm Yin Yoga is at 15:00, it's difficult to attend that *and* nap.
2020-10-10 Begin working on Habit Screens projectWilliam Carroll12-0/+414
Created a small MVP for digitizing my weekly habits. Much more to come. Lots of things happening: - Copied the boilerplate to get started - Added a brief project-level README - Outlined my ambitions in design.md See README and design.md for more context on this project.
2020-10-10 Add elm-format-on-save-mode to elm-mode-hookWilliam Carroll1-1/+3
Instead of calling this manually.
2020-10-04 Remove evil dependency from window-manager.elWilliam Carroll1-2/+0
When `keybindings` requires `window-manager`, the `evil-want-integration` warning emerges. If I remove the `evil` dependency from `window-manager`, it resolves the issue.
2020-10-04 Enable spell-checking during magit commitWilliam Carroll1-1/+4
This is another (overdue) change about which I'm quite excited. Add spell-checking to my Git commit buffers. :)
2020-10-04 Extend "l" -> "L" KBD remapping for magit-{log,revision}-mode-mapWilliam Carroll1-1/+3
Thankfully `general` made this change super easy and maintainable to support.
2020-10-04 Support display-arrangement macroWilliam Carroll1-36/+66
I was tired of using `arandr` to manually configure my monitor positions, so I encoded the settings in Elisp in the `display.el` module. TL;DR: - Drop support for `position` kwarg in `display-register` macro - Support `coords` kwarg in `display-register`. - `defconst` the `xrandr` arguments and command in `display-register`. - Define `display-arrangement` macro that consumes the `xrandr` arguments that `display-register` defines to create an interactive function, `display-arrange-<NAME>`, which -- when invoked -- runs one xrandr command to configure a display "arrangement".
2020-10-04 Disable company-mode during git commitsWilliam Carroll1-0/+1
Why didn't I configure this earlier? For years, my workflow involved checking a buffer's major mode and then extending that major-mode's hook. Confusingly (to me), the `major-mode` for `COMMIT_EDITMSG` is `text-mode`, and I didn't want to disable `company-mode` for *all* `text-mode` buffers, which is what the following would have done: ```elisp (add-hook 'text-mode-hook (lambda () (company-mode -1)) ``` Thankfully I recently invested some time into learning more about Emacs's offline help system, `Info-mode`, so -- putting that knowledge to work -- I ran `info-apropos` and searched "magit commit". After ~5 minutes of reading I knew the recommended way of configuring this was to modify `git-commit-setup-hook`. How validating!
2020-10-04 Move KBDs from window-manager.el to keybindings.elWilliam Carroll2-55/+37
Assuming (hoping) that this doesn't break anything.
2020-10-04 Debug Emacs initializationWilliam Carroll1-1/+1
Since "Briefcase" doesn't exist, `window-manager--switch` fails and so does `exwm-init-hook`. It'd be nice to catch these errors earlier...