Skip to content

Instantly share code, notes, and snippets.

@andykitchen
andykitchen / puzzle.txt
Last active August 29, 2015 13:57
Multi-Language Quine Generator Puzzle
This came up in discussion with a couple of people
at the Melbourne Funtional Users Group
Problem:
Create a program that takes as input a list of languages, then outputs
a multi-quine that cycles through those languages in order.
e.g.
user> (cemerick.piggieback/cljs-repl :repl-env (nashorn/repl-env))
Type `:cljs/quit` to stop the ClojureScript REPL
nil
cljs.user> (+ 1 1)
2
cljs.user> (js/java.lang.System.currentTimeMillis)
1404733130652
(ns cljs-spike.core)
(defn vector->react [v]
(let [[el attrs body] v
react-body (react body)]
(if (keyword? el)
(make-react-dom-component el attrs react-body)
(el attrs react-body))))
(defn make-react-dom-component [el attrs react-body]
import Data.Map (Map)
import qualified Data.Map as Map
import Data.List (nub, maximumBy)
import Data.Function (on)
import Control.Concurrent
type Loc = (Int, Int)
size :: Int
size = 8
w = 96
n = 20000
l = 32
def rand_ranges(a, b, l, size):
r = np.repeat(np.arange(l, dtype=np.intp)[np.newaxis], size, axis=0)
r += np.random.randint(a, b-l, size=size)[:,np.newaxis]
return r
si0 = np.random.randint(0, images.shape[0], size=n)
U,s,V = np.linalg.svd(X, full_matrices=False)
n = X.shape[0]
k = n # or however many terms you want to keep
X_zca = np.sqrt(n) * U[:,:k].dot(V[:k])
(define fixp? (lambda (f x) (equal? (f x) x)))
(define quine? (lambda (x) (fixp? eval x)))
(define apply1 (lambda (f) (lambda (x) (f x))))
(define fac*
(lambda (f)
(lambda (n)
(if (< n 2)