Skip to content

Commit

Permalink
Solved 99.
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenaustin committed Oct 8, 2011
1 parent 43250a6 commit abc3b06
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ to the `euler` function:
user> (euler 42) 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 ## Problems to migrate from Ruby project


I originally started with Project Euler as a way to learn Ruby. I I originally started with Project Euler as a way to learn Ruby. I
Expand All @@ -46,7 +53,6 @@ it in Ruby. Here is my migration TODO list. Problems I have solved
in Ruby, but not yet in Clojure: in Ruby, but not yet in Clojure:


* 96 * 96
* 99
* 111 * 111
* 114 * 114
* 115 * 115
Expand Down
14 changes: 14 additions & 0 deletions src/dma/euler/p099.clj
Original file line number Original file line Diff line number Diff line change
@@ -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.