Permalink
Browse files

Solved 99.

  • Loading branch information...
1 parent 43250a6 commit abc3b069915b69ad082f5afbe2ae06ed6313e193 @darrenaustin committed Oct 8, 2011
Showing with 21 additions and 1 deletion.
  1. +7 −1 README.md
  2. +14 −0 src/dma/euler/p099.clj
View
@@ -37,6 +37,13 @@ to the `euler` function:
user> (euler 42)
+## TODO list
+* Migrate to 1.3
+* Clean up numeric.clj
+* Clean up :use clauses to only specify exactly what is being used in
+ each file
+* Solve the rest of the problems :)
+
## Problems to migrate from Ruby project
I originally started with Project Euler as a way to learn Ruby. I
@@ -46,7 +53,6 @@ it in Ruby. Here is my migration TODO list. Problems I have solved
in Ruby, but not yet in Clojure:
* 96
-* 99
* 111
* 114
* 115
View
@@ -0,0 +1,14 @@
+(ns dma.euler.p099)
+
+(defn solution {:answer 709} []
+ (let [pairs (partition 2 (map read-string (re-seq #"\d+" (slurp "data/base_exp.txt"))))]
+ ;; Rather than test a full b^e expansion, we should just be able to compare
+ ;; e * log(b) to determine which result will be largest. Also need to keep
+ ;; track of the line number.
+ (let [[line value]
+ (reduce (fn [[max-line max-value] [line value]]
+ (if (> value max-value)
+ [line value]
+ [max-line max-value]))
+ (map-indexed (fn [line [base exp]] [line (* exp (Math/log base))]) pairs))]
+ (inc line))))(

0 comments on commit abc3b06

Please sign in to comment.