Skip to content

Instantly share code, notes, and snippets.

@jld
Created August 31, 2013 00:51
Show Gist options
  • Select an option

  • Save jld/6395568 to your computer and use it in GitHub Desktop.

Select an option

Save jld/6395568 to your computer and use it in GitHub Desktop.
In which numbers are multiplied and divided.
> (define (usable? n) (or (zero? n) (let ((i (modulo n 223))) (and (or (< i 26) (and (>= i 32) (< i (+ 32 26)))) (usable? (quotient n 223))))))
> (time (let loop ((n 1)) (and (< n 100000000) (if (usable? (* n (expt 2 63))) n (loop (+ n 1))))))
(time (let loop ((n 1)) (and (< n 100000000) (if (usable? (* n (expt 2 63))) n (loop (+ n 1))))))
44377 ms real time
44359 ms cpu time (44339 user, 20 system)
58806 collections accounting for 2957 ms real time (2920 user, 0 system)
17930827840 bytes allocated
no minor faults
no major faults
23411452
> (define (thing b n) (if (zero? n) '() (cons (remainder n b) (thing b (quotient n b)))))
> (map (lambda (i) (integer->char (+ 65 i))) (thing 223 (* 23411452 (expt 2 63))))
(#\m #\e #\X #\F #\U #\M #\e #\s #\K #\E #\j #\D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment