Skip to content

Instantly share code, notes, and snippets.

@miner miner/lucky.clj
Created Feb 23, 2015

Embed
What would you like to do?
(ns miner.lucky
(:require [clojure.data.avl :as avl]))
;; http://en.wikipedia.org/wiki/Lucky_number
(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)))
(recur (inc i) (reduce (fn [sss m] (disj sss (nth avl m)))
avl
(range (dec n) (count avl) n)))
(sequence avl)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.