This gist is currently under re-development after my most recent round of interview prep and will be re-posted with major edits soon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This was the first challenging programming assignment I ever tried to complete, | |
given as an early homework question when I took CS220 (Introduction to Programming with Python) | |
in Fall 2011 at the College of Charleston (we had just learned about conditionals and iteration). | |
I was 21 years old, and was learning computer programming for the very first time. | |
The prompt was: "write a program that takes as input a symbol and a number, then prints a center-justified | |
pyramid of the given symbols and the height of the given number." | |
I stayed overnight in the computer lab, chugging energy drinks and banging my head against the desk |
Virtual environments ("venvs") make setting up Python projects easy, especially for projects multiple people work on. First, we need to create the venv:
joshua.goller @ joshua-goller ~/Code/skip-example
└─ $ ▶ python3 -m venv ./venv
joshua.goller @ joshua-goller ~/Code/skip-example
└─ $ ▶ ls
venv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define atom? | |
(lambda (x) | |
(and (not (pair? x)) (not (null? x))))) | |
(define generic-eq? | |
(lambda (item1 item2) | |
(cond ((and (number? item1) (number? item2)) (= item1 item2)) | |
((and (atom? item1) (atom? item2)) (eq? item1 item2)) | |
((and (list? item1) (list? item2)) (list-eq? item1 item2)) |
Here's a quick intro to D&D to help you get ready for your first campaign.
- D&D is a storytelling and roleplaying game; there is no specific victory condition or loss condition, except those designated by the story.
- D&D has a lot of rules, many of which are common RPG tropes (such as XP, turn based combat, spellcasting, etc) but there is no "right way" to play D&D. Having fun takes precedence over following the rules - the only "wrong way" to play is if any players are having a bad time. As such, some DMs will be more orthodox with the rules while others will be more lenient (but consistent), depending on the preferences of the players.
- Because of the sheer volume of the rules and mechanics, D&D can be overwhelming at first but most people catch on quickly. You don't need to read all of the rules before playing (though skimming some can be helpful) - the DM is expected to help new players get familiar with the rules.
- Rules are organized i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
3-5. Write a program that will keep track of grades for several students at | |
once. The program could keep two vectors in sync: The first should hold the | |
student's names, and the second the final grades that can be computed as input | |
is read. For now, you should assume a fixed number of homework grades. We'll see | |
in §4.1.3/56 how to handle a variable number of grades intermixed with student | |
names. | |
------------------------- | |
Again, I think we can just use a map - can we use a mapping of strings to | |
vectors? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a file called "Makefile" and copy / paste the contents of this gist into it. | |
# Then from the same directory, run `make all`. Requires docker-ce and GNU make to be installed. | |
anaconda all: anaconda-rm anaconda-container anaconda-shell | |
# Stop and remove the running Anaconda container | |
anaconda-rm: | |
-docker stop anaconda | |
-docker rm anaconda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
https://leetcode.com/problems/search-a-2d-matrix/description/ | |
--- | |
Understand | |
Program takes a value and a list of lists, should efficiently find whether | |
the value is in any sublist. Returns bool, not index. | |
This is a D&C problem - the lists are sorted, and later lists bound earlier lists. We do not | |
need to examine every item, so we can likely binsearch. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.hackerrank.com/challenges/ctci-bfs-shortest-reach/copy-from/72471548 | |
from collections import deque | |
class Graph(): | |
def __init__(self, node_count): | |
self.nodes = {} | |
for i in range(node_count): | |
self.nodes[i] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class t_node(): | |
def __init__(self): | |
self.children = {} | |
self.is_complete = False | |
self.valid_children = 0 | |
def add_child(self, char): | |
self.children[char] = t_node() | |
return self.children[char] | |
NewerOlder