Compare commits

...

2 Commits

Author SHA1 Message Date
frero 643f175635 2025/8/janet: attempt 2026-07-01 21:34:48 +02:00
frero 4ad82ea6cb 2025/2/janet: attempt 2026-07-01 21:34:44 +02:00
2 changed files with 31 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
(def example-input `11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124`)
(defn mapi "immutable map" [f xs] (slice (map f xs)))
(defn parse-input [input]
(mapi |(mapi parse (string/split "-" $))
(string/split "," input)))
(defn solve/1 [data]
(map (fn [[l r]]
(range l r))
data))
(pp (solve/1 (parse-input example-input)))
+16
View File
@@ -0,0 +1,16 @@
(defn magnitude [vector]
(math/sqrt (sum (map |(* $ $) vector))))
(defn straight-line [v1 v2]
(magnitude (map - v1 v2)))
(with [f (file/open "2025/8/ex_input")]
(def parsed (freeze (map
|(map parse (string/split "," (string/trim $)))
(file/lines f))))
(loop [i :range [0 (length parsed)]
:after (print)
j :range [0 i]]
(let [v1 (get parsed i)
v2 (get parsed j)]
(pp (straight-line v1 v2)))))