bird-count

This commit is contained in:
2023-12-18 00:39:17 -05:00
parent 5cc59f9234
commit b8a7845967
11 changed files with 387 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
defmodule BirdCount do
def today([]), do: nil
def today([head | _tail]), do: head
def increment_day_count([]), do: [1]
def increment_day_count([head | tail]), do: [head + 1 | tail]
def has_day_without_birds?([]), do: false
def has_day_without_birds?([0 | _tail]), do: true
def has_day_without_birds?([_head | tail]), do: has_day_without_birds?(tail)
def total([]), do: 0
def total([head | tail]), do: head + total(tail)
def busy_days([]), do: 0
def busy_days([head | tail]) when head >= 5, do: 1 + busy_days(tail)
def busy_days([_head | tail]), do: busy_days(tail)
end