d15 p1
parent
64e54f2f63
commit
bc77b0e75f
@ -0,0 +1,24 @@
|
|||||||
|
#lang br
|
||||||
|
(require racket/file rackunit)
|
||||||
|
|
||||||
|
(define (make-patintss ints)
|
||||||
|
(for/list ([i (in-range (length ints))])
|
||||||
|
(apply append (map (curry make-list (add1 i)) '(0 1 0 -1)))))
|
||||||
|
|
||||||
|
(define (fft str [phase-count 1])
|
||||||
|
(for/fold ([ints (for/list ([c (in-string str)])
|
||||||
|
(string->number (string c)))]
|
||||||
|
#:result (take ints 8))
|
||||||
|
([pidx (in-range phase-count)])
|
||||||
|
(for/list ([patints (in-list (make-patintss ints))])
|
||||||
|
(modulo (abs (for/sum ([int (in-list (cons 0 ints))] ; cons 0 to burn off first patint
|
||||||
|
[patint (in-cycle patints)])
|
||||||
|
(* int patint))) 10))))
|
||||||
|
|
||||||
|
|
||||||
|
(check-equal? (fft "80871224585914546619083218645595" 100) '(2 4 1 7 6 1 7 6))
|
||||||
|
(check-equal? (fft "19617804207202209144916044189917" 100) '(7 3 7 4 5 4 1 8))
|
||||||
|
(check-equal? (fft "69317163492948606335995924319873" 100) '(5 2 4 3 2 1 3 3))
|
||||||
|
|
||||||
|
;; 1
|
||||||
|
(check-equal? (fft (file->string "15.rktd") 100) '(8 5 7 2 6 5 0 2))
|
@ -0,0 +1 @@
|
|||||||
|
59773775883217736423759431065821647306353420453506194937477909478357279250527959717515453593953697526882172199401149893789300695782513381578519607082690498042922082853622468730359031443128253024761190886248093463388723595869794965934425375464188783095560858698959059899665146868388800302242666479679987279787144346712262803568907779621609528347260035619258134850854741360515089631116920328622677237196915348865412336221562817250057035898092525020837239100456855355496177944747496249192354750965666437121797601987523473707071258599440525572142300549600825381432815592726865051526418740875442413571535945830954724825314675166862626566783107780527347044
|
Reference in New Issue