trackler 2.0.8.54 → 2.0.8.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/common/CONTRIBUTING.md +7 -6
- data/fixtures/tracks/animal/config.json +1 -0
- data/fixtures/tracks/animal/exercises/dog/a_test_example_for.animal +1 -0
- data/lib/trackler/implementation.rb +32 -38
- data/lib/trackler/implementations.rb +2 -2
- data/lib/trackler/track.rb +24 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/elixir/config.json +17 -0
- data/tracks/elixir/exercises/bracket-push/bracket_push_test.exs +34 -19
- data/tracks/elixir/exercises/saddle-points/example.exs +1 -1
- data/tracks/elixir/exercises/saddle-points/saddle_points.exs +1 -1
- data/tracks/elixir/exercises/saddle-points/saddle_points_test.exs +10 -10
- data/tracks/elixir/exercises/simple-cipher/example.exs +80 -0
- data/tracks/elixir/exercises/simple-cipher/simple_cipher.exs +49 -0
- data/tracks/elixir/exercises/simple-cipher/simple_cipher_test.exs +89 -0
- data/tracks/elixir/exercises/tournament/HINTS.md +3 -0
- data/tracks/elixir/exercises/tournament/example.exs +81 -0
- data/tracks/elixir/exercises/tournament/tournament.exs +17 -0
- data/tracks/elixir/exercises/tournament/tournament_test.exs +96 -0
- data/tracks/go/exercises/bob/bob.go +2 -2
- data/tracks/go/exercises/clock/clock.go +1 -8
- data/tracks/go/exercises/gigasecond/gigasecond.go +4 -6
- data/tracks/go/exercises/hamming/hamming.go +0 -1
- data/tracks/go/exercises/raindrops/raindrops.go +2 -1
- data/tracks/go/exercises/triangle/triangle.go +1 -2
- data/tracks/java/bin/journey-test.sh +6 -5
- data/tracks/java/exercises/nth-prime/src/example/java/PrimeCalculator.java +1 -5
- data/tracks/java/exercises/rna-transcription/src/test/java/RnaTranscriptionTest.java +5 -5
- data/tracks/pony/.github/stale.yml +0 -0
- data/tracks/pony/.travis.yml +2 -9
- data/tracks/pony/bin/install-deps +15 -8
- data/tracks/pony/bin/test-exercises +2 -0
- data/tracks/pony/config.json +2 -1
- data/tracks/pony/exercises/anagram/example.pony +1 -1
- data/tracks/pony/exercises/anagram/test.pony +2 -2
- data/tracks/pony/exercises/atbash-cipher/example.pony +6 -4
- data/tracks/pony/exercises/atbash-cipher/test.pony +24 -38
- data/tracks/pony/exercises/pascals-triangle/test.pony +3 -3
- data/tracks/pony/exercises/rna-transcription/test.pony +4 -4
- data/tracks/pony/exercises/roman-numerals/example.pony +12 -12
- data/tracks/pony/exercises/roman-numerals/test.pony +18 -18
- data/tracks/purescript/config.json +15 -0
- data/tracks/purescript/exercises/etl/bower.json +17 -0
- data/tracks/purescript/exercises/etl/examples/src/Etl.purs +20 -0
- data/tracks/purescript/exercises/etl/src/Etl.purs +3 -0
- data/tracks/purescript/exercises/etl/test/Main.purs +99 -0
- data/tracks/purescript/exercises/isogram/bower.json +18 -0
- data/tracks/purescript/exercises/isogram/examples/src/Isogram.purs +22 -0
- data/tracks/purescript/exercises/isogram/src/Isogram.purs +4 -0
- data/tracks/purescript/exercises/isogram/test/Main.purs +44 -0
- data/tracks/ruby/README.md +10 -9
- data/tracks/ruby/exercises/anagram/example.tt +1 -1
- data/tracks/ruby/exercises/bowling/example.tt +1 -1
- data/tracks/ruby/exercises/hamming/example.tt +2 -2
- data/tracks/ruby/exercises/luhn/.meta/.version +1 -0
- data/tracks/ruby/exercises/luhn/example.rb +18 -23
- data/tracks/ruby/exercises/luhn/example.tt +18 -0
- data/tracks/ruby/exercises/luhn/luhn_test.rb +60 -27
- data/tracks/ruby/exercises/pig-latin/.meta/.version +1 -0
- data/tracks/ruby/exercises/pig-latin/example.rb +4 -0
- data/tracks/ruby/exercises/pig-latin/example.tt +21 -0
- data/tracks/ruby/exercises/pig-latin/pig_latin_test.rb +73 -24
- data/tracks/ruby/exercises/rna-transcription/example.tt +1 -1
- data/tracks/ruby/lib/anagram_cases.rb +1 -1
- data/tracks/ruby/lib/binary_cases.rb +3 -3
- data/tracks/ruby/lib/bowling_cases.rb +1 -1
- data/tracks/ruby/lib/hamming_cases.rb +1 -1
- data/tracks/ruby/lib/luhn_cases.rb +27 -0
- data/tracks/ruby/lib/pig_latin_cases.rb +20 -0
- data/tracks/ruby/lib/rna_transcription_cases.rb +1 -1
- metadata +25 -3
- data/tracks/go/.github/stale.yml +0 -22
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
|
2
|
+
Code.load_file("simple_cipher.exs", __DIR__)
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
ExUnit.start
|
|
6
|
+
ExUnit.configure trace: true, exclude: :pending
|
|
7
|
+
|
|
8
|
+
defmodule SimpleCipherTest do
|
|
9
|
+
use ExUnit.Case
|
|
10
|
+
|
|
11
|
+
#@tag :pending
|
|
12
|
+
test "encoding with 'a' returns the original text" do
|
|
13
|
+
assert SimpleCipher.encode("a", "a") == "a"
|
|
14
|
+
assert SimpleCipher.encode("b", "a") == "b"
|
|
15
|
+
assert SimpleCipher.encode("c", "a") == "c"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
@tag :pending
|
|
19
|
+
test "encoding with another key returns shifted text" do
|
|
20
|
+
assert SimpleCipher.encode("a", "d") == "d"
|
|
21
|
+
assert SimpleCipher.encode("b", "d") == "e"
|
|
22
|
+
assert SimpleCipher.encode("c", "d") == "f"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
@tag :pending
|
|
26
|
+
test "decoding with 'a' returns the original text" do
|
|
27
|
+
assert SimpleCipher.decode("a", "a") == "a"
|
|
28
|
+
assert SimpleCipher.decode("b", "a") == "b"
|
|
29
|
+
assert SimpleCipher.decode("c", "a") == "c"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
@tag :pending
|
|
33
|
+
test "decoding with another key returns unshifted text" do
|
|
34
|
+
assert SimpleCipher.decode("d", "d") == "a"
|
|
35
|
+
assert SimpleCipher.decode("e", "d") == "b"
|
|
36
|
+
assert SimpleCipher.decode("f", "d") == "c"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@tag :pending
|
|
40
|
+
test "key uses per-letter translation for encoding" do
|
|
41
|
+
key = "abc"
|
|
42
|
+
|
|
43
|
+
assert SimpleCipher.encode("abc", key) == "ace"
|
|
44
|
+
assert SimpleCipher.encode("bcd", key) == "bdf"
|
|
45
|
+
assert SimpleCipher.encode("cde", key) == "ceg"
|
|
46
|
+
assert SimpleCipher.encode("iamapandabear", "dddddddddddddd") == "ldpdsdqgdehdu"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@tag :pending
|
|
50
|
+
test "key uses per-letter translation for decoding" do
|
|
51
|
+
key = "abc"
|
|
52
|
+
|
|
53
|
+
assert SimpleCipher.decode("ace", key) == "abc"
|
|
54
|
+
assert SimpleCipher.decode("bdf", key) == "bcd"
|
|
55
|
+
assert SimpleCipher.decode("ceg", key) == "cde"
|
|
56
|
+
assert SimpleCipher.decode("ldpdsdqgdehdu", "dddddddddddddd") == "iamapandabear"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
@tag :pending
|
|
60
|
+
test "only lowercase a-z are translated, rest are passed through" do
|
|
61
|
+
assert SimpleCipher.encode("this is a test!", "d") == "wklv lv d whvw!"
|
|
62
|
+
assert SimpleCipher.decode("wklv lv d whvw!", "d") == "this is a test!"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@tag :pending
|
|
66
|
+
test "if key is shorter than text, repeat key" do
|
|
67
|
+
assert SimpleCipher.encode("abc", "a") == "abc"
|
|
68
|
+
assert SimpleCipher.encode("abcdefghi", "abc") == "acedfhgik"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
@tag :pending
|
|
72
|
+
test "if key is longer than text, only use as much as needed" do
|
|
73
|
+
key = "somewhatlongkey"
|
|
74
|
+
|
|
75
|
+
assert SimpleCipher.encode("abc", key) == "spo"
|
|
76
|
+
assert SimpleCipher.decode("abc", key) == "inq"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
@tag :pending
|
|
80
|
+
test "if you know both the encoded and decoded text, you can figure out the key" do
|
|
81
|
+
key = "supersecretkey"
|
|
82
|
+
|
|
83
|
+
plaintext = "attackxatxdawn"
|
|
84
|
+
ciphertext = SimpleCipher.encode(plaintext, key)
|
|
85
|
+
|
|
86
|
+
assert SimpleCipher.decode(ciphertext, plaintext) == key
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
defmodule Tournament do
|
|
2
|
+
@stats_header { "Team", "MP", "W", "D", "L", "P" }
|
|
3
|
+
@initial_stats { 0, 0, 0, 0, 0 }
|
|
4
|
+
|
|
5
|
+
@doc """
|
|
6
|
+
Given `input` lines representing two teams and whether the first of them won,
|
|
7
|
+
lost, or reached a draw, separated by semicolons, calculate the statistics
|
|
8
|
+
for each team's number of games played, won, drawn, lost, and total points
|
|
9
|
+
for the season, and return a nicely-formatted string table.
|
|
10
|
+
|
|
11
|
+
A win earns a team 3 points, a draw earns 1 point, and a loss earns nothing.
|
|
12
|
+
|
|
13
|
+
Order the outcome by most total points for the season, and settle ties by
|
|
14
|
+
listing the teams in alphabetical order.
|
|
15
|
+
"""
|
|
16
|
+
@spec tally(input :: list(String.t())) :: String.t()
|
|
17
|
+
def tally(input) do
|
|
18
|
+
%{}
|
|
19
|
+
|> do_tally(input)
|
|
20
|
+
|> Enum.into([], fn {k, v} -> Tuple.insert_at(v, 0, k) end)
|
|
21
|
+
|> Enum.sort(&sort_results/2)
|
|
22
|
+
|> List.insert_at(0, @stats_header)
|
|
23
|
+
|> Enum.map_join("\n", &format_results/1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
defp do_tally(results, []), do: results
|
|
27
|
+
defp do_tally(results, [line | rest]) do
|
|
28
|
+
results
|
|
29
|
+
|> parse_line(line |> String.split(";", trim: true))
|
|
30
|
+
|> do_tally(rest)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
defp parse_line(results, [first, second, "win"]) do
|
|
34
|
+
results |> mark_win(first) |> mark_loss(second)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
defp parse_line(results, [first, second, "draw"]) do
|
|
38
|
+
results |> mark_draw(first) |> mark_draw(second)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
defp parse_line(results, [first, second, "loss"]) do
|
|
42
|
+
results |> mark_loss(first) |> mark_win(second)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
defp parse_line(results, _), do: results
|
|
46
|
+
|
|
47
|
+
defp mark_win(results, team) do
|
|
48
|
+
{ played, wins, draws, lost, points } = Map.get(results, team, @initial_stats)
|
|
49
|
+
|
|
50
|
+
Map.put(results, team, { played + 1, wins + 1, draws, lost, points + 3 })
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
defp mark_draw(results, team) do
|
|
54
|
+
{ played, wins, draws, lost, points } = Map.get(results, team, @initial_stats)
|
|
55
|
+
|
|
56
|
+
Map.put(results, team, { played + 1, wins, draws + 1, lost, points + 1})
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
defp mark_loss(results, team) do
|
|
60
|
+
{ played, wins, draws, lost, points } = Map.get(results, team, @initial_stats)
|
|
61
|
+
|
|
62
|
+
Map.put(results, team, { played + 1, wins, draws, lost + 1, points})
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
defp sort_results({_, _, _, _, _, points_a}, {_, _, _, _, _, points_b}) when points_a > points_b, do: true
|
|
66
|
+
defp sort_results({_, _, _, _, _, points_a}, {_, _, _, _, _, points_b}) when points_a < points_b, do: false
|
|
67
|
+
defp sort_results({name_a, _, _, _, _, _}, {name_b, _, _, _, _, _}) when name_a <= name_b, do: true
|
|
68
|
+
defp sort_results(_, _), do: false
|
|
69
|
+
|
|
70
|
+
defp format_results({name, played, wins, draws, lost, points}) do
|
|
71
|
+
[
|
|
72
|
+
name |> String.pad_trailing(30),
|
|
73
|
+
played |> to_string |> String.pad_leading(2),
|
|
74
|
+
wins |> to_string |> String.pad_leading(2),
|
|
75
|
+
draws |> to_string |> String.pad_leading(2),
|
|
76
|
+
lost |> to_string |> String.pad_leading(2),
|
|
77
|
+
points |> to_string |> String.pad_leading(2)
|
|
78
|
+
] |> Enum.join(" | ")
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
defmodule Tournament do
|
|
2
|
+
@doc """
|
|
3
|
+
Given `input` lines representing two teams and whether the first of them won,
|
|
4
|
+
lost, or reached a draw, separated by semicolons, calculate the statistics
|
|
5
|
+
for each team's number of games played, won, drawn, lost, and total points
|
|
6
|
+
for the season, and return a nicely-formatted string table.
|
|
7
|
+
|
|
8
|
+
A win earns a team 3 points, a draw earns 1 point, and a loss earns nothing.
|
|
9
|
+
|
|
10
|
+
Order the outcome by most total points for the season, and settle ties by
|
|
11
|
+
listing the teams in alphabetical order.
|
|
12
|
+
"""
|
|
13
|
+
@spec tally(input :: list(String.t())) :: String.t()
|
|
14
|
+
def tally(input) do
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
if !System.get_env("EXERCISM_TEST_EXAMPLES") do
|
|
2
|
+
Code.load_file("tournament.exs", __DIR__)
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
ExUnit.start
|
|
6
|
+
ExUnit.configure trace: true, exclude: :pending
|
|
7
|
+
|
|
8
|
+
defmodule TournamentTest do
|
|
9
|
+
use ExUnit.Case
|
|
10
|
+
|
|
11
|
+
#@tag :pending
|
|
12
|
+
test "typical input" do
|
|
13
|
+
input = [
|
|
14
|
+
"Allegoric Alaskans;Blithering Badgers;win",
|
|
15
|
+
"Devastating Donkeys;Courageous Californians;draw",
|
|
16
|
+
"Devastating Donkeys;Allegoric Alaskans;win",
|
|
17
|
+
"Courageous Californians;Blithering Badgers;loss",
|
|
18
|
+
"Blithering Badgers;Devastating Donkeys;loss",
|
|
19
|
+
"Allegoric Alaskans;Courageous Californians;win"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
expected = """
|
|
23
|
+
Team | MP | W | D | L | P
|
|
24
|
+
Devastating Donkeys | 3 | 2 | 1 | 0 | 7
|
|
25
|
+
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
|
|
26
|
+
Blithering Badgers | 3 | 1 | 0 | 2 | 3
|
|
27
|
+
Courageous Californians | 3 | 0 | 1 | 2 | 1
|
|
28
|
+
""" |> String.trim
|
|
29
|
+
|
|
30
|
+
assert Tournament.tally(input) == expected
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@tag :pending
|
|
34
|
+
test "incomplete competition (not all pairs have played)" do
|
|
35
|
+
input = [
|
|
36
|
+
"Allegoric Alaskans;Blithering Badgers;loss",
|
|
37
|
+
"Devastating Donkeys;Allegoric Alaskans;loss",
|
|
38
|
+
"Courageous Californians;Blithering Badgers;draw",
|
|
39
|
+
"Allegoric Alaskans;Courageous Californians;win"
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
expected = """
|
|
43
|
+
Team | MP | W | D | L | P
|
|
44
|
+
Allegoric Alaskans | 3 | 2 | 0 | 1 | 6
|
|
45
|
+
Blithering Badgers | 2 | 1 | 1 | 0 | 4
|
|
46
|
+
Courageous Californians | 2 | 0 | 1 | 1 | 1
|
|
47
|
+
Devastating Donkeys | 1 | 0 | 0 | 1 | 0
|
|
48
|
+
""" |> String.trim
|
|
49
|
+
|
|
50
|
+
assert Tournament.tally(input) == expected
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
@tag :pending
|
|
54
|
+
test "ties broken alphabetically" do
|
|
55
|
+
input = [
|
|
56
|
+
"Courageous Californians;Devastating Donkeys;win",
|
|
57
|
+
"Allegoric Alaskans;Blithering Badgers;win",
|
|
58
|
+
"Devastating Donkeys;Allegoric Alaskans;loss",
|
|
59
|
+
"Courageous Californians;Blithering Badgers;win",
|
|
60
|
+
"Blithering Badgers;Devastating Donkeys;draw",
|
|
61
|
+
"Allegoric Alaskans;Courageous Californians;draw"
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
expected = """
|
|
65
|
+
Team | MP | W | D | L | P
|
|
66
|
+
Allegoric Alaskans | 3 | 2 | 1 | 0 | 7
|
|
67
|
+
Courageous Californians | 3 | 2 | 1 | 0 | 7
|
|
68
|
+
Blithering Badgers | 3 | 0 | 1 | 2 | 1
|
|
69
|
+
Devastating Donkeys | 3 | 0 | 1 | 2 | 1
|
|
70
|
+
""" |> String.trim
|
|
71
|
+
|
|
72
|
+
assert Tournament.tally(input) == expected
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
@tag :pending
|
|
76
|
+
test "mostly invalid lines" do
|
|
77
|
+
# Invalid input lines in an otherwise-valid game still results in valid
|
|
78
|
+
# output.
|
|
79
|
+
input = [
|
|
80
|
+
"",
|
|
81
|
+
"Allegoric Alaskans@Blithering Badgers;draw",
|
|
82
|
+
"Blithering Badgers;Devastating Donkeys;loss",
|
|
83
|
+
"Devastating Donkeys;Courageous Californians;win;5",
|
|
84
|
+
"Courageous Californians;Allegoric Alaskans;los"
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
expected = """
|
|
88
|
+
Team | MP | W | D | L | P
|
|
89
|
+
Devastating Donkeys | 1 | 1 | 0 | 0 | 3
|
|
90
|
+
Blithering Badgers | 1 | 0 | 0 | 1 | 0
|
|
91
|
+
""" |> String.trim
|
|
92
|
+
|
|
93
|
+
assert Tournament.tally(input) == expected
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
package bob
|
|
1
|
+
package bob
|
|
2
2
|
|
|
3
|
-
const testVersion = 2
|
|
3
|
+
const testVersion = 2
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
// Clock stub file
|
|
2
|
-
|
|
3
|
-
// To use the right term, this is the package *clause*.
|
|
4
|
-
// You can document general stuff about the package here if you like.
|
|
5
1
|
package clock
|
|
6
2
|
|
|
7
|
-
// The value of testVersion here must match `targetTestVersion` in the file
|
|
8
|
-
// clock_test.go.
|
|
9
3
|
const testVersion = 4
|
|
10
4
|
|
|
11
|
-
//
|
|
12
|
-
// More details and hints are in clock_test.go.
|
|
5
|
+
// You can find more details and hints in the test file.
|
|
13
6
|
|
|
14
7
|
type Clock // Complete the type definition. Pick a suitable data type.
|
|
15
8
|
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// Package clause.
|
|
2
1
|
package gigasecond
|
|
3
2
|
|
|
4
|
-
//
|
|
5
|
-
|
|
3
|
+
// import path for the time package from the standard library
|
|
4
|
+
import "time"
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
func AddGigasecond(time.Time) time.Time
|
|
6
|
+
const testVersion = 4
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
func AddGigasecond(time.Time) time.Time
|
|
@@ -2,10 +2,9 @@ package triangle
|
|
|
2
2
|
|
|
3
3
|
const testVersion = 3
|
|
4
4
|
|
|
5
|
-
// Code this function.
|
|
6
5
|
func KindFromSides(a, b, c float64) Kind
|
|
7
6
|
|
|
8
|
-
// Notice
|
|
7
|
+
// Notice KindFromSides() returns this type. Pick a suitable data type.
|
|
9
8
|
type Kind
|
|
10
9
|
|
|
11
10
|
// Pick values for the following identifiers used by the test program.
|
|
@@ -143,6 +143,11 @@ make_local_trackler() {
|
|
|
143
143
|
|
|
144
144
|
local xjava=$( pwd )
|
|
145
145
|
pushd ${trackler}
|
|
146
|
+
|
|
147
|
+
# Get the version of Trackler x-api is currently using
|
|
148
|
+
local version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
|
|
149
|
+
|
|
150
|
+
git checkout v${version}
|
|
146
151
|
git submodule init -- common
|
|
147
152
|
git submodule update
|
|
148
153
|
|
|
@@ -152,10 +157,6 @@ make_local_trackler() {
|
|
|
152
157
|
cp ${xjava}/config.json tracks/java
|
|
153
158
|
cp -r ${xjava}/exercises tracks/java
|
|
154
159
|
|
|
155
|
-
# Set the version to that expected by x-api
|
|
156
|
-
version=$( grep -m 1 'trackler' ${xapi_home}/Gemfile.lock | sed 's/.*(//' | sed 's/)//' )
|
|
157
|
-
echo "module Trackler VERSION = \"${version}\" end" > lib/trackler/version.rb
|
|
158
|
-
|
|
159
160
|
gem install bundler
|
|
160
161
|
bundle install
|
|
161
162
|
gem build trackler.gemspec
|
|
@@ -229,7 +230,7 @@ solve_all_exercises() {
|
|
|
229
230
|
gradle compileTestJava
|
|
230
231
|
# Ensure we run all the tests (as delivered, all but the first is @Ignore'd)
|
|
231
232
|
for testfile in `find . -name "*Test.java"`; do
|
|
232
|
-
sed 's/@Ignore//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
|
|
233
|
+
sed 's/@Ignore\(.*\)//' ${testfile} > "${tempfile}" && mv "${tempfile}" "${testfile}"
|
|
233
234
|
done
|
|
234
235
|
gradle test
|
|
235
236
|
popd
|
|
@@ -17,31 +17,31 @@ public class RnaTranscriptionTest {
|
|
|
17
17
|
Assert.assertEquals("", rnaTranscription.ofDna(""));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
@Ignore
|
|
20
|
+
@Ignore("Remove to run test")
|
|
21
21
|
@Test
|
|
22
22
|
public void testRnaTranscriptionOfCytosineIsGuanine() {
|
|
23
23
|
Assert.assertEquals("G", rnaTranscription.ofDna("C"));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
@Ignore
|
|
26
|
+
@Ignore("Remove to run test")
|
|
27
27
|
@Test
|
|
28
28
|
public void testRnaTranscriptionOfGuanineIsCytosine() {
|
|
29
29
|
Assert.assertEquals("C", rnaTranscription.ofDna("G"));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
@Ignore
|
|
32
|
+
@Ignore("Remove to run test")
|
|
33
33
|
@Test
|
|
34
34
|
public void testRnaTranscriptionOfThymineIsAdenine() {
|
|
35
35
|
Assert.assertEquals("A", rnaTranscription.ofDna("T"));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
@Ignore
|
|
38
|
+
@Ignore("Remove to run test")
|
|
39
39
|
@Test
|
|
40
40
|
public void testRnaTranscriptionOfAdenineIsUracil() {
|
|
41
41
|
Assert.assertEquals("U", rnaTranscription.ofDna("A"));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
@Ignore
|
|
44
|
+
@Ignore("Remove to run test")
|
|
45
45
|
@Test
|
|
46
46
|
public void testRnaTranscription() {
|
|
47
47
|
Assert.assertEquals("UGCACCAGAAUU", rnaTranscription.ofDna("ACGTGGTCTTAA"));
|
|
File without changes
|
data/tracks/pony/.travis.yml
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
---
|
|
2
1
|
language: c
|
|
3
|
-
|
|
4
|
-
sudo:
|
|
2
|
+
dist: trusty
|
|
3
|
+
sudo: required
|
|
5
4
|
|
|
6
5
|
install:
|
|
7
|
-
- sudo apt-get update -q
|
|
8
|
-
- sudo apt-get install -y python-software-properties
|
|
9
|
-
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
10
|
-
- sudo apt-get update -q
|
|
11
|
-
- sudo apt-get install -y wget git apt-transport-https g++-5 build-essential zlib1g-dev libncurses5-dev libssl-dev
|
|
12
|
-
|
|
13
6
|
- sudo bash bin/install-deps
|
|
14
7
|
|
|
15
8
|
script:
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
sudo apt-get update -q
|
|
4
|
+
sudo apt-get install -y python-software-properties
|
|
5
|
+
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
|
6
|
+
sudo apt-get update -q
|
|
7
|
+
sudo apt-get install -y \
|
|
8
|
+
wget git apt-transport-https g++-5 build-essential \
|
|
9
|
+
zlib1g-dev libncurses5-dev libssl-dev llvm-3.8
|
|
10
|
+
|
|
11
|
+
# Install pcre2 (uncomment if regex package is ever used)
|
|
12
|
+
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.bz2
|
|
13
|
+
# tar -xjvf pcre2-10.21.tar.bz2
|
|
14
|
+
# cd pcre2-10.21 && ./configure --prefix=/usr && make && sudo make install && cd -
|
|
15
|
+
# rm -r pcre2-10.21
|
|
8
16
|
|
|
9
17
|
# Insall ponyc
|
|
10
|
-
|
|
11
|
-
sudo
|
|
12
|
-
sudo apt-get install -y --force-yes ponyc-release
|
|
18
|
+
git clone "https://github.com/ponylang/ponyc"
|
|
19
|
+
cd ponyc && make && sudo make install && cd -
|
data/tracks/pony/config.json
CHANGED
|
@@ -11,7 +11,7 @@ primitive Anagram
|
|
|
11
11
|
let lower': String = s.lower()
|
|
12
12
|
(lower != lower') and (sorted == Anagram._strsort(lower'))
|
|
13
13
|
})
|
|
14
|
-
.collect
|
|
14
|
+
.collect(Array[String])
|
|
15
15
|
|
|
16
16
|
fun _strsort(s: String): String =>
|
|
17
17
|
String.from_array(recover Sort[Array[U8], U8](s.array().clone()) end)
|
|
@@ -11,7 +11,7 @@ class iso _AnagramTest is UnitTest
|
|
|
11
11
|
fun name(): String => "anagram/Anagram"
|
|
12
12
|
|
|
13
13
|
fun apply(h: TestHelper) =>
|
|
14
|
-
let anagrams = ["banana"
|
|
14
|
+
let anagrams = ["banana"; "bob"; "sent"; "sale"; "ales"]
|
|
15
15
|
let empty = Array[String]
|
|
16
16
|
|
|
17
17
|
// Anagram should return an empty array if there are no anagrams
|
|
@@ -25,4 +25,4 @@ class iso _AnagramTest is UnitTest
|
|
|
25
25
|
// Anagram should be case insensitive
|
|
26
26
|
h.assert_array_eq[String](["sent"], Anagram("nETs", anagrams))
|
|
27
27
|
// Anagram should return multiple anagrams
|
|
28
|
-
h.assert_array_eq[String](["sale"
|
|
28
|
+
h.assert_array_eq[String](["sale"; "ales"], Anagram("seal", anagrams))
|
|
@@ -34,7 +34,9 @@ primitive Atbash
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
fun decode(input: String): String iso^ =>
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
recover
|
|
38
|
+
Iter[U8](input.values())
|
|
39
|
+
.filter({(c: U8): Bool => c != ' '})
|
|
40
|
+
.map[U8](this~_transpose())
|
|
41
|
+
.collect[String ref](String)
|
|
42
|
+
end
|
|
@@ -13,31 +13,22 @@ class iso _TestAtbashEncode is UnitTest
|
|
|
13
13
|
|
|
14
14
|
fun apply(h: TestHelper) =>
|
|
15
15
|
let tests = [
|
|
16
|
-
(
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"Testing,1 2 3, testing.",
|
|
33
|
-
"gvhgr mt123 gvhgr mt"
|
|
34
|
-
),(
|
|
35
|
-
"Truth is fiction.",
|
|
36
|
-
"gifgs rhurx grlm"
|
|
37
|
-
),(
|
|
38
|
-
"The quick brown fox jumps over the lazy dog.",
|
|
39
|
-
"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"
|
|
40
|
-
)
|
|
16
|
+
("yes",
|
|
17
|
+
"bvh")
|
|
18
|
+
("no",
|
|
19
|
+
"ml")
|
|
20
|
+
("OMG",
|
|
21
|
+
"lnt")
|
|
22
|
+
("O M G",
|
|
23
|
+
"lnt")
|
|
24
|
+
("mindblowingly",
|
|
25
|
+
"nrmwy oldrm tob")
|
|
26
|
+
("Testing,1 2 3, testing.",
|
|
27
|
+
"gvhgr mt123 gvhgr mt")
|
|
28
|
+
("Truth is fiction.",
|
|
29
|
+
"gifgs rhurx grlm")
|
|
30
|
+
("The quick brown fox jumps over the lazy dog.",
|
|
31
|
+
"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt")
|
|
41
32
|
]
|
|
42
33
|
for (input, expected) in tests.values() do
|
|
43
34
|
h.assert_eq[String](Atbash.encode(input), expected)
|
|
@@ -48,19 +39,14 @@ class iso _TestAtbashDecode is UnitTest
|
|
|
48
39
|
|
|
49
40
|
fun apply(h: TestHelper) =>
|
|
50
41
|
let tests = [
|
|
51
|
-
(
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
"testing123testing"
|
|
60
|
-
),(
|
|
61
|
-
"gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt",
|
|
62
|
-
"thequickbrownfoxjumpsoverthelazydog"
|
|
63
|
-
)
|
|
42
|
+
("vcvix rhn",
|
|
43
|
+
"exercism")
|
|
44
|
+
("zmlyh gzxov rhlug vmzhg vkkrm thglm v",
|
|
45
|
+
"anobstacleisoftenasteppingstone")
|
|
46
|
+
("gvhgr mt123 gvhgr mt",
|
|
47
|
+
"testing123testing")
|
|
48
|
+
("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt",
|
|
49
|
+
"thequickbrownfoxjumpsoverthelazydog")
|
|
64
50
|
]
|
|
65
51
|
for (input, expected) in tests.values() do
|
|
66
52
|
h.assert_eq[String](Atbash.decode(input), expected)
|
|
@@ -14,9 +14,9 @@ class iso _TestPascalsTriangle is UnitTest
|
|
|
14
14
|
fun apply(h: TestHelper) ? =>
|
|
15
15
|
assert_rows_eq(h, 0, Array[Array[USize]])
|
|
16
16
|
assert_rows_eq(h, 1, [[1]])
|
|
17
|
-
assert_rows_eq(h, 2, [[1]
|
|
18
|
-
assert_rows_eq(h, 3, [[1]
|
|
19
|
-
assert_rows_eq(h, 4, [[1]
|
|
17
|
+
assert_rows_eq(h, 2, [[1]; [1; 1]])
|
|
18
|
+
assert_rows_eq(h, 3, [[1]; [1; 1]; [1; 2; 1]])
|
|
19
|
+
assert_rows_eq(h, 4, [[1]; [1; 1]; [1; 2; 1]; [1; 3; 3; 1]])
|
|
20
20
|
|
|
21
21
|
fun assert_rows_eq(
|
|
22
22
|
h: TestHelper,
|
|
@@ -13,13 +13,13 @@ class iso _TestRNATrancription is UnitTest
|
|
|
13
13
|
fun apply(h: TestHelper) ? =>
|
|
14
14
|
let tests = [
|
|
15
15
|
// rna complement of cytosine is guanine
|
|
16
|
-
("C", "G")
|
|
16
|
+
("C", "G")
|
|
17
17
|
// rna complement of guanine is cytosine
|
|
18
|
-
("G", "C")
|
|
18
|
+
("G", "C")
|
|
19
19
|
// rna complement of thymine is adenine
|
|
20
|
-
("T", "A")
|
|
20
|
+
("T", "A")
|
|
21
21
|
// rna complement of adenine is uracil
|
|
22
|
-
("A", "U")
|
|
22
|
+
("A", "U")
|
|
23
23
|
// rna complement
|
|
24
24
|
("ACGTGGTCTTAA", "UGCACCAGAAUU")
|
|
25
25
|
]
|