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
;; ess-R-object-popup.el | |
;; | |
;; I have defined a function, ess-R-object-popup, that when | |
;; invoked, will return a popup with some information about | |
;; the object at point. The information returned is | |
;; determined by which R function is called. This is controlled | |
;; by an alist, called ess-R-object-popup-alist. The default is | |
;; given below. The keys are the classes of R object that will | |
;; use the associated function. For example, when the function | |
;; is called while point is on a factor object, a table of that |
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 ^:dynamic *m-fib*) | |
(defn fib | |
[n] | |
(let [fib* (memoize (fn | |
[x] | |
(if (< 1 x) | |
(+ (*m-fib* (dec x)) | |
(*m-fib* (- x 2))) | |
1)))] |
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
(ns tnoda.projecteuler.problem-19 | |
(:import (org.joda.time DateTime) ; [joda-time/joda-time "2.1"] | |
(org.joda.time.chrono GregorianChronology))) | |
(defn- a-month-later | |
[^DateTime dt] | |
(.plusMonths dt 1)) | |
(defn- sunday? | |
[^DateTime dt] |
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
(ns tnoda.projecteuler.problem-11 | |
[:require [clojure.string :as str]]) | |
(def ^:private input "08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 | |
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 | |
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 | |
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 | |
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 | |
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 | |
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 |
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
(ns tnoda.projecteuler.problem-12 | |
(:use [org.clojars.tnoda.math.prime :only [sieve* prime-factors *prime-array*]] | |
clojure.test)) | |
(defn- solver* | |
"Returns the value of the first triangle number to have over x divisors." | |
[x] | |
(binding [*prime-array* (sieve*)] | |
(let [triangle-numbers (reductions + (range)) | |
nd (fn number-of-divisors |
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
;;;A palindromic number reads the same both ways. | |
;;;The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. | |
;;;Find the largest palindrome made from the product of two 3-digit numbers. | |
;;;左右どちらから読んでも同じ値になる数を回文数という。 2桁の数の積で表される回文数のうち、 | |
;;;最大のものは 9009 = 91 × 99 である。 | |
;;;では、3桁の数の積で表される回文数のうち最大のものはいくらになるか。 | |
(ns projecteuler.problem-4 | |
(:require [clojure.string :as str]) |
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
(ns tnoda.projecteuler.problem-5 | |
(:import org.apache.commons.math.util.MathUtils) ; [org.apache.commons/commons-math "2.2"] | |
(:use clojure.test)) | |
(defn- solver* | |
[n] | |
(reduce (fn [^long x ^long y] (MathUtils/lcm x y)) (range 1 (inc n)))) | |
(def solver (partial solver* 20)) |
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
(defn fib | |
"Returns the nth Fibonacci number." | |
^long | |
[n] | |
(-> (* 0.5 (inc (Math/sqrt 5))) ; golden ratio | |
(Math/pow n) | |
(/ (Math/sqrt 5)) | |
(+ 0.5) | |
Math/floor | |
long)) |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Retrieved from http://projecteuler.net/problem=1, on Nov 14 2012.