Skip to content

Instantly share code, notes, and snippets.

@kapilreddy
Created February 27, 2013 08:27
Show Gist options
  • Save kapilreddy/5046274 to your computer and use it in GitHub Desktop.
Save kapilreddy/5046274 to your computer and use it in GitHub Desktop.
A simple solution to Josephus problem with kill rate of 2.
(defn find-surviver*
[in]
(loop [[f s & coll] in]
(if (and f s)
(recur (concat coll [f]))
f)))
(defn find-surviver
[population]
(inc (find-surviver* (range population))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment