DEV Community

Discussion on: Daily Coding Puzzles - Oct 29th - Nov 2nd

Collapse
 
tux0r profile image
tux0r

Common Lisp again:

(setf bits '(1 0 0 0)) ;; or something
(reduce (lambda (x y) (+ (* 2 x) y)) bits)

Output:

8

This is entirely type-agnostic and will not overflow for large input arrays.