Skip to content

Instantly share code, notes, and snippets.

@yosu
yosu / books.json
Last active December 12, 2016 14:30
Elastic stack Advent Calendar 2016 説明用の「本」データ
{"index":{"_id":1}}
{"title":"The Millstone","author":"Herta Mann","publisher":"Bloomsbury Publishing Plc","genre":"Suspense/Thriller","rating":5,"release_date":"2016-11-16"}
{"index":{"_id":2}}
{"title":"The Line of Beauty","author":"Leopold Johnston","publisher":"Bloodaxe Books","genre":"Fairy tale","rating":2,"release_date":"2016-11-30"}
{"index":{"_id":3}}
{"title":"The Wings of the Dove","author":"River Denesik","publisher":"Medknow Publications","genre":"Speech","rating":2,"release_date":"2016-12-10"}
{"index":{"_id":4}}
{"title":"A Monstrous Regiment of Women","author":"Simone Gleichner","publisher":"Applewood Books","genre":"Narrative nonfiction","rating":5,"release_date":"2016-10-22"}
{"index":{"_id":5}}
{"title":"If Not Now, When?","author":"Corrine Gulgowski DVM","publisher":"Manchester University Press","genre":"Textbook","rating":3,"release_date":"2016-11-20"}
@yosu
yosu / knapsack.hs
Created February 23, 2016 10:38
5.10 Dynamic Programming: The Knapsack Problem - Introduction to Algorithms by Udi Manber
import Data.Array
knapsack :: [Int] -> Int -> Bool
knapsack xs cap = table!(cap, n)
where
n = length xs
ks = listArray (1, n) xs
table = array ((0,0), (cap, n)) $
[((k, 0), k == 0) | k <- [0..cap]] ++
[((k, i), ans k i) | k <- [0..cap], i <- [1..n]]
@yosu
yosu / skyline.go
Last active February 10, 2016 06:11
5.6 A Divide-and-Conquer Algorithm: The Skyline Problem - Introduction to Algorithms by Udi Manber
package main
import (
"fmt"
)
type Building struct {
left int
height int
right int
@yosu
yosu / celebrity.go
Last active February 3, 2016 05:01
5.5 Celebrity Problem - Introduction to Algorithms by Udi Manber
package main
import (
"bufio"
"flag"
"fmt"
"os"
"strconv"
"strings"
)