Skip to content

Instantly share code, notes, and snippets.


Steve Miner miner

View GitHub Profile
View roman-faster.clj
;; I posted an earlier version on my blog:
;; This version is faster and more readable.
(defn range-down
"Returns a seq of integers from HIGH (exclusive) down to LOW (inclusive).
LOW defaults to 0. STEP is a positve decrement, defaults to 1. Like
`(reverse (range low high step))' but a bit faster."
([high] (range (dec high) -1 -1))
View lucky.clj
(ns miner.lucky
(:require [ :as avl]))
(defn lucky-avl
([max] (lucky-avl 1 (apply avl/sorted-set (range 1 max 2))))
([i avl]
(let [n (nth avl i nil)]
(if (and n (<= n (count avl)))

Keybase proof

I hereby claim:

  • I am miner on github.
  • I am miner ( on keybase.
  • I have a public key whose fingerprint is DB15 4E49 B5BD BE5A 10B4 4437 6A9B 8B0A 4D6A 8900

To claim this, I am signing this object:

miner / fourbit.clj
Created Jun 18, 2012
Miner's four-bit adder for Rosetta Code
View fourbit.clj
(ns miner.fourbit)
;; a bit is represented as a boolean (true/false)
;; a word is a big-endian vector of bits [true false true true] = 11
;; maybe little endian is more convenient???
(defn bvec
miner / gist:3240618
Created Aug 2, 2012 — forked from swannodette/gist:3217582
View gist:3240618
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
(defn init [vars hints]
miner / roman.clj
Created Aug 6, 2012
Roman Numerals
View roman.clj
(ns miner.roman
(:require [clojure.test :refer :all]))
;; inspired by
(def roman-map {1000 "M" 900 "CM" 500 "D" 400 "CD"
100 "C" 90 "XC" 50 "L" 40 "XL"
10 "X" 9 "IX" 5 "V" 4 "IV" 1 "I"})
View submap.clj
;; inspired by
;; reduce-kv is faster than destructuring with maps
;; use (get m k) instead of (k m) to be safe with non-keyword keys
(defn sub=
"Like = for most things, but maps compare recursively by only the keys in a, so it returns true
if a is a 'submap' of b."
[a b]
(if (and (map? a) (map? b))
View ycombinator.clj
;;; 01/14/14 16:18 by miner -- Steve Miner revised this code to be more idiomatic Clojure.
; Short sidebar: Clojure has a special form for the efficient compilation of tail recursion.
; Something like this would work as a factorial function:
(defn fact2 [n]
(loop [n n acc 1]
(if (zero? n) acc (recur (dec n) (* n acc)))))
; We're not going to discuss `recur` any further as we're imagining a language that doesn't
View dijkstra_primes.clj
(ns miner.dijkstra-primes)
;; ----------------------------------------------------------------------
;; Converted to Clojure by SEM. Note that there are lots of shadowing and recursive calls in
;; the Clojure code to avoid the mutation in the original code. The Clojure loops are a bit
;; ugly. Not sure if this is the best way to do things. However, the performance is pretty
;; good.
miner / bowling.clj
Last active May 19, 2016
Bowling Kata in Clojure
View bowling.clj
(ns miner.bowling)
;; game is a string, encoding balls rolled
;; X for strike
;; / for spare
;; - for a miss or gutter ball
;; 1-9 for that many pins
You can’t perform that action at this time.