Sha256: 49441931933f268489ef4dda8464675e9a7ef8fcf28960c40bb85d79a567c08d

Contents?: true

Size: 806 Bytes

Versions: 396

Compression:

Stored size: 806 Bytes

Contents

#lang racket

(provide convert)

(define (convert n)
  (let ([drops ""]
        (factors (filter (lambda (v)
                           (and (>= v 3) (<= v 7)))
                         (prime-factors n))))
    (if (not (null? factors))
        (begin
          (when (member 3 factors)
            (set! drops (string-append drops "Pling")))
          (when (member 5 factors)
            (set! drops (string-append drops "Plang")))
          (when (member 7 factors)
            (set! drops (string-append drops "Plong"))))
        (set! drops (string-append drops (number->string n))))
    drops))

(define (prime-factors n)
  (let loop ([n n] [m 2] [factors '()])
    (cond [(= n 1) factors]
          [(= 0 (modulo n m)) (loop (/ n m) 2 (cons m factors))]
          [else (loop n (+ 1 m) factors)])))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.179 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.178 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.177 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.176 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.175 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.174 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.173 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.172 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.171 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.170 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.169 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.167 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.166 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.165 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.164 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.163 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.162 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.161 tracks/racket/exercises/raindrops/example.rkt
trackler-2.2.1.160 tracks/racket/exercises/raindrops/example.rkt