Created
October 4, 2013 17:19
-
-
Save laurilehmijoki/6829426 to your computer and use it in GitHub Desktop.
Find the maximum product of five consecutive integers.
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
(def numbers-in-string (str "37900490610897696126265185408732594047834333441947" | |
"01850393807417064181700348379116686008018966949867" | |
"75587222482716536850061657037580780205386629145841" | |
"06964490601037178417735301109842904952970798120105" | |
"47016802197685547844962006690576894353336688823830" | |
"22913337214734911490555218134123051689058329294117" | |
"83011983450277211542535458190375258738804563705619" | |
"55277740874464155295278944953199015261800156422805" | |
"72771774460964310684699893055144451845092626359982" | |
"79063901081322647763278370447051079759349248247518")) | |
(defn as-int [char] | |
(Character/getNumericValue char)) | |
(apply max | |
(map #(apply * %) | |
(partition 5 | |
(map as-int numbers-in-string)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Haskell: https://gist.github.com/laurilehmijoki/6829074
In Java 8: https://gist.github.com/laurilehmijoki/6840530