Skip to content

Instantly share code, notes, and snippets.

@kylethebaker
kylethebaker / fibonacci.erl
Last active July 23, 2017 01:57
Erlang Fast Fibonacci
-module(fibonacci).
-export([fast_fib/1]).
-export([slow_fib/1]).
-spec slow_fib(integer()) -> integer().
-spec fast_fib(integer()) -> integer().
% Finds the Nth fibonacci number using standard recursion
% Gets unbearably slow to find around when N = 45
import sys
def is_triangle(tri):
return all([tri[i%3] + tri[(i+1)%3] > tri[(i+2)%3] for i in range(3)])
in_str = [line.strip() for line in sys.stdin.readlines()]
in_list = [[int(side) for side in line.split()] for line in in_str]
print("part 1: ", len(list(filter(is_triangle, in_list))))
#!/usr/bin/env python3
import socketserver
import logging
from random import randint
HOST, PORT = "", 999
bigrams = {
"th" : 1.52, "he" : 1.28, "in" : 0.94,
"er" : 0.94, "an" : 0.82, "re" : 0.68,
"nd" : 0.63, "at" : 0.59, "on" : 0.57,
"nt" : 0.56, "ha" : 0.56, "es" : 0.56,
"st" : 0.55, "en" : 0.55, "ed" : 0.53,
"to" : 0.52, "it" : 0.50, "ou" : 0.50,
"ea" : 0.47, "hi" : 0.46, "is" : 0.46,
"or" : 0.43, "ti" : 0.34, "as" : 0.33,
"te" : 0.27, "et" : 0.19, "ng" : 0.18,