Skip to content

Commit 0111b04

Browse files
more number koans
1 parent 18ce175 commit 0111b04

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

lib/koans/03_numbers.ex

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,38 @@ defmodule Numbers do
44

55
@intro "Why is the number six so scared? Because seven eight nine!\nWe should get to know numbers a bit more!"
66

7+
koan "Is an integer equal to its float equivalent?" do
8+
assert 1 == 1.0 == ___
9+
end
10+
11+
koan "Is an integer threequal to its float equivalent?" do
12+
assert 1 === 1.0 == ___
13+
end
14+
15+
koan "Revisit divison with threequal" do
16+
assert 2 / 2 === ___
17+
end
18+
19+
koan "Another way to divide" do
20+
assert div(5, 2) == ___
21+
end
22+
23+
koan "Other math operators may produce this" do
24+
assert 2 * 2 === ___
25+
end
26+
27+
koan "Or other math operators may produce this" do
28+
assert 2 * 2.0 === ___
29+
end
30+
31+
koan "Two ways to round, are they exactly the same?" do
32+
assert Float.round(1.2) === round(1.2) == ___
33+
end
34+
35+
koan "Release the decimals into the void" do
36+
assert trunc(5.6) === ___
37+
end
38+
739
koan "Are you odd?" do
840
assert Integer.is_odd(3) == ___
941
end

test/koans/numbers_koans_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ defmodule NumbersTests do
44

55
test "Numbers" do
66
answers = [
7+
true,
8+
false,
9+
1.0,
10+
2,
11+
4,
12+
4.0,
13+
false,
14+
5,
715
true,
816
true,
917
[5, 8, 1, 2, 7],

0 commit comments

Comments
 (0)