~rhcarvalho/+junk/racket

« back to all changes in this revision

Viewing changes to project-euler-17.rkt

  • Committer: Rodolfo Carvalho
  • Date: 2011-07-25 08:31:01 UTC
  • Revision ID: rhcarvalho@gmail.com-20110725083101-lh2isl4z3bk0axsn
Extract max-n and compute plot domain

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
;;--------------------------------------------------------------------------
15
15
;; Rodolfo Carvalho, 2011/07/24
16
16
 
 
17
;; --- change here ---
 
18
(define max-n 100000)
 
19
;; --------//---------
 
20
 
17
21
(require (planet williams/describe/describe)
18
22
         (planet stephanh/mathsymbols/mathsymbols)
19
23
         plot
70
74
  (displayln (format "Generating data for ~a" f))
71
75
  (time
72
76
   (let* ([min 1000]
73
 
          [max 100000]
 
77
          [max max-n]
74
78
          [points# 10]
75
79
          [repeat# 7])
76
80
     (for/list ([n (in-range min (add1 max) (/ (- max min) (sub1 points#)))])
108
112
 
109
113
(define (find-max-value . data-lst)
110
114
  ; to be properly implemented...
111
 
  (list 5000000 2000 2000 600))
 
115
  (let ([max-time (apply max (filter number? (apply append (filter list? (apply append (apply append data-lst))))))])
 
116
    (list (+ (* 55.56 (- max-n 1000.0)) 24527)     ; max n
 
117
          (* 6/5 max-time)                         ; max cpu time
 
118
          (* 6/5 max-time)                         ; max real time
 
119
          (* 1/5 max-time)                         ; max gc time
 
120
          )))
112
121
 
113
122
(define (make-data-table getter . data-lst)
114
123
  (apply map list
191
200
         #:width client-w
192
201
         #:height client-h
193
202
         #:x-min 0
194
 
         #:x-max 100000
 
203
         #:x-max max-n
195
204
         #:y-min 0
196
205
         #:y-max y-max
197
206
         #:x-label "N"