We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd733ef commit 783209cCopy full SHA for 783209c
elixir/learn-fp-with-elixir/02.variables-and-functions/exercises/04.ex
@@ -0,0 +1,22 @@
1
+defmodule MatchstickFactory do
2
+ def boxes(matchsticks) do
3
+ big = div(matchsticks, 50)
4
+ remaining_after_big = rem(matchsticks, 50)
5
+
6
+ medium = div(remaining_after_big, 20)
7
+ remaining_after_medium = rem(remaining_after_big, 20)
8
9
+ small = div(remaining_after_medium, 5)
10
+ remaining_matchsticks = rem(remaining_after_medium, 5)
11
12
+ %{
13
+ big: big,
14
+ medium: medium,
15
+ small: small,
16
+ remaining_matchsticks: remaining_matchsticks
17
+ }
18
+ end
19
+end
20
21
+IO.inspect MatchstickFactory.boxes(98)
22
+IO.inspect MatchstickFactory.boxes(39)
0 commit comments