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/local/bin/python3 | |
import sys | |
from networkx import nx | |
from pprint import pprint | |
from functools import reduce | |
N = 4 | |
words=[w.strip() |
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
(ns cf | |
(:require [clojure.math.numeric-tower :as nt])) | |
(defn- step [x-2 x-1 [a & as]] | |
(when a | |
(let [x (+ (* a x-1) x-2)] | |
(cons x (lazy-seq (step x-1 x as)))))) | |
(defn convergents [as] | |
(let [c (fn c [[h & hs] [k & ks]] |
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
(ns cf | |
(:require [clojure.math.numeric-tower :as nt])) | |
(defn- step [x-2 x-1 [a & as]] | |
(when a | |
(let [x (+ (* a x-1) x-2)] | |
(cons x (lazy-seq (step x-1 x as)))))) | |
(defn convergents [as] | |
(let [c (fn c [[h & hs] [k & ks]] |
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
(ns cf | |
(:require [clojure.math.numeric-tower :as nt])) | |
(defn- step [x-2 x-1 [a & as]] | |
(when a | |
(let [x (+ (* a x-1) x-2)] | |
(cons x (lazy-seq (step x-1 x as)))))) | |
(defn convergents [as] | |
(let [c (fn c [[h & hs] [k & ks]] |
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
(ns ef | |
(:require [clojure.math.numeric-tower :as nt])) | |
(defn ef [r] | |
(loop [r r ef []] | |
(let [x (numerator r) | |
y (denominator r)] | |
(if (= x 1) (conj ef r) | |
(recur (/ (mod (- y) x) (* y (nt/ceil (/ y x)))) | |
(conj ef (/ (nt/ceil (/ y x))))))))) |
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.util.ArrayList; | |
import java.util.List; | |
import processing.core.PVector; | |
List<Bug> bugs = new ArrayList<Bug>(); | |
int w = 500; | |
abstract class Actor { | |
protected PVector pos; | |
protected float rot; |
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
summer = lambda acc, val: acc+val | |
maxxer = lambda acc, val: max(acc, val) | |
unioner = lambda acc, val: acc.union({val}) | |
def log(val): | |
print 'value:', val | |
return val | |
print reduce(summer, xrange(5), 0) | |
print reduce(maxxer, xrange(5), 0) |
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
void setup () { | |
fill(255,0,60); | |
stroke(0); | |
rect(50,50,10,10); | |
} |