---
# System prepended metadata

title: Untitled

---

#
# Write a function `find_twos/1` taking as its only argument a list,
# returning a list containing only the `2`s

# input a list
# output a list of only `2`s

```elixir

def find_twos([el | tail], acc) do
  if(el == 2, do: find_twos(tail, [el | acc]), else: find_twos(tail, acc))
end

def find_twos([], acc), do: acc


def find_twos([]), do: []
def find_twos([2|t]), do: [2|find_twos(t)]
def find_twos([_h|t]), do: find_twos(t)

```


As part of our statistics efforts, Bynk needs to keep track ten
smallest loan applications. Build an Elixir process that receives
messages of the form {:loan 5000}, {:loan 20000} and keeps track of
the 10 smallest loans. When the message :dump is received it should
print out the ten smallest loans. Bynk processes a lot of loans so
the algorithm needs to be somewhat efficient.

```elixir

def process({:loan, amount}, state) do
  if(length(state) < 10 or amount < Enum.max(state), do: [amount | state], else: state)
end

def process(:dump, state), do: state |> Enum.sort |> Enum.take(10)


```