Skip to content

Commit

Permalink
Solved for 112.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Austin committed Sep 17, 2010
1 parent 63d8023 commit 505e496
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/dma/euler/p112.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns dma.euler.p112
(:use dma.euler.numeric))

(defn bouncy? [n]
(let [ds (digits n)
increasing? (fn [ds] (apply <= ds))
decreasing? (fn [ds] (apply >= ds))]
(and (not (increasing? ds))
(not (decreasing? ds)))))

(defn least-bouncy-proportion [target]
(loop [num-bouncy 0
n 100]
(if (= (/ num-bouncy (dec n)) target)
(dec n)
(recur (if (bouncy? n) (inc num-bouncy) num-bouncy) (inc n)))))

(defn solution {:answer nil} []
(least-bouncy-proportion 99/100))

0 comments on commit 505e496

Please sign in to comment.