Permalink
Newer
Older
100644 25 lines (20 sloc) 798 Bytes
Mar 25, 2012
1
#lang racket
2
(require "common.rkt")
3
4
; Find the denominator of the product of the four curious fractions with two
5
; digits numerators and denominators.
6
7
(define (solve)
8
9
(define (curious? a b)
10
(and (or (= (remainder a 10) (quotient b 10))
11
(= (quotient a 10) (remainder b 10)))
12
(or (and (not (zero? (quotient b 10)))
13
(= (/ a b) (/ (remainder a 10) (quotient b 10))))
14
(and (not (zero? (remainder b 10)))
15
(= (/ a b) (/ (quotient a 10) (remainder b 10)))))
16
(< (/ a b) 1)))
17
18
(denominator
19
(foldr * 1
20
(map (lambda (x) (/ (first x) (second x)))
21
(filter
22
(lambda (x) (apply curious? x))
23
(cartesian-product (range 10 99) (range 10 99)))))))
24
25
(provide solve)