1
0
Fork 0

Update library and stats.

This commit is contained in:
Jonathan Chan 2021-12-05 10:34:29 -08:00 committed by Jonathan Chan
parent 9bafad63d6
commit eb98a66b34
2 changed files with 14 additions and 21 deletions

13
lib.rkt
View File

@ -4,10 +4,7 @@
threading
(only-in data/queue
make-queue
enqueue!)
(only-in 2htdp/batch-io
read-lines
read-file))
enqueue!))
(provide (all-from-out threading)
(all-defined-out))
@ -35,15 +32,15 @@
;; Return contents of input file input/xx.txt as lines of strings.
(define (problem-input n [suffix ""])
(let* ([filename (~a n #:min-width 2 #:align 'right #:left-pad-string "0")]
[path (string-append "../input/" filename suffix ".txt")])
(read-lines path)))
[path (build-path ".." "input" (format "~a~a.txt" filename suffix))])
(file->lines path)))
;; problem-input-all : number? -> string?
;; Return contents of input file input/xx.txt as a single string.
(define (problem-input-all n [suffix ""])
(let* ([filename (~a n #:min-width 2 #:align 'right #:left-pad-string "0")]
[path (string-append "../input/" filename suffix ".txt")])
(read-file path)))
[path (build-path ".." "input" (format "~a~a.txt" filename suffix))])
(file->string path)))
;; problem-input-grouped : number? -> (listof string?)
;; Return contents of input file input/xx.txt as a list of strings,

View File

@ -1,24 +1,20 @@
#lang curly-fn racket
(require threading
(only-in 2htdp/batch-io
read-lines))
(require threading)
(define (source-input n)
(let* ([filename (~a n #:min-width 2 #:align 'right #:left-pad-string "0")]
[path (string-append "src/" filename ".rkt")])
(read-lines path)))
(define rkt-files
(filter #{regexp-match #rx".*\\.rkt$" (path->string %)}
(directory-list "src/" #:build? #{build-path "src/" %})))
(define srcs
(~>> (range 1 11)
(map (λ~>> source-input
(filter non-empty-string?)))))
(map (λ~>> file->lines
(filter non-empty-string?))
rkt-files))
(define src-lengths (map length srcs))
(define src-widths
(~>> srcs
(apply append)
(~>> (apply append srcs)
(map string-length)
(sort _ <=)))