Created
September 25, 2022 03:40
-
-
Save uxjp/854b1e591aadf2be2eaea05d4b5e65c7 to your computer and use it in GitHub Desktop.
fp-list-length without libs
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 Arr do | |
def count(arr) do | |
c(arr, 0) | |
end | |
def c([_ | tail], acc) do | |
c(tail, acc + 1) | |
end | |
def c([], acc) do | |
acc | |
end | |
end | |
defmodule Solution do | |
IO.read(:all) | |
|> String.split | |
|> Enum.map(&String.to_integer/1) | |
|> Arr.count | |
|> IO.puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.hackerrank.com/challenges/fp-list-length/problem?isFullScreen=true&h_r=next-challenge&h_v=zen