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
{- | |
Income quintiles in 2011. This represents the poorest fifth to the richest fifth | |
of income earners in america in 2001. | |
-} | |
income2011 = [15282.0, 37556.0, 61032.0, 93232.0, 197932.0] | |
{- | |
Find the average income of americans, by averaging the quintiles. |
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
import Data.Ratio | |
import qualified Data.Set as S | |
data Op = Add | Sub | Mul | Div | |
deriving Eq | |
data Exp a = Bin Op (Exp a) (Exp a) | |
| Num a | |
deriving Eq | |
instance Show Op where |
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
import java.lang.reflect.Constructor; | |
import java.lang.reflect.InvocationTargetException; | |
import java.sql.ResultSet; | |
import java.sql.SQLException; | |
import java.util.Optional; | |
import lombok.extern.slf4j.Slf4j; | |
import org.skife.jdbi.v2.ResultSetMapperFactory; | |
import org.skife.jdbi.v2.StatementContext; | |
import org.skife.jdbi.v2.tweak.ResultSetMapper; |
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
module test; | |
reg clk; | |
wire out; | |
initial begin | |
$display("newjam wave decoder"); | |
clk = 0; | |
//$monitor("%s", out); | |
end |
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
{-# LANGUAGE ExistentialQuantification #-} | |
-- DFA borrowed from Romain Ruetschi on github: https://gist.github.com/romac/9193493 | |
module DFA ( | |
DFA(..), | |
runDFA, | |
scanDFA, | |
isAccepting, | |
) where |
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
#!/usr/bin/env ruby | |
require 'net/ssh' | |
def main | |
if ARGV.size < 3 then | |
puts 'usage: <hostname> <username> <password>' | |
else | |
hostname = ARGV[0] | |
username = ARGV[1] |
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
hello |
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/3sum-closest/ | |
(declare-const a Int) | |
(declare-const b Int) | |
(declare-const c Int) | |
(assert (or (= a -1) (= a 2) (= a 1) (= a -4))) | |
(assert (or (= b -1) (= b 2) (= b 1) (= b -4))) | |
(assert (or (= c -1) (= c 2) (= c 1) (= c -4))) |
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
from heapq import heappush, heappop | |
schedule = [(1, 3), (2, 5), (4, 5)] | |
def required_rooms(schedule): | |
h = [] | |
for start, end in schedule: | |
if len(h) > 0 and h[0] <= start: | |
heappop(h) | |
heappush(h, end) |
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
#!/usr/bin/env python3 | |
from sys import stdin | |
from sys import argv | |
from collections import defaultdict | |
# Adapted from Intro to Algorithms by CLRS. | |
# A string matching automata similar to grep. | |
def computeTransitionFunction(pattern): | |
m = len(pattern) |
OlderNewer