Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,3 @@
(let (handle (open "readings.txt" "read"))
(setq all-lines (collect (read-line handle)))
(close handle))

View file

@ -0,0 +1,22 @@
;; (20.0 "1990-01-01" 1 0)
(define (line->matrix line)
(letn (fields (parse line {\s+} 0)
day (pop fields)
lst)
(for (i 0 (- (length fields) 1) 2)
(push (array 4 (list (float (fields i)) day (int (fields (+ i 1))) 0))
lst -1))
lst))
(setq all-readings
(array (* 24 (length all-lines)) 4
'(0.0 "2000-00-00" 0 0))
_ nil)
(let (cnt 0)
(dolist (line all-lines)
(setq one-day (line->matrix line))
(dolist (reading one-day)
(setf (all-readings cnt) reading)
(++ cnt)))
'ok)

View file

@ -0,0 +1,7 @@
(local (prev)
(dotimes (i (length all-readings))
(unless (= 1 (all-readings i -2))
(setq prev
(if (zero? i) 0 (all-readings (- i 1) -1)))
(setf (all-readings i -1) (+ 1 prev))))
'ok)

View file

@ -0,0 +1,2 @@
(setq len (apply max (clean zero? (map last all-readings))))
(println "Longest run of bad readings: " len)

View file

@ -0,0 +1,4 @@
(setq days
(map (fn(i) (all-readings i 1))
(index (curry = len) (map last all-readings))))
(println "Bad runs with that length ended on these days: " days)

View file

@ -0,0 +1,3 @@
(setq grand-total (apply add (map first all-readings)))
(setq grand-count (length (filter zero? (map last all-readings))))
(println "Total number of bad readings: " (- (length all-readings) grand-count))

View file

@ -0,0 +1,2 @@
(println (format "Grand total: %.3f Count: %d Average: %.3f"
grand-total grand-count (div grand-total grand-count)))

View file

@ -0,0 +1,4 @@
(define (get-day day)
(filter (fn(e) (= day (e 1))) (array-list all-readings)))
(get-day "1993-03-05")

View file

@ -0,0 +1,8 @@
(define (sum-day day)
(letn (lst (filter (fn(a) (= 1 (a 2))) (get-day day))
tot (apply add (map first lst)))
(println (format "%s Good readings: %d Total: %.3f Avg.: %.3f"
day (length lst) tot
(div tot (if (zero? (length lst)) 0 (length lst)))))))
(sum-day "1993-03-05")