You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
546 B
Clojure

(def counts
(loop [line (read-line)
tot (repeat (count line) 0)
]
(if (empty? line)
tot
(recur
(read-line)
(map + tot (map #(if (= % \1) 1 0) line))
)
)
)
)
(loop [cnts counts gamma 0 epsilon 0]
(if (empty? cnts)
(println (* gamma epsilon))
(recur
(rest cnts)
(if (> (first cnts) 500)
(inc (* 2 gamma))
(* 2 gamma)
)
(if (< (first cnts) 500)
(inc (* 2 epsilon))
(* 2 epsilon)
)
)
)
)