From a262ed2747dd1666617469e2187476bc256455f9 Mon Sep 17 00:00:00 2001 From: Alexander Avery Date: Tue, 3 Dec 2024 11:02:10 -0500 Subject: [PATCH] add a few aggregate functions for boolean slices --- 2024/aggregate.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 2024/aggregate.go diff --git a/2024/aggregate.go b/2024/aggregate.go new file mode 100644 index 0000000..8c71d88 --- /dev/null +++ b/2024/aggregate.go @@ -0,0 +1,19 @@ +package adventoc2024 + +func anyt(b []bool) bool { + for i := range b { + if b[i] { + return true + } + } + return false +} + +func allt(b []bool) bool { + for i := range b { + if !b[i] { + return false + } + } + return true +}