Skip to content

Instantly share code, notes, and snippets.

@laurilehmijoki
Created October 4, 2013 17:19
Show Gist options
  • Save laurilehmijoki/6829426 to your computer and use it in GitHub Desktop.
Save laurilehmijoki/6829426 to your computer and use it in GitHub Desktop.
Find the maximum product of five consecutive integers.
(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))))
@laurilehmijoki
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment