trackler 2.0.8.39 → 2.0.8.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/elixir/config.json +14 -0
- data/tracks/elixir/exercises/bank-account/bank_account_test.exs +8 -0
- data/tracks/elixir/exercises/bank-account/example.exs +10 -2
- data/tracks/elixir/exercises/secret-handshake/HINTS.md +20 -0
- data/tracks/elixir/exercises/secret-handshake/example.exs +43 -0
- data/tracks/elixir/exercises/secret-handshake/secret_handshake.exs +20 -0
- data/tracks/elixir/exercises/secret-handshake/secret_handshake_test.exs +72 -0
- data/tracks/elixir/exercises/strain/HINTS.md +1 -0
- data/tracks/elixir/exercises/strain/example.exs +40 -0
- data/tracks/elixir/exercises/strain/strain.exs +22 -0
- data/tracks/elixir/exercises/strain/strain_test.exs +96 -0
- data/tracks/erlang/SETUP.md +2 -2
- data/tracks/java/bin/journey-test.sh +2 -0
- data/tracks/java/exercises/book-store/src/test/java/BookstoreTest.java +1 -0
- data/tracks/java/exercises/twelve-days/src/example/java/TwelveDays.java +16 -20
- data/tracks/java/exercises/twelve-days/src/test/java/TwelveDaysTest.java +21 -14
- data/tracks/perl6/.travis.yml +1 -1
- data/tracks/python/exercises/diamond/diamond_test.py +73 -13
- data/tracks/python/exercises/grep/grep_test.py +3 -0
- data/tracks/python/exercises/sublist/sublist_test.py +10 -0
- data/tracks/rust/exercises/acronym/.gitignore +7 -0
- data/tracks/rust/exercises/all-your-base/.gitignore +7 -0
- data/tracks/rust/exercises/alphametics/.gitignore +7 -0
- data/tracks/rust/exercises/atbash-cipher/.gitignore +7 -0
- data/tracks/rust/exercises/protein-translation/.gitignore +7 -0
- data/tracks/rust/exercises/react/.gitignore +7 -0
- data/tracks/rust/exercises/rotational-cipher/.gitignore +7 -0
- metadata +17 -3
- data/tracks/perl6/.gitmodules +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d30d6eef2ec6bb48c145139282b4dfd7ae00001
|
4
|
+
data.tar.gz: 9f8b29d64bf05c03625ee0f2dfc057c6fde1ea04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f55c537bf59e203edc2d98bfe922b699643a0f5838fd52d216f0a194a82bd665f3ed687e8c53220c7994beaaef35daca336aab2ac48fe19d192a1b93d139c4
|
7
|
+
data.tar.gz: 2f6b57f6ed237a96d07a34c73f4d436968c7b69191c961d9fc1e50b14147af4e4ec3d8a58d215dfae735854aec1cd51f9acb3190f0e5569eecf357b39885ecd2
|
data/lib/trackler/version.rb
CHANGED
data/tracks/elixir/config.json
CHANGED
@@ -20,6 +20,13 @@
|
|
20
20
|
"enumerables"
|
21
21
|
]
|
22
22
|
},
|
23
|
+
{
|
24
|
+
"slug": "secret-handshake",
|
25
|
+
"difficulty": 2,
|
26
|
+
"topics": [
|
27
|
+
"binary representation"
|
28
|
+
]
|
29
|
+
},
|
23
30
|
{
|
24
31
|
"slug": "rotational-cipher",
|
25
32
|
"difficulty": 2,
|
@@ -27,6 +34,13 @@
|
|
27
34
|
"string processing"
|
28
35
|
]
|
29
36
|
},
|
37
|
+
{
|
38
|
+
"slug": "strain",
|
39
|
+
"difficulty": 2,
|
40
|
+
"topics": [
|
41
|
+
"collections"
|
42
|
+
]
|
43
|
+
},
|
30
44
|
{
|
31
45
|
"slug": "protein-translation",
|
32
46
|
"difficulty": 2,
|
@@ -50,6 +50,14 @@ defmodule BankAccountTest do
|
|
50
50
|
assert BankAccount.balance(account) == 20
|
51
51
|
end
|
52
52
|
|
53
|
+
@tag :pending
|
54
|
+
test "closing account rejects further inquiries", %{account: account} do
|
55
|
+
assert BankAccount.balance(account) == 0
|
56
|
+
BankAccount.close_bank(account)
|
57
|
+
assert BankAccount.balance(account) == {:error, :account_closed}
|
58
|
+
assert BankAccount.update(account, 10) == {:error, :account_closed}
|
59
|
+
end
|
60
|
+
|
53
61
|
@tag :pending
|
54
62
|
test "incrementing balance from another process then checking it from test process", %{account: account} do
|
55
63
|
assert BankAccount.balance(account) == 0
|
@@ -53,13 +53,21 @@ defmodule BankAccount do
|
|
53
53
|
"""
|
54
54
|
@spec balance(account) :: integer
|
55
55
|
def balance(account) do
|
56
|
-
|
56
|
+
if Process.alive?(account) do
|
57
|
+
:gen_server.call(account, :balance)
|
58
|
+
else
|
59
|
+
{ :error, :account_closed }
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
@doc """
|
60
64
|
Update the account's balance by adding the given amount which may be negative.
|
61
65
|
"""
|
62
66
|
def update(account, amount) do
|
63
|
-
|
67
|
+
if Process.alive?(account) do
|
68
|
+
:gen_server.call(account, { :update, amount })
|
69
|
+
else
|
70
|
+
{ :error, :account_closed }
|
71
|
+
end
|
64
72
|
end
|
65
73
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
use Bitwise (or div/rem)
|
2
|
+
|
3
|
+
If you use Bitwise, an easy way to see if a particular bit is set is to compare
|
4
|
+
the binary AND (`&&&`) of a set of bits with the particular bit pattern you
|
5
|
+
want to check, and determine if the result is the same as the pattern you're
|
6
|
+
checking.
|
7
|
+
|
8
|
+
Example:
|
9
|
+
|
10
|
+
Flags: 0b11011
|
11
|
+
Check: 0b11010
|
12
|
+
|
13
|
+
Flags &&& Check: 0b11010 (All checked bits are set)
|
14
|
+
|
15
|
+
Another:
|
16
|
+
|
17
|
+
Flags: 0b11011
|
18
|
+
Check: 0b10110
|
19
|
+
|
20
|
+
Flags &&& Check: 0b10010 (Third bit not set)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
defmodule SecretHandshake do
|
2
|
+
use Bitwise
|
3
|
+
|
4
|
+
@codes ["wink", "double blink", "close your eyes", "jump"]
|
5
|
+
|
6
|
+
@doc """
|
7
|
+
Determine the actions of a secret handshake based on the binary
|
8
|
+
representation of the given `code`.
|
9
|
+
|
10
|
+
If the following bits are set, include the corresponding action in your list
|
11
|
+
of commands, in order from lowest to highest.
|
12
|
+
|
13
|
+
1 = wink
|
14
|
+
10 = double blink
|
15
|
+
100 = close your eyes
|
16
|
+
1000 = jump
|
17
|
+
|
18
|
+
10000 = Reverse the order of the operations in the secret handshake
|
19
|
+
"""
|
20
|
+
@spec commands(code :: integer) :: list(String.t())
|
21
|
+
def commands(code) do
|
22
|
+
@codes
|
23
|
+
|> Enum.with_index
|
24
|
+
|> Enum.map(fn {command, i} -> { command, 2 <<< (i-1) } end)
|
25
|
+
|> decode_commands(code, [])
|
26
|
+
end
|
27
|
+
|
28
|
+
defp decode_commands([], code, results) do
|
29
|
+
case flag_set(code, 16) do
|
30
|
+
true -> results
|
31
|
+
_ -> Enum.reverse(results)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
defp decode_commands([{ command, flag } | flags], code, results) do
|
35
|
+
case flag_set(code, flag) do
|
36
|
+
true -> decode_commands(flags, code, [command | results])
|
37
|
+
_ -> decode_commands(flags, code, results)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
defp flag_set(flags, flag_to_check), do: (flags &&& flag_to_check) == flag_to_check
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
defmodule SecretHandshake do
|
2
|
+
@doc """
|
3
|
+
Determine the actions of a secret handshake based on the binary
|
4
|
+
representation of the given `code`.
|
5
|
+
|
6
|
+
If the following bits are set, include the corresponding action in your list
|
7
|
+
of commands, in order from lowest to highest.
|
8
|
+
|
9
|
+
1 = wink
|
10
|
+
10 = double blink
|
11
|
+
100 = close your eyes
|
12
|
+
1000 = jump
|
13
|
+
|
14
|
+
10000 = Reverse the order of the operations in the secret handshake
|
15
|
+
"""
|
16
|
+
@spec commands(code :: integer) :: list(String.t())
|
17
|
+
def commands(code) do
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
2
|
+
Code.load_file("secret_handshake.exs", __DIR__)
|
3
|
+
end
|
4
|
+
|
5
|
+
ExUnit.start
|
6
|
+
ExUnit.configure trace: true, exclude: :pending
|
7
|
+
|
8
|
+
defmodule SecretHandshakeTest do
|
9
|
+
use ExUnit.Case
|
10
|
+
|
11
|
+
describe "Create a handshake for a number" do
|
12
|
+
#@tag :pending
|
13
|
+
test "wink for 1" do
|
14
|
+
assert SecretHandshake.commands(1) == ["wink"]
|
15
|
+
end
|
16
|
+
|
17
|
+
@tag :pending
|
18
|
+
test "double blink for 10" do
|
19
|
+
assert SecretHandshake.commands(2) == ["double blink"]
|
20
|
+
end
|
21
|
+
|
22
|
+
@tag :pending
|
23
|
+
test "close your eyes for 100" do
|
24
|
+
assert SecretHandshake.commands(4) == ["close your eyes"]
|
25
|
+
end
|
26
|
+
|
27
|
+
@tag :pending
|
28
|
+
test "jump for 1000" do
|
29
|
+
assert SecretHandshake.commands(8) == ["jump"]
|
30
|
+
end
|
31
|
+
|
32
|
+
@tag :pending
|
33
|
+
test "combine two actions" do
|
34
|
+
assert SecretHandshake.commands(3) == ["wink", "double blink"]
|
35
|
+
end
|
36
|
+
|
37
|
+
@tag :pending
|
38
|
+
test "reverse two actions" do
|
39
|
+
assert SecretHandshake.commands(19) == ["double blink", "wink"]
|
40
|
+
end
|
41
|
+
|
42
|
+
@tag :pending
|
43
|
+
test "reversing one action gives the same action" do
|
44
|
+
assert SecretHandshake.commands(24) == ["jump"]
|
45
|
+
end
|
46
|
+
|
47
|
+
@tag :pending
|
48
|
+
test "reversing no actions still gives no actions" do
|
49
|
+
assert SecretHandshake.commands(16) == []
|
50
|
+
end
|
51
|
+
|
52
|
+
@tag :pending
|
53
|
+
test "all possible actions" do
|
54
|
+
assert SecretHandshake.commands(15) == ["wink", "double blink", "close your eyes", "jump"]
|
55
|
+
end
|
56
|
+
|
57
|
+
@tag :pending
|
58
|
+
test "reverse all possible actions" do
|
59
|
+
assert SecretHandshake.commands(31) == ["jump", "close your eyes", "double blink", "wink"]
|
60
|
+
end
|
61
|
+
|
62
|
+
@tag :pending
|
63
|
+
test "do nothing for zero" do
|
64
|
+
assert SecretHandshake.commands(0) == []
|
65
|
+
end
|
66
|
+
|
67
|
+
@tag :pending
|
68
|
+
test "do nothing if lower 5 bits not set" do
|
69
|
+
assert SecretHandshake.commands(32) == []
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
`apply` will let you pass arguments to a function, as will `fun.(args)`
|
@@ -0,0 +1,40 @@
|
|
1
|
+
defmodule Strain do
|
2
|
+
@doc """
|
3
|
+
Given a `list` of items and a function `fun`, return the list of items where
|
4
|
+
`fun` returns true.
|
5
|
+
|
6
|
+
Do not use `Enum.filter`.
|
7
|
+
"""
|
8
|
+
@spec keep(list :: list(any), fun :: ((any) -> boolean)) :: list(any)
|
9
|
+
def keep(list, fun) do
|
10
|
+
do_keep(list, fun, [])
|
11
|
+
end
|
12
|
+
|
13
|
+
defp do_keep([], _, results), do: Enum.reverse(results)
|
14
|
+
defp do_keep([head | tail], fun, results) do
|
15
|
+
case apply(fun, [head]) do
|
16
|
+
true -> do_keep(tail, fun, [head | results])
|
17
|
+
_ -> do_keep(tail, fun, results)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@doc """
|
22
|
+
Given a `list` of items and a function `fun`, return the list of items where
|
23
|
+
`fun` returns true.
|
24
|
+
|
25
|
+
Do not use `Enum.reject`.
|
26
|
+
"""
|
27
|
+
@spec discard(list :: list(any), fun :: ((any) -> boolean)) :: list(any)
|
28
|
+
def discard(list, fun) do
|
29
|
+
do_discard(list, fun, [])
|
30
|
+
end
|
31
|
+
|
32
|
+
defp do_discard([], _, results), do: Enum.reverse(results)
|
33
|
+
defp do_discard([head | tail], fun, results) do
|
34
|
+
case apply(fun, [head]) do
|
35
|
+
true -> do_discard(tail, fun, results)
|
36
|
+
_ -> do_discard(tail, fun, [ head | results ])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
defmodule Strain do
|
2
|
+
@doc """
|
3
|
+
Given a `list` of items and a function `fun`, return the list of items where
|
4
|
+
`fun` returns true.
|
5
|
+
|
6
|
+
Do not use `Enum.filter`.
|
7
|
+
"""
|
8
|
+
@spec keep(list :: list(any), fun :: ((any) -> boolean)) :: list(any)
|
9
|
+
def keep(list, fun) do
|
10
|
+
end
|
11
|
+
|
12
|
+
@doc """
|
13
|
+
Given a `list` of items and a function `fun`, return the list of items where
|
14
|
+
`fun` returns true.
|
15
|
+
|
16
|
+
Do not use `Enum.reject`.
|
17
|
+
"""
|
18
|
+
@spec discard(list :: list(any), fun :: ((any) -> boolean)) :: list(any)
|
19
|
+
def discard(list, fun) do
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
2
|
+
Code.load_file("strain.exs", __DIR__)
|
3
|
+
end
|
4
|
+
|
5
|
+
ExUnit.start
|
6
|
+
ExUnit.configure trace: true, exclude: :pending
|
7
|
+
|
8
|
+
defmodule StrainTest do
|
9
|
+
use ExUnit.Case
|
10
|
+
|
11
|
+
defp is_odd?(n), do: rem(n, 2) == 1
|
12
|
+
defp is_even?(n), do: rem(n, 2) == 0
|
13
|
+
defp noop(_), do: true
|
14
|
+
|
15
|
+
#@tag :pending
|
16
|
+
test "empty keep" do
|
17
|
+
assert Strain.keep([], &noop/1) == []
|
18
|
+
end
|
19
|
+
|
20
|
+
@tag :pending
|
21
|
+
test "keep everything" do
|
22
|
+
assert Strain.keep([1, 2, 3], fn e -> e < 10 end) == [1, 2, 3]
|
23
|
+
end
|
24
|
+
|
25
|
+
@tag :pending
|
26
|
+
test "keep first and last" do
|
27
|
+
assert Strain.keep([1, 2, 3], &is_odd?/1) == [1, 3]
|
28
|
+
end
|
29
|
+
|
30
|
+
@tag :pending
|
31
|
+
test "keep neither first nor last" do
|
32
|
+
assert Strain.keep([1, 2, 3, 4, 5], &is_even?/1) == [2, 4]
|
33
|
+
end
|
34
|
+
|
35
|
+
@tag :pending
|
36
|
+
test "keep strings" do
|
37
|
+
words = ~w(apple zebra banana zombies cherimoya zelot)
|
38
|
+
assert Strain.keep(words, &(String.starts_with?(&1, "z"))) == ~w(zebra zombies zelot)
|
39
|
+
end
|
40
|
+
|
41
|
+
@tag :pending
|
42
|
+
test "keep arrays" do
|
43
|
+
rows = [
|
44
|
+
[1, 2, 3],
|
45
|
+
[5, 5, 5],
|
46
|
+
[5, 1, 2],
|
47
|
+
[2, 1, 2],
|
48
|
+
[1, 5, 2],
|
49
|
+
[2, 2, 1],
|
50
|
+
[1, 2, 5]
|
51
|
+
]
|
52
|
+
|
53
|
+
assert Strain.keep(rows, fn row -> 5 in row end) == [[5, 5, 5], [5, 1, 2], [1, 5, 2], [1, 2, 5]]
|
54
|
+
end
|
55
|
+
|
56
|
+
@tag :pending
|
57
|
+
test "empty discard" do
|
58
|
+
assert Strain.discard([], &noop/1) == []
|
59
|
+
end
|
60
|
+
|
61
|
+
@tag :pending
|
62
|
+
test "discard nothing" do
|
63
|
+
assert Strain.discard([1, 2, 3], fn e -> e > 10 end) == [1, 2, 3]
|
64
|
+
end
|
65
|
+
|
66
|
+
@tag :pending
|
67
|
+
test "discard first and last" do
|
68
|
+
assert Strain.discard([1, 2, 3], &is_odd?/1) == [2]
|
69
|
+
end
|
70
|
+
|
71
|
+
@tag :pending
|
72
|
+
test "discard neither first nor last" do
|
73
|
+
assert Strain.discard([1, 2, 3, 4, 5], &is_even?/1) == [1, 3, 5]
|
74
|
+
end
|
75
|
+
|
76
|
+
@tag :pending
|
77
|
+
test "discard strings" do
|
78
|
+
words = ~w(apple zebra banana zombies cherimoya zelot)
|
79
|
+
assert Strain.discard(words, &(String.starts_with?(&1, "z"))) == ~w(apple banana cherimoya)
|
80
|
+
end
|
81
|
+
|
82
|
+
@tag :pending
|
83
|
+
test "discard arrays" do
|
84
|
+
rows = [
|
85
|
+
[1, 2, 3],
|
86
|
+
[5, 5, 5],
|
87
|
+
[5, 1, 2],
|
88
|
+
[2, 1, 2],
|
89
|
+
[1, 5, 2],
|
90
|
+
[2, 2, 1],
|
91
|
+
[1, 2, 5]
|
92
|
+
]
|
93
|
+
assert Strain.discard(rows, fn row -> 5 in row end) == [[1, 2, 3], [2, 1, 2], [2, 2, 1]]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
data/tracks/erlang/SETUP.md
CHANGED
@@ -13,7 +13,7 @@ Each problem defines a macro `TEST_VERSION` in the test file and
|
|
13
13
|
verifies that the solution defines and exports a function `test_version`
|
14
14
|
returning that same value.
|
15
15
|
|
16
|
-
To make
|
16
|
+
To make tests pass, add the following to your solution:
|
17
17
|
|
18
18
|
```erlang
|
19
19
|
-export([test_version/0]).
|
@@ -24,7 +24,7 @@ test_version() ->
|
|
24
24
|
|
25
25
|
The benefit of this is that reviewers can see against which test version
|
26
26
|
an iteration was written if, for example, a previously posted solution
|
27
|
-
does not
|
27
|
+
does not solve the current problem or passes current tests.
|
28
28
|
|
29
29
|
## Questions?
|
30
30
|
|
@@ -225,6 +225,8 @@ solve_all_exercises() {
|
|
225
225
|
cp -R -H ${xjava}/exercises/${exercise}/src/example/java/* ${exercism_exercises_dir}/java/${exercise}/src/main/java/
|
226
226
|
|
227
227
|
pushd ${exercism_exercises_dir}/java/${exercise}
|
228
|
+
# Check that tests compile before we strip @Ignore annotations
|
229
|
+
gradle compileTestJava
|
228
230
|
# Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
|
229
231
|
for testfile in `find . -name "*Test.java"`; do
|
230
232
|
sed 's/@Ignore//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
public class TwelveDays {
|
2
|
-
private static String[] days = new String[]
|
3
|
-
|
4
|
-
private static String[] gifts = new String[]
|
2
|
+
private static String[] days = new String[]{"first", "second", "third", "fourth", "fifth", "sixth", "seventh",
|
3
|
+
"eighth", "ninth", "tenth", "eleventh", "twelfth"};
|
4
|
+
private static String[] gifts = new String[]{
|
5
5
|
"a Partridge in a Pear Tree.",
|
6
6
|
"two Turtle Doves, ",
|
7
7
|
"three French Hens, ",
|
@@ -16,31 +16,27 @@ public class TwelveDays {
|
|
16
16
|
"twelve Drummers Drumming, "
|
17
17
|
};
|
18
18
|
|
19
|
-
public
|
20
|
-
|
19
|
+
public String verse(int verseNumber) {
|
20
|
+
StringBuilder stringBuilder = new StringBuilder("On the " + days[verseNumber - 1]
|
21
|
+
+ " day of Christmas my true love gave to me, ");
|
22
|
+
for (int i = verseNumber; i > 0; i--) {
|
23
|
+
if (verseNumber != 1 && i == 1) stringBuilder.append("and ");
|
24
|
+
stringBuilder.append(gifts[i - 1]);
|
25
|
+
}
|
26
|
+
stringBuilder.append("\n");
|
27
|
+
return stringBuilder.toString();
|
21
28
|
}
|
22
29
|
|
23
|
-
public
|
24
|
-
StringBuilder stringBuilder = new StringBuilder(
|
30
|
+
public String verses(int verseNumberStart, int verseNumberEnd) {
|
31
|
+
StringBuilder stringBuilder = new StringBuilder(verse(verseNumberStart));
|
25
32
|
for (int i = verseNumberStart + 1; i <= verseNumberEnd; i++) {
|
26
33
|
stringBuilder.append("\n");
|
27
|
-
stringBuilder.append(
|
34
|
+
stringBuilder.append(verse(i));
|
28
35
|
}
|
29
36
|
return stringBuilder.toString();
|
30
37
|
}
|
31
38
|
|
32
|
-
public
|
39
|
+
public String sing() {
|
33
40
|
return verses(1, 12);
|
34
41
|
}
|
35
|
-
|
36
|
-
private static String constructVerse(int verseNumber) {
|
37
|
-
StringBuilder stringBuilder = new StringBuilder("On the " + days[verseNumber - 1]
|
38
|
-
+ " day of Christmas my true love gave to me, ");
|
39
|
-
for (int i = verseNumber; i > 0; i--) {
|
40
|
-
if (verseNumber != 1 && i == 1) stringBuilder.append("and ");
|
41
|
-
stringBuilder.append(gifts[i - 1]);
|
42
|
-
}
|
43
|
-
stringBuilder.append("\n");
|
44
|
-
return stringBuilder.toString();
|
45
|
-
}
|
46
42
|
}
|
@@ -1,15 +1,22 @@
|
|
1
|
+
import org.junit.Before;
|
1
2
|
import org.junit.Ignore;
|
2
3
|
import org.junit.Test;
|
3
4
|
|
4
5
|
import static org.junit.Assert.assertEquals;
|
5
6
|
|
6
7
|
public class TwelveDaysTest {
|
8
|
+
private TwelveDays twelveDays;
|
9
|
+
|
10
|
+
@Before
|
11
|
+
public void setup() {
|
12
|
+
twelveDays = new TwelveDays();
|
13
|
+
}
|
7
14
|
|
8
15
|
@Test
|
9
16
|
public void testVerseOne() {
|
10
17
|
String expectedVerseOne = "On the first day of Christmas my true love gave to me, " +
|
11
18
|
"a Partridge in a Pear Tree.\n";
|
12
|
-
assertEquals(expectedVerseOne,
|
19
|
+
assertEquals(expectedVerseOne, twelveDays.verse(1));
|
13
20
|
}
|
14
21
|
|
15
22
|
@Ignore
|
@@ -17,7 +24,7 @@ public class TwelveDaysTest {
|
|
17
24
|
public void testVerseTwo() {
|
18
25
|
String expectedVerseTwo = "On the second day of Christmas my true love gave to me, two Turtle Doves, " +
|
19
26
|
"and a Partridge in a Pear Tree.\n";
|
20
|
-
assertEquals(expectedVerseTwo,
|
27
|
+
assertEquals(expectedVerseTwo, twelveDays.verse(2));
|
21
28
|
}
|
22
29
|
|
23
30
|
@Ignore
|
@@ -25,7 +32,7 @@ public class TwelveDaysTest {
|
|
25
32
|
public void testVerseThree() {
|
26
33
|
String expectedVerseThree = "On the third day of Christmas my true love gave to me, three French Hens, " +
|
27
34
|
"two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
28
|
-
assertEquals(expectedVerseThree,
|
35
|
+
assertEquals(expectedVerseThree, twelveDays.verse(3));
|
29
36
|
}
|
30
37
|
|
31
38
|
@Ignore
|
@@ -33,7 +40,7 @@ public class TwelveDaysTest {
|
|
33
40
|
public void testVerseFour() {
|
34
41
|
String expectedVerseFour = "On the fourth day of Christmas my true love gave to me, four Calling Birds, " +
|
35
42
|
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
36
|
-
assertEquals(expectedVerseFour,
|
43
|
+
assertEquals(expectedVerseFour, twelveDays.verse(4));
|
37
44
|
}
|
38
45
|
|
39
46
|
@Ignore
|
@@ -41,7 +48,7 @@ public class TwelveDaysTest {
|
|
41
48
|
public void testVerseFive() {
|
42
49
|
String expectedVerseFive = "On the fifth day of Christmas my true love gave to me, five Gold Rings, " +
|
43
50
|
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
44
|
-
assertEquals(expectedVerseFive,
|
51
|
+
assertEquals(expectedVerseFive, twelveDays.verse(5));
|
45
52
|
}
|
46
53
|
|
47
54
|
@Ignore
|
@@ -50,7 +57,7 @@ public class TwelveDaysTest {
|
|
50
57
|
String expectedVerseSix = "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, " +
|
51
58
|
"five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
|
52
59
|
"and a Partridge in a Pear Tree.\n";
|
53
|
-
assertEquals(expectedVerseSix,
|
60
|
+
assertEquals(expectedVerseSix, twelveDays.verse(6));
|
54
61
|
}
|
55
62
|
|
56
63
|
@Ignore
|
@@ -59,7 +66,7 @@ public class TwelveDaysTest {
|
|
59
66
|
String expectedVerseSeven = "On the seventh day of Christmas my true love gave to me, " +
|
60
67
|
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, " +
|
61
68
|
"two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
62
|
-
assertEquals(expectedVerseSeven,
|
69
|
+
assertEquals(expectedVerseSeven, twelveDays.verse(7));
|
63
70
|
}
|
64
71
|
|
65
72
|
@Ignore
|
@@ -68,7 +75,7 @@ public class TwelveDaysTest {
|
|
68
75
|
String expectedVerseEight = "On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking," +
|
69
76
|
" seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
|
70
77
|
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
71
|
-
assertEquals(expectedVerseEight,
|
78
|
+
assertEquals(expectedVerseEight, twelveDays.verse(8));
|
72
79
|
}
|
73
80
|
|
74
81
|
@Ignore
|
@@ -77,7 +84,7 @@ public class TwelveDaysTest {
|
|
77
84
|
String expectedVerseNine = "On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, " +
|
78
85
|
"eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
|
79
86
|
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
80
|
-
assertEquals(expectedVerseNine,
|
87
|
+
assertEquals(expectedVerseNine, twelveDays.verse(9));
|
81
88
|
}
|
82
89
|
|
83
90
|
@Ignore
|
@@ -87,7 +94,7 @@ public class TwelveDaysTest {
|
|
87
94
|
"nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, " +
|
88
95
|
"five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, " +
|
89
96
|
"and a Partridge in a Pear Tree.\n";
|
90
|
-
assertEquals(expectedVerseTen,
|
97
|
+
assertEquals(expectedVerseTen, twelveDays.verse(10));
|
91
98
|
}
|
92
99
|
|
93
100
|
@Ignore
|
@@ -97,7 +104,7 @@ public class TwelveDaysTest {
|
|
97
104
|
"eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
|
98
105
|
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
|
99
106
|
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
100
|
-
assertEquals(expectedVerseEleven,
|
107
|
+
assertEquals(expectedVerseEleven, twelveDays.verse(11));
|
101
108
|
}
|
102
109
|
|
103
110
|
@Ignore
|
@@ -107,7 +114,7 @@ public class TwelveDaysTest {
|
|
107
114
|
"twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, " +
|
108
115
|
"eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, " +
|
109
116
|
"four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
110
|
-
assertEquals(expectedVerseTwelve,
|
117
|
+
assertEquals(expectedVerseTwelve, twelveDays.verse(12));
|
111
118
|
}
|
112
119
|
|
113
120
|
@Ignore
|
@@ -119,7 +126,7 @@ public class TwelveDaysTest {
|
|
119
126
|
"and a Partridge in a Pear Tree.\n\n" +
|
120
127
|
"On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, " +
|
121
128
|
"and a Partridge in a Pear Tree.\n";
|
122
|
-
assertEquals(expectedVerseOneToThree,
|
129
|
+
assertEquals(expectedVerseOneToThree, twelveDays.verses(1, 3));
|
123
130
|
}
|
124
131
|
|
125
132
|
@Ignore
|
@@ -167,6 +174,6 @@ public class TwelveDaysTest {
|
|
167
174
|
"eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, " +
|
168
175
|
"seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, " +
|
169
176
|
"three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n";
|
170
|
-
assertEquals(expectedSong,
|
177
|
+
assertEquals(expectedSong, twelveDays.sing());
|
171
178
|
}
|
172
179
|
}
|
data/tracks/perl6/.travis.yml
CHANGED
@@ -3,11 +3,19 @@ import unittest
|
|
3
3
|
from diamond import make_diamond
|
4
4
|
|
5
5
|
|
6
|
+
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
|
7
|
+
|
6
8
|
class DiamondTests(unittest.TestCase):
|
7
|
-
def
|
9
|
+
def test_degenerate_case_with_a_single_row(self):
|
8
10
|
self.assertMultiLineEqual(make_diamond('A'), 'A\n')
|
9
11
|
|
10
|
-
def
|
12
|
+
def test_degenerate_case_with_two_rows(self):
|
13
|
+
result = [' A ',
|
14
|
+
'B B',
|
15
|
+
' A ']
|
16
|
+
self.assertMultiLineEqual(make_diamond('B'), '\n'.join(result) + '\n')
|
17
|
+
|
18
|
+
def test_smallest_non_degenerate_case_with_odd_diamond_side_length(self):
|
11
19
|
result = [' A ',
|
12
20
|
' B B ',
|
13
21
|
'C C',
|
@@ -15,17 +23,69 @@ class DiamondTests(unittest.TestCase):
|
|
15
23
|
' A ']
|
16
24
|
self.assertMultiLineEqual(make_diamond('C'), '\n'.join(result) + '\n')
|
17
25
|
|
18
|
-
def
|
19
|
-
result = ['
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
def test_smallest_non_degenerate_case_with_even_diamond_side_length(self):
|
27
|
+
result = [' A ',
|
28
|
+
' B B ',
|
29
|
+
' C C ',
|
30
|
+
'D D',
|
31
|
+
' C C ',
|
32
|
+
' B B ',
|
33
|
+
' A ']
|
34
|
+
self.assertMultiLineEqual(make_diamond('D'), '\n'.join(result) + '\n')
|
35
|
+
|
36
|
+
def test_largest_possible_diamond(self):
|
37
|
+
result = [' A ',
|
38
|
+
' B B ',
|
39
|
+
' C C ',
|
40
|
+
' D D ',
|
41
|
+
' E E ',
|
42
|
+
' F F ',
|
43
|
+
' G G ',
|
44
|
+
' H H ',
|
45
|
+
' I I ',
|
46
|
+
' J J ',
|
47
|
+
' K K ',
|
48
|
+
' L L ',
|
49
|
+
' M M ',
|
50
|
+
' N N ',
|
51
|
+
' O O ',
|
52
|
+
' P P ',
|
53
|
+
' Q Q ',
|
54
|
+
' R R ',
|
55
|
+
' S S ',
|
56
|
+
' T T ',
|
57
|
+
' U U ',
|
58
|
+
' V V ',
|
59
|
+
' W W ',
|
60
|
+
' X X ',
|
61
|
+
' Y Y ',
|
62
|
+
'Z Z',
|
63
|
+
' Y Y ',
|
64
|
+
' X X ',
|
65
|
+
' W W ',
|
66
|
+
' V V ',
|
67
|
+
' U U ',
|
68
|
+
' T T ',
|
69
|
+
' S S ',
|
70
|
+
' R R ',
|
71
|
+
' Q Q ',
|
72
|
+
' P P ',
|
73
|
+
' O O ',
|
74
|
+
' N N ',
|
75
|
+
' M M ',
|
76
|
+
' L L ',
|
77
|
+
' K K ',
|
78
|
+
' J J ',
|
79
|
+
' I I ',
|
80
|
+
' H H ',
|
81
|
+
' G G ',
|
82
|
+
' F F ',
|
83
|
+
' E E ',
|
84
|
+
' D D ',
|
85
|
+
' C C ',
|
86
|
+
' B B ',
|
87
|
+
' A ']
|
88
|
+
self.assertMultiLineEqual(make_diamond('Z'), '\n'.join(result) + '\n')
|
29
89
|
|
30
90
|
|
31
91
|
if __name__ == '__main__':
|
@@ -76,6 +76,16 @@ class SublistTest(unittest.TestCase):
|
|
76
76
|
multiples_of_15 = list(range(15, 200, 15))
|
77
77
|
self.assertEqual(check_lists(multiples_of_15, multiples_of_3), UNEQUAL)
|
78
78
|
|
79
|
+
def test_double_digits(self):
|
80
|
+
l1 = [1, 0, 1]
|
81
|
+
l2 = [10, 1]
|
82
|
+
self.assertEqual(check_lists(l1, l2), UNEQUAL)
|
83
|
+
|
84
|
+
def test_inner_spaces(self):
|
85
|
+
l1 = ['a c']
|
86
|
+
l2 = ['a', 'c']
|
87
|
+
self.assertEqual(check_lists(l1, l2), UNEQUAL)
|
88
|
+
|
79
89
|
def test_avoid_sets(self):
|
80
90
|
self.assertEqual(check_lists([1, 3], [1, 2, 3]), UNEQUAL)
|
81
91
|
self.assertEqual(check_lists([1, 2, 3], [1, 3]), UNEQUAL)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.8.
|
4
|
+
version: 2.0.8.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -2625,6 +2625,10 @@ files:
|
|
2625
2625
|
- tracks/elixir/exercises/scrabble-score/example.exs
|
2626
2626
|
- tracks/elixir/exercises/scrabble-score/scrabble.exs
|
2627
2627
|
- tracks/elixir/exercises/scrabble-score/scrabble_score_test.exs
|
2628
|
+
- tracks/elixir/exercises/secret-handshake/HINTS.md
|
2629
|
+
- tracks/elixir/exercises/secret-handshake/example.exs
|
2630
|
+
- tracks/elixir/exercises/secret-handshake/secret_handshake.exs
|
2631
|
+
- tracks/elixir/exercises/secret-handshake/secret_handshake_test.exs
|
2628
2632
|
- tracks/elixir/exercises/series/example.exs
|
2629
2633
|
- tracks/elixir/exercises/series/series.exs
|
2630
2634
|
- tracks/elixir/exercises/series/series_test.exs
|
@@ -2637,6 +2641,10 @@ files:
|
|
2637
2641
|
- tracks/elixir/exercises/space-age/example.exs
|
2638
2642
|
- tracks/elixir/exercises/space-age/space_age.exs
|
2639
2643
|
- tracks/elixir/exercises/space-age/space_age_test.exs
|
2644
|
+
- tracks/elixir/exercises/strain/HINTS.md
|
2645
|
+
- tracks/elixir/exercises/strain/example.exs
|
2646
|
+
- tracks/elixir/exercises/strain/strain.exs
|
2647
|
+
- tracks/elixir/exercises/strain/strain_test.exs
|
2640
2648
|
- tracks/elixir/exercises/sublist/example.exs
|
2641
2649
|
- tracks/elixir/exercises/sublist/sublist.exs
|
2642
2650
|
- tracks/elixir/exercises/sublist/sublist_test.exs
|
@@ -6185,7 +6193,6 @@ files:
|
|
6185
6193
|
- tracks/perl5/img/icon.png
|
6186
6194
|
- tracks/perl6/.git
|
6187
6195
|
- tracks/perl6/.gitignore
|
6188
|
-
- tracks/perl6/.gitmodules
|
6189
6196
|
- tracks/perl6/.travis.yml
|
6190
6197
|
- tracks/perl6/LICENSE
|
6191
6198
|
- tracks/perl6/README.md
|
@@ -7363,11 +7370,13 @@ files:
|
|
7363
7370
|
- tracks/rust/docs/RESOURCES.md
|
7364
7371
|
- tracks/rust/docs/TESTS.md
|
7365
7372
|
- tracks/rust/exercises/TRACK_HINTS.md
|
7373
|
+
- tracks/rust/exercises/acronym/.gitignore
|
7366
7374
|
- tracks/rust/exercises/acronym/Cargo.lock
|
7367
7375
|
- tracks/rust/exercises/acronym/Cargo.toml
|
7368
7376
|
- tracks/rust/exercises/acronym/example.rs
|
7369
7377
|
- tracks/rust/exercises/acronym/src/lib.rs
|
7370
7378
|
- tracks/rust/exercises/acronym/tests/acronym.rs
|
7379
|
+
- tracks/rust/exercises/all-your-base/.gitignore
|
7371
7380
|
- tracks/rust/exercises/all-your-base/Cargo.lock
|
7372
7381
|
- tracks/rust/exercises/all-your-base/Cargo.toml
|
7373
7382
|
- tracks/rust/exercises/all-your-base/example.rs
|
@@ -7379,6 +7388,7 @@ files:
|
|
7379
7388
|
- tracks/rust/exercises/allergies/example.rs
|
7380
7389
|
- tracks/rust/exercises/allergies/src/lib.rs
|
7381
7390
|
- tracks/rust/exercises/allergies/tests/allergies.rs
|
7391
|
+
- tracks/rust/exercises/alphametics/.gitignore
|
7382
7392
|
- tracks/rust/exercises/alphametics/Cargo-example.toml
|
7383
7393
|
- tracks/rust/exercises/alphametics/Cargo.lock
|
7384
7394
|
- tracks/rust/exercises/alphametics/Cargo.toml
|
@@ -7391,6 +7401,7 @@ files:
|
|
7391
7401
|
- tracks/rust/exercises/anagram/example.rs
|
7392
7402
|
- tracks/rust/exercises/anagram/src/lib.rs
|
7393
7403
|
- tracks/rust/exercises/anagram/tests/anagram.rs
|
7404
|
+
- tracks/rust/exercises/atbash-cipher/.gitignore
|
7394
7405
|
- tracks/rust/exercises/atbash-cipher/Cargo.lock
|
7395
7406
|
- tracks/rust/exercises/atbash-cipher/Cargo.toml
|
7396
7407
|
- tracks/rust/exercises/atbash-cipher/example.rs
|
@@ -7572,6 +7583,7 @@ files:
|
|
7572
7583
|
- tracks/rust/exercises/phone-number/example.rs
|
7573
7584
|
- tracks/rust/exercises/phone-number/src/lib.rs
|
7574
7585
|
- tracks/rust/exercises/phone-number/tests/phone-number.rs
|
7586
|
+
- tracks/rust/exercises/protein-translation/.gitignore
|
7575
7587
|
- tracks/rust/exercises/protein-translation/Cargo.lock
|
7576
7588
|
- tracks/rust/exercises/protein-translation/Cargo.toml
|
7577
7589
|
- tracks/rust/exercises/protein-translation/example.rs
|
@@ -7589,6 +7601,7 @@ files:
|
|
7589
7601
|
- tracks/rust/exercises/raindrops/example.rs
|
7590
7602
|
- tracks/rust/exercises/raindrops/src/lib.rs
|
7591
7603
|
- tracks/rust/exercises/raindrops/tests/raindrops.rs
|
7604
|
+
- tracks/rust/exercises/react/.gitignore
|
7592
7605
|
- tracks/rust/exercises/react/Cargo.lock
|
7593
7606
|
- tracks/rust/exercises/react/Cargo.toml
|
7594
7607
|
- tracks/rust/exercises/react/example.rs
|
@@ -7624,6 +7637,7 @@ files:
|
|
7624
7637
|
- tracks/rust/exercises/roman-numerals/example.rs
|
7625
7638
|
- tracks/rust/exercises/roman-numerals/src/lib.rs
|
7626
7639
|
- tracks/rust/exercises/roman-numerals/tests/roman-numerals.rs
|
7640
|
+
- tracks/rust/exercises/rotational-cipher/.gitignore
|
7627
7641
|
- tracks/rust/exercises/rotational-cipher/Cargo.lock
|
7628
7642
|
- tracks/rust/exercises/rotational-cipher/Cargo.toml
|
7629
7643
|
- tracks/rust/exercises/rotational-cipher/example.rs
|
data/tracks/perl6/.gitmodules
DELETED