Browse files

Problem 19 in ruby

  • Loading branch information...
1 parent b2f38fa commit 8d437880a224102eeafca083ee40b97a17357c41 @jdunphy committed Jan 14, 2013
Showing with 17 additions and 5 deletions.
  1. +3 −0 clojure/pandigital.clj
  2. +2 −5 racket/euler-001.rkt
  3. +12 −0 ruby/euler-019.rb
View
3 clojure/pandigital.clj
@@ -41,3 +41,6 @@
(def largest-pandigital
(last (sort (filter prime?
(map #(Integer/parseInt (apply str %)) (combo/permutations (reverse (range 1 8))))))))
+
+
+;; problem 43 is also a pandigital problem 0-9 pandigital
View
7 racket/euler-001.rkt
@@ -6,14 +6,11 @@
(define (mod5 n) (zero? (modulo n 5)))
(apply + (remove-duplicates
- (append (filter mod3 (range 1 1000)) (filter mod5 (range 1 1000)))))
-
+ (append (filter mod3 (range 1 1000)) (filter mod5 (range 1 1000)))))
; solution 2
(define (modder mod) (lambda (num) (zero? (modulo num mod))))
(apply + (remove-duplicates
(append (filter (modder 3) (range 1 1000))
- (filter (modder 5) (range 1 1000)))))
-
-
+ (filter (modder 5) (range 1 1000)))))
View
12 ruby/euler-019.rb
@@ -0,0 +1,12 @@
+require 'date'
+
+date = Date.new 1901, 1, 1
+end_date = Date.new 2001, 1, 1
+sundays = 0
+
+while (date < end_date) do
+ sundays += 1 if date.sunday? && date.mday == 1
+ date = date.next_month
+end
+
+puts sundays

0 comments on commit 8d43788

Please sign in to comment.