Skip to content

Instantly share code, notes, and snippets.

@bouk
bouk / dijkstra.hs
Created January 6, 2013 14:17
Dijkstra's algorithm implemented in Haskell. Example input: 5 7 0 1 2 0 2 7 0 3 6 1 4 6 1 2 3 2 4 5 3 4 1
import Data.List (insert)
fst3 (x,_,_) = x
snd3 (_,x,_) = x
trd3 (_,_,x) = x
toTuple2Int :: String -> (Int, Int)
toTuple2Int s = (read $ takeWhile (/=' ') s :: Int, read $ dropWhile (==' ') $ dropWhile (/=' ') s :: Int)
toTupleTuple2Int :: String -> (Int, (Int, Int))
@bouk
bouk / immutable.js
Last active March 15, 2016 00:00 — forked from cpojer/immutable.js
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* Immutable data encourages pure functions (data-in, data-out) and lends itself
* to much simpler application development and enabling techniques from
* functional programming such as lazy evaluation.
*
* While designed to bring these powerful functional concepts to JavaScript, it
* presents an Object-Oriented API familiar to JavaScript engineers and closely
* mirroring that of Array, Map, and Set. It is easy and efficient to convert to
FROM ubuntu
RUN apt-get install -y wget
RUN wget -O - http://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz | tar xzf - -C /usr/local/
RUN ln -s /usr/local/go/bin/go /usr/local/bin/go
RUN ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt
RUN ln -s /usr/local/go/bin/godoc /usr/local/bin/godoc
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int H, k;
vector<int> houses;
bool possible(int w)
from bs4 import BeautifulSoup
import urllib2
def main():
page = urllib2.urlopen("http://www.weersvoorspelling.nl/weer-nederland/culemborg/per-uur/8387")
doc = BeautifulSoup(page.read())
for row in doc.find(class_='forecastTable').find_all('tr'):
#include <cstdio>
using namespace std;
int N;
int number;
bool first;
int main()
{
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;
struct state
{
int depth;
int parent;
@bouk
bouk / domineren.py
Created February 27, 2013 19:54
NIO 2012-2013 ronde 2 opdracht 0
import re
import copy
import sys
board = None
moves_done = 0
columns = 0
rows = 0
moves = []
class Songtext
def refrain(*args, &block)
if block
@refrain = block
else
if args.first[0].downcase == 'x'
puts
args.first[1..-1].to_i.times do
@refrain.call()
puts
@bouk
bouk / bf.py
Created January 5, 2013 11:57
Brainfuck to C
mapping = {
'>': '++p;',
'<': '--p;',
'+': '++*p;',
'-': '--*p;',
'.': 'putchar(*p);',
',': '*p=getchar();',
'[': 'while (*p) {',
']': '}'
}