`
hotcharm
  • 浏览: 16553 次
  • 性别: Icon_minigender_1
  • 来自: 义乌
最近访客 更多访客>>
社区版块
存档分类
最新评论

用clojure解决euler problem 8

 
阅读更多

问题描述:

Find the greatest product of five consecutive digits in the 1000-digit number.

73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450

解决方案:

(ns euler-problem-8.core)

(defn char-to-int
  [a]
  (Character/digit a 10))

(def one-thousand-digit-number-string "73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450")

(apply max (map #(reduce * (map char-to-int %)) (partition 5 1 one-thousand-digit-number-string )))

答案为:40824
分享到:
评论

相关推荐

    欧拉公式求圆周率的matlab代码-euler:我对欧拉计画的解决方案(clojure)

    该存储库是使用Clojure解决Euler问题的支架。 它以有组织的结构生成规格和解决方案存根,从而使生活稍微好一些。 安装 如果尚未安装,则将其添加到您的路径中。 签出这个项目: $ git clone git@github....

    欧拉公式求圆周率的matlab代码-project-euler:Clojure解决Euler项目问题​​的方法

    Clojure骇客解决了Euler项目的问题。 目的是用惯用的Clojure编写功能解决方案。 用法 大多数解决方案都是完整的,并且完全独立地包含在具有“解决”功能的唯一名称空间中。 有些正在“进行中”。 执照 版权所有:...

    project-euler-clojure:我对Euler项目的Clojure解决方案

    欧拉计划 问题1-2、4、6、8-10、12、14、21、24-26、32、34、36、39、41、46、49、52、55-58、62、65的Clojure解决方案70-74、87、92、97、124、173-174、179、187、214运行解决方案使用以下命令行运行解决方案: ...

    Programming Clojure 英文电子版

    Clojure's clean, careful design lets you write programs that get right to the essence of a problem, without a lot of clutter and ceremony. Clojure is Lisp reloaded. Clojure has the power inherent in...

    euler:Clojure中的Project Euler解决方案

    欧拉解决Clojure中的Euler项目问题​​的方法。 持续的爱好。执照版权所有:copyright:2012-2015 Dave Yarwood 在Eclipse Public License 1.0版下分发。

    有关JAVA的译文 Clojure:“挑战”Java编程语言

    在今后的软件设计中无论使用Clojure语言,还是坚持使用Java语言,Clojure语言都将与java做比较,哪种是设计软件的最佳方式。 Clojure语言是一个JVM(包括Groovy,Jython和JRuby等语言)的新语言,它提供了活力,...

    Clojure编程乐趣

    Clojure is an opinionated language—it doesn’t try to cover all paradigms or provide every checklist bullet-point feature. Instead it provides the features needed to solve all kinds of real-world ...

    Professional.Clojure.1119267277

    Clear, practical Clojure for the professional programmer Professional Clojure is the experienced developer's guide to functional programming using the Clojure language. Designed specifically to meet ...

    Practical Clojure.pdf

    Practical Clojure Clojure语言书籍

    clojure eclipse

    clojure clojure clojureclojure clojure

    Clojure可选类型系统TypedClojure.zip

    主要特性:从 Java 中保护你的 Clojure 程序,进行安全的互操作,正确的使用外部 Java 库。Typed Clojure 支持关键字映射的使用,类型检测器中包含有用的映射操作,包括关键字查找,添加或者移除关键字,合并映射...

    clojure相关书籍1

    【1】[Clojure编程乐趣](The Joy of Clojure).pdf 【2】Clojure – Functional Programming for the JVM中文版.pdf 【3】Clojure Cookbook.pdf 【4】Clojure Data Analysis Cookbook.pdf 【5】clojure Hand book...

    Clojure电子书合集2(13本)

    [2013] Functional Programming Patterns in Scala and Clojure - Write Lean Programs for the JVM.(Michael Bevilacqua-Linn).[1937785475].pdf+epub.rar [2014] Clojure Cookbook - Recipes for Functional ...

    Clojure编程乐趣]+clojure_programming.pdf

    Clojure编程乐趣和clojure_programming.pdf两本书

    tools.analyzer, 用于Clojure代码的分析器,用Clojure编写,并在EDN中生成 AST.zip

    tools.analyzer, 用于Clojure代码的分析器,用Clojure编写,并在EDN中生成 AST tools.analyzer主机无关Clojure代码的分析器,用Clojure编写,并在EDN中生成 AST 。我在 2015年12月的ClojureX上讨论了 tools.analyzer...

    Mastering.Clojure.1785

    Key Features Learn to handle data using sequences, ...Chapter 8. Leveraging Asynchronous Tasks Chapter 9. Reactive Programming Chapter 10. Testing Your Code Chapter 11. Troubleshooting and Best Practices

    4clojure-solutions:我对 4clojure 问题的解决方案

    4clojure解决方案对问题的解决方案。 不是最惯用的 Clojure 代码,但到底是什么 - 它有效! :grinning_face:小费不要复制/粘贴解决方案,而是在理解所遵循的方法后尝试自己编写。 使用这些解决方案来找出算法而不是...

    Clojure电子书合集1(12本)

    [2009] Programming Clojure.(Stuart Halloway).[1934356336].pdf [2010] Functional Programming with Clojure - Simple Concurrency on the JVM.(Tim Berglund, Matthew McCullough).[193650202X].pdf [2010] ...

    clojure1.3.0及资料

    clojure1.3.0及资料,附《Programming Clojure》,《Practical Clojure》

Global site tag (gtag.js) - Google Analytics