Skip to content

Instantly share code, notes, and snippets.

@gigamonkey
gigamonkey / change.py
Created April 19, 2017 05:03
Dynamic programming implementation of change counting problem
#!/usr/bin/env python3
def ways(amount, coins):
# Set up our data. Note that this is all we need other than three
# local variables we use in the loop below.
starts = [ i + 1 + sum(coins[:i]) for i in range(len(coins)) ]
data = [ int(i in starts) for i in range(sum(coins) + len(coins) + 1) ]
# Iterate up to the desired amount.
@gigamonkey
gigamonkey / wordbreak.hs
Created April 18, 2017 04:24
Got nerd sniped by sylphon
import Data.List
dict = [ "this", "th", "is", "famous", "Word", "break", "b", "r", "e", "a", "k", "br", "bre", "brea", "ak", "problem" ]
string = "Wordbreakproblem"
solve d s = map (intercalate " " . reverse . fst) $ finish (concatMap (starts d)) [([], s)]
starts _ x@(ws, []) = [x]
starts d (ws, s) = [(w:ws, drop (length w) s) | w <- d, w `isPrefixOf` s]
@gigamonkey
gigamonkey / marc-questions.md
Last active July 21, 2016 00:15
Marc's questions
  • Tell me about your best manager and your worst manager and what made them so.

  • Tell me about people you’ve loved working with.

  • Tell me about the kind of projects you really love, and projects that drag you down.

  • Tell me what I can be doing to support your reaching the next step in your career.

@gigamonkey
gigamonkey / pi.hs
Last active January 22, 2016 05:03
Compute π with random numbers.
import Data.Function
import System.Random
inQuarterCircle :: (Double, Double) -> Bool
inQuarterCircle = (< 1) . uncurry ((+) `on` (**2))
pairs :: [a] -> [(a,a)]
pairs (a:b:rest) = (a,b) : pairs rest
sample :: Int -> (a -> Bool) -> [a] -> Double
@gigamonkey
gigamonkey / start-coding.md
Last active January 18, 2016 08:49
Answer to email asking how to start learning to code

There are a bunch of ways to start. The main thing is to get some simple programming environment where you can try things and learn from your mistakes. Depending on how you like to learn you might want to start with a good book. I haven't read it myself but I've heard good things about How to Design Programs which you can read online here http://www.htdp.org/. There are also sites like https://www.codecademy.com/ and https://studio.code.org/ that have online instruction for starting programming. The latter may be aimed somewhat at kids but that doesn't really matter.

Another approach is to start by learning HTML, the language used to make web pages, which is not exactly a programming language but which will let you play with making a computer do something as well as giving you a chance to learn some of the mechanics of dealing with files and debugging your mistakes, etc. From there you can learn to make web pages more dynamic with Javascript, which is a programming language. In this case your programming e

@gigamonkey
gigamonkey / hackweek_carol.md
Last active December 14, 2015 18:34
A Hackweek Carol

The chain he drew was clasped about his middle. It was long, and wound about him like a tail; and it was made (for Scrooge observed it closely) of FIXMEs, untested code, copy-pasted-code, unhandled error conditions, and JIRAs closed with Won’t Fix.

“You are fettered,” said Scrooge, trembling. “Tell me why?”

“I wear the chain I forged in life,” replied the Ghost. “I made it link by link, and yard by yard; I girded it on of my own free will, and of my own free will I wore it. Is its pattern strange to you?”

@gigamonkey
gigamonkey / cosell-reviews.md
Last active July 25, 2019 12:59
Bernie Cosell on BBN design reviews from Coders at Work

From Bernie Cosell interview in Coders at Work

Another thing that Frank did, on other projects, was design reviews. He had the most scary design reviews and I actually carried that idea forward. People would quake in their boots at his design reviews. This was sort of like taking your orals for your dissertation. He would have a hand-picked collection of people in the audience and you would have to present your design. The people he picked were always good. The thing that made his design reviews so scary is he knew when you were bluffing.

I’m sure you’ve done design reviews where you didn’t work on some part of it real well and so you kind of slide past that part. You think you got this right but you didn’t really do the analysis so you don’t know quite what’s going on. He had an instinct, and it was abetted by having a good crew in there, of catching you when you were bluffing, catching you when you hadn’t thought it through.

The parts that you did absolutely fine hardly got a mention. We all said, “O

@gigamonkey
gigamonkey / criteria.txt
Last active January 5, 2020 06:21
Hiring criteria: looking for the ability to …
Write a program that does what it’s supposed to do
Write idiomatic code
Debug a program that you wrote
Debug a program someone else wrote
Debug the interaction between a system you wrote and one you didn’t
File a good bug report
Modify a program you didn’t write
Test a program you wrote
Test a program you didn’t write
Learn a new programming language
Links
https://medium.com/@jocelyngoldfein/how-to-hire-engineers-step-0-what-to-look-for-85ae44bf0a1c
http://bryce.vc/post/18018734466/talk-to-us-about-your-problems
https://www.quora.com/Management/What-are-common-mistakes-that-new-or-inexperienced-managers-make/answer/Elaine-Wherry?srid=Q&share=1
http://www.nytimes.com/2011/03/13/business/13hire.html?ref=homepage&src=me&pagewanted=all
http://www.ewherry.com/2012/06/the-recruiter-honeypot/
http://www.ewherry.com/2012/08/the-best-recruiters-followup/
http://randsinrepose.com/archives/the-old-guard/
http://www.humansofnewyork.com/post/108853481056/after-our-first-meeting-ms-lopez-invited-me-to
@gigamonkey
gigamonkey / gist:03efdb275e487da37c59
Last active August 29, 2015 14:22
How to collaborate on technical problems

“[A] good problem description had to satisfy everyone. If two people saw a problem from a different point of view, both people’s points of view were merged into the problem description, making the problem more complicated, and making solutions sometimes harder to achieve. But this was essential to addressing porting problems, for example. One couldn’t just solve how a file system operation would work on one operating system unless the solution was going to work on other operating systems, too. On the other hand, the “proposal” field was very different. If two people disagreed on a proposal, they each wrote their own proposal so that proposals could be internally consistent and coherent. This meant that a single problem often had several proposed solutions with different costs and benefits, and the committee had to decide which was the stronger proposal.”

From http://www.nhplace.com/kent/Papers/cl-untold-story.html