Skip to content

Instantly share code, notes, and snippets.

View johnwalker's full-sized avatar
💭
what is this status for

John Walker johnwalker

💭
what is this status for
View GitHub Profile
(require 'package)
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(package-initialize)
(require 'undo-tree)
(require 'gist)
(defn foobar []
(println "Foobar"))
(ns ieee2013.binpalindromes)
(defn log2up [x]
(int (Math/ceil (/ (Math/log x)
(Math/log 2)
2))))
(defn problem []
(let [[lower upper]
(mapv #(. Integer parseInt %)
@johnwalker
johnwalker / bottlenecks.clj
Created October 27, 2013 17:01
Mostly works
(ns ieee2013.carpalind)
(require 'clojure.set)
(defn read-in []
(let [n (- (read-string (read-line)) 1)]
(clojure.string/trim
(apply str (for [x (range n)]
(str (read-line) " "))))))
(ns ieee2013.icecream)
(require 'clojure.set)
(defn- dfs
[graph goal]
(fn search
[path visited]
(let [current (peek path)]
(if (= goal current)
@johnwalker
johnwalker / subst.clj
Created October 27, 2013 17:02
Incomplete
(ns ieee2013.subst)
(defn make-encoding [w c]
(if (= (count c) (count w))
(map-indexed (fn [n x] {(nth w n) (nth c n)})
w)))
(let [input
"2
case
@johnwalker
johnwalker / rpnhexcalc.cpp
Last active December 26, 2015 17:09
IEEExtreme 2013
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <stack>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
@johnwalker
johnwalker / goodstuff.json
Last active December 26, 2015 22:09
testing json reading in clojure
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": {
"total_blogs": 15,
"blogs": [
{
"name": "twosillycorgis",
(ns largest-product-in-a-grid)
(def grid '[[8 2 22 97 38 15 0 40 0 75 4 5 7 78 52 12 50 77 91 8]
[49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 4 56 62 0]
[81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 3 49 13 36 65]
[52 70 95 23 4 60 11 42 69 24 68 56 1 32 56 71 37 2 36 91]
[22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80]
[24 47 32 60 99 3 45 2 44 75 33 53 78 36 84 20 35 17 12 50]
[32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70]
[67 26 20 68 2 62 12 20 95 63 94 39 63 8 40 91 66 49 94 21]
(ns highly-divisible-triangle-numbers
(:require [clojure.core.reducers :as r]))
(def triangles (reduce
(fn [x y]
(conj x (+ (peek x) y)))
[0]
(range 1 20000)))
(defn factors [n]