-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43250a6
commit abc3b06
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
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
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
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))))( |