Created
February 27, 2013 08:27
-
-
Save kapilreddy/5046274 to your computer and use it in GitHub Desktop.
A simple solution to Josephus problem with kill rate of 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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