Created
September 25, 2022 19:48
-
-
Save vKxni/65c2ea4025c3114ecf4997ffdf672e05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule BirdCount do | |
def today([]), do: nil | |
def today(list), do: hd(list) | |
def increment_day_count([]), do: [1] | |
def increment_day_count([h | t]), do: [h + 1 | t] | |
def has_day_without_birds?([]), do: false | |
def has_day_without_birds?([0 | _]), do: true | |
def has_day_without_birds?([_ | t ]), do: has_day_without_birds?(t) | |
def total([]), do: 0 | |
def total([h | t]), do: h + total(t) | |
def busy_days([]), do: 0 | |
def busy_days([h | t]) when h >= 5, do: 1 + busy_days(t) | |
def busy_days([_ | t]), do: busy_days(t) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment