trackler 2.0.0.1 → 2.0.0.2
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/bin/bump-content +3 -1
- data/bin/verify-metadata +2 -2
- data/common/exercises/alphametics/canonical-data.json +19 -9
- data/common/exercises/food-chain/canonical-data.json +7 -1
- data/common/exercises/grains/canonical-data.json +66 -0
- data/common/exercises/raindrops/description.md +4 -5
- data/common/exercises/triangle/canonical-data.json +81 -54
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/config.json +26 -19
- data/tracks/c/exercises/allergies/makefile +15 -0
- data/tracks/c/exercises/allergies/src/allergies.h +21 -0
- data/tracks/c/exercises/allergies/src/example.c +32 -0
- data/tracks/c/exercises/allergies/src/example.h +26 -0
- data/tracks/c/exercises/allergies/test/test_allergies.c +203 -0
- data/tracks/c/exercises/allergies/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/allergies/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/allergies/test/vendor/unity_internals.h +701 -0
- data/tracks/c/exercises/atbash-cipher/makefile +16 -0
- data/tracks/c/exercises/atbash-cipher/src/example.c +71 -0
- data/tracks/c/exercises/atbash-cipher/src/example.h +7 -0
- data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +113 -0
- data/tracks/c/exercises/atbash-cipher/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/atbash-cipher/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/atbash-cipher/test/vendor/unity_internals.h +701 -0
- data/tracks/c/exercises/phone-number/makefile +16 -0
- data/tracks/c/exercises/phone-number/src/example.c +66 -0
- data/tracks/c/exercises/phone-number/src/example.h +8 -0
- data/tracks/c/exercises/phone-number/test/test_phone_number.c +108 -0
- data/tracks/c/exercises/phone-number/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/phone-number/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/phone-number/test/vendor/unity_internals.h +701 -0
- data/tracks/csharp/config.json +8 -0
- data/tracks/csharp/exercises/bowling/BowlingTest.cs +188 -33
- data/tracks/csharp/exercises/bowling/Example.cs +38 -9
- data/tracks/csharp/exercises/rectangles/Example.cs +91 -0
- data/tracks/csharp/exercises/rectangles/RectanglesTest.cs +133 -0
- data/tracks/elisp/docs/INSTALLATION.org +1 -1
- data/tracks/elixir/config.json +8 -66
- data/tracks/elixir/docs/LEARNING.md +1 -1
- data/tracks/elixir/exercises/diamond/diamond_test.exs +12 -12
- data/tracks/elixir/exercises/grep/example.exs +92 -0
- data/tracks/elixir/exercises/grep/grep.exs +6 -0
- data/tracks/elixir/exercises/grep/grep_test.exs +259 -0
- data/tracks/elixir/exercises/markdown/markdown.exs +59 -2
- data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +4 -4
- data/tracks/elixir/exercises/phone-number/phone_number_test.exs +5 -0
- data/tracks/fsharp/exercises/bowling/BowlingTest.fs +158 -43
- data/tracks/fsharp/exercises/bowling/Example.fs +53 -24
- data/tracks/go/config.json +5 -0
- data/tracks/go/exercises/diamond/diamond_test.go +227 -0
- data/tracks/go/exercises/diamond/example.go +47 -0
- data/tracks/go/exercises/food-chain/example.go +1 -1
- data/tracks/go/exercises/food-chain/food_chain_test.go +30 -6
- data/tracks/go/exercises/nucleotide-count/example.go +21 -8
- data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +45 -37
- data/tracks/haskell/exercises/anagram/test/Tests.hs +1 -11
- data/tracks/java/bin/journey-test.sh +165 -128
- data/tracks/java/docs/ABOUT.md +5 -8
- data/tracks/java/exercises/hello-world/build.gradle +0 -6
- data/tracks/java/exercises/hello-world/src/test/java/HelloWorldTest.java +0 -1
- data/tracks/java/exercises/meetup/build.gradle +0 -1
- data/tracks/java/exercises/meetup/src/example/java/Meetup.java +9 -7
- data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +185 -188
- data/tracks/lua/config.json +0 -73
- data/tracks/lua/exercises/bowling/bowling_spec.lua +92 -48
- data/tracks/lua/exercises/bowling/example.lua +4 -1
- data/tracks/objective-c/config.json +9 -30
- data/tracks/objective-c/exercises/pangram/PangramExample.h +7 -0
- data/tracks/objective-c/exercises/pangram/PangramExample.m +21 -0
- data/tracks/objective-c/exercises/pangram/PangramTest.m +51 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
- data/tracks/ocaml/README.md +46 -1
- data/tracks/ocaml/SETUP.md +21 -2
- data/tracks/ocaml/config.json +48 -78
- data/tracks/perl5/README.md +15 -8
- data/tracks/perl5/testall.pl +5 -5
- data/tracks/php/config.json +26 -34
- data/tracks/php/docs/ABOUT.md +15 -0
- data/tracks/php/exercises/allergies/allergies_test.php +121 -0
- data/tracks/php/exercises/allergies/example.php +64 -0
- data/tracks/php/exercises/etl/etl_test.php +52 -0
- data/tracks/php/exercises/etl/example.php +12 -0
- data/tracks/php/exercises/nucleotide-count/example.php +25 -0
- data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +36 -0
- data/tracks/php/exercises/pig-latin/example.php +25 -29
- data/tracks/php/exercises/pig-latin/pig-latin_test.php +26 -19
- data/tracks/php/exercises/space-age/example.php +65 -0
- data/tracks/php/exercises/space-age/space-age_test.php +70 -0
- data/tracks/php/exercises/triangle/example.php +43 -0
- data/tracks/php/exercises/triangle/triangle_test.php +140 -0
- data/tracks/pony/exercises/anagram/example.pony +6 -6
- data/tracks/pony/exercises/anagram/test.pony +3 -4
- data/tracks/pony/exercises/bob/test.pony +23 -23
- data/tracks/pony/exercises/difference-of-squares/test.pony +11 -11
- data/tracks/pony/exercises/hamming/example.pony +3 -3
- data/tracks/pony/exercises/hamming/test.pony +16 -16
- data/tracks/pony/exercises/hello-world/test.pony +5 -4
- data/tracks/pony/exercises/leap/test.pony +8 -8
- data/tracks/python/config.json +18 -0
- data/tracks/python/exercises/diamond/diamond_test.py +33 -0
- data/tracks/python/exercises/diamond/example.py +15 -0
- data/tracks/python/exercises/linked-list/example.py +47 -0
- data/tracks/python/exercises/linked-list/linked_list.py +13 -0
- data/tracks/python/exercises/linked-list/linked_list_test.py +49 -0
- data/tracks/python/exercises/list-ops/example.py +55 -0
- data/tracks/python/exercises/list-ops/list_ops.py +38 -0
- data/tracks/python/exercises/list-ops/list_ops_test.py +136 -0
- data/tracks/ruby/bin/generate +22 -2
- data/tracks/ruby/config.json +12 -83
- data/tracks/ruby/exercises/allergies/allergies_test.rb +0 -1
- data/tracks/ruby/exercises/atbash-cipher/atbash_cipher_test.rb +0 -1
- data/tracks/ruby/exercises/beer-song/beer_song_test.rb +1 -2
- data/tracks/ruby/exercises/binary/example.rb +0 -1
- data/tracks/ruby/exercises/binary-search-tree/binary_search_tree_test.rb +1 -1
- data/tracks/ruby/exercises/bowling/.version +1 -0
- data/tracks/ruby/exercises/bowling/bowling_test.rb +109 -133
- data/tracks/ruby/exercises/bowling/example.rb +7 -7
- data/tracks/ruby/exercises/bowling/example.tt +27 -0
- data/tracks/ruby/exercises/circular-buffer/circular_buffer_test.rb +0 -2
- data/tracks/ruby/exercises/clock/example.rb +0 -2
- data/tracks/ruby/exercises/connect/connect_test.rb +0 -1
- data/tracks/ruby/exercises/custom-set/custom_set_test.rb +0 -1
- data/tracks/ruby/exercises/diamond/diamond_test.rb +0 -1
- data/tracks/ruby/exercises/etl/etl_test.rb +1 -1
- data/tracks/ruby/exercises/house/house_test.rb +0 -1
- data/tracks/ruby/exercises/isogram/isogram_test.rb +2 -2
- data/tracks/ruby/exercises/largest-series-product/example.tt +0 -3
- data/tracks/ruby/exercises/largest-series-product/largest_series_product_test.rb +0 -4
- data/tracks/ruby/exercises/linked-list/linked_list_test.rb +1 -1
- data/tracks/ruby/exercises/meetup/meetup_test.rb +0 -1
- data/tracks/ruby/exercises/nth-prime/example.tt +0 -2
- data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +0 -2
- data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +1 -2
- data/tracks/ruby/exercises/protein-translation/protein_translation_test.rb +0 -1
- data/tracks/ruby/exercises/proverb/proverb_test.rb +1 -3
- data/tracks/ruby/exercises/queen-attack/example.rb +3 -1
- data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +34 -8
- data/tracks/ruby/exercises/robot-simulator/robot_simulator_test.rb +1 -1
- data/tracks/ruby/exercises/strain/strain_test.rb +2 -2
- data/tracks/ruby/exercises/tournament/.version +1 -0
- data/tracks/ruby/exercises/tournament/example.rb +54 -0
- data/tracks/ruby/exercises/tournament/example.tt +23 -0
- data/tracks/ruby/exercises/tournament/tournament_test.rb +92 -0
- data/tracks/ruby/exercises/transpose/.version +1 -0
- data/tracks/ruby/exercises/transpose/example.rb +14 -0
- data/tracks/ruby/exercises/transpose/example.tt +22 -0
- data/tracks/ruby/exercises/transpose/transpose_test.rb +303 -0
- data/tracks/ruby/lib/bowling_cases.rb +46 -0
- data/tracks/ruby/lib/isogram_cases.rb +1 -1
- data/tracks/ruby/lib/tournament_cases.rb +45 -0
- data/tracks/ruby/lib/transpose_cases.rb +45 -0
- data/tracks/rust/config.json +2 -0
- data/tracks/rust/exercises/bowling/.gitignore +7 -0
- data/tracks/rust/exercises/bowling/Cargo.toml +3 -0
- data/tracks/rust/exercises/bowling/example.rs +134 -0
- data/tracks/rust/exercises/bowling/tests/bowling.rs +373 -0
- data/tracks/rust/exercises/grains/.gitignore +7 -0
- data/tracks/rust/exercises/grains/Cargo.toml +3 -0
- data/tracks/rust/exercises/grains/example.rs +11 -0
- data/tracks/rust/exercises/grains/src/lib.rs +7 -0
- data/tracks/rust/exercises/grains/tests/grains.rs +63 -0
- data/tracks/rust/problems.md +2 -0
- data/tracks/scala/README.md +38 -0
- data/tracks/scala/config.json +20 -74
- data/tracks/scala/exercises/accumulate/src/test/scala/accumulate_test.scala +4 -0
- data/tracks/scala/exercises/allergies/src/test/scala/allergies_test.scala +11 -0
- data/tracks/scala/exercises/alphametics/build.sbt +6 -0
- data/tracks/scala/exercises/alphametics/example.scala +125 -0
- data/tracks/scala/exercises/alphametics/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +62 -0
- data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +8 -0
- data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +4 -0
- data/tracks/scala/exercises/binary/src/test/scala/binary_test.scala +13 -0
- data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +11 -0
- data/tracks/scala/exercises/bowling/Example.scala +116 -0
- data/tracks/scala/exercises/bowling/build.sbt +3 -0
- data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +11 -0
- data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +237 -0
- data/tracks/scala/exercises/clock/src/test/scala/ClockTest.scala +50 -0
- data/tracks/scala/exercises/connect/README.md +17 -0
- data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +7 -0
- data/tracks/scala/exercises/crypto-square/src/test/scala/{CrytpoSquareTest.scala → CryptoSquareTest.scala} +9 -0
- data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +36 -0
- data/tracks/scala/exercises/difference-of-squares/src/test/scala/squares_test.scala +8 -0
- data/tracks/scala/exercises/forth/src/test/scala/ForthTest.scala +22 -0
- data/tracks/scala/exercises/hexadecimal/src/test/scala/HexadecimalTest.scala +8 -0
- data/tracks/scala/exercises/kindergarten-garden/src/test/scala/GardenTest.scala +5 -0
- data/tracks/scala/exercises/largest-series-product/src/test/scala/SeriesTest.scala +2 -0
- data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +4 -0
- data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +4 -0
- data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +2 -0
- data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +6 -0
- data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +5 -0
- data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +15 -0
- data/tracks/scala/exercises/octal/src/test/scala/OctalTest.scala +7 -0
- data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +8 -0
- data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +5 -0
- data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +4 -0
- data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +3 -0
- data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +5 -0
- data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotTest.scala +16 -8
- data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +34 -17
- data/tracks/scala/exercises/scrabble-score/src/test/scala/scrabble_score_test.scala +6 -0
- data/tracks/scala/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala +18 -9
- data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +4 -2
- data/tracks/scala/exercises/sieve/src/test/scala/SieveTest.scala +8 -4
- data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +17 -9
- data/tracks/scala/exercises/sublist/src/test/scala/sublist_test.scala +17 -0
- data/tracks/scala/exercises/trinary/src/test/scala/TrinaryTest.scala +14 -7
- data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +28 -14
- data/tracks/scala/project/Build.scala +3 -3
- data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +57 -0
- data/tracks/sml/config.json +41 -6
- data/tracks/sml/exercises/flatten-array/example.sml +6 -0
- data/tracks/sml/exercises/flatten-array/test_flatten_array.sml +10 -0
- data/tracks/sml/exercises/nth-prime/example.sml +46 -0
- data/tracks/sml/exercises/nth-prime/test_nth_prime.sml +14 -0
- data/tracks/sml/exercises/raindrops/example.sml +9 -0
- data/tracks/sml/exercises/raindrops/raindrops.sml +2 -0
- data/tracks/sml/exercises/raindrops/test_raindrops.sml +95 -0
- data/tracks/swift/config.json +269 -328
- data/tracks/swift/exercises/pangram/PangramExample.swift +17 -0
- data/tracks/swift/exercises/pangram/PangramTest.swift +43 -0
- data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +16 -0
- metadata +95 -3
|
@@ -5,11 +5,13 @@ class SieveTest extends FunSuite with Matchers {
|
|
|
5
5
|
Sieve.primesUpTo(10) should be (List(2, 3, 5, 7))
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
test("primes up to 11") {
|
|
8
|
+
test("primes up to 11") {
|
|
9
|
+
pending
|
|
9
10
|
Sieve.primesUpTo(11) should be (List(2, 3, 5, 7, 11))
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
test("primes up to 1000") {
|
|
13
|
+
test("primes up to 1000") {
|
|
14
|
+
pending
|
|
13
15
|
Sieve.primesUpTo(1000) should be (List(
|
|
14
16
|
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
|
|
15
17
|
73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
|
|
@@ -24,11 +26,13 @@ class SieveTest extends FunSuite with Matchers {
|
|
|
24
26
|
919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997))
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
test("first thousand primes") {
|
|
29
|
+
test("first thousand primes") {
|
|
30
|
+
pending
|
|
28
31
|
Sieve.primesUpTo(7919).size should be (1000)
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
test("edge cases") {
|
|
34
|
+
test("edge cases") {
|
|
35
|
+
pending
|
|
32
36
|
Sieve.primesUpTo(1) should be (List())
|
|
33
37
|
Sieve.primesUpTo(2) should be (List(2))
|
|
34
38
|
}
|
|
@@ -12,43 +12,51 @@ class CipherTest extends FunSuite with Matchers {
|
|
|
12
12
|
cipher.decode(cipher.key.substring(0, 10)) should be ("aaaaaaaaaa")
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
test("Invalid key - contains caps") {
|
|
16
|
-
|
|
15
|
+
test("Invalid key - contains caps") {
|
|
16
|
+
pending
|
|
17
|
+
intercept[IllegalArgumentException] {
|
|
17
18
|
Cipher(Some("ABCD"))
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
test("Invalid key - contains numerics") {
|
|
22
|
+
test("Invalid key - contains numerics") {
|
|
23
|
+
pending
|
|
22
24
|
intercept[IllegalArgumentException] {
|
|
23
25
|
Cipher(Some("123"))
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
test("Invalid key - is empty") {
|
|
29
|
+
test("Invalid key - is empty") {
|
|
30
|
+
pending
|
|
28
31
|
intercept[IllegalArgumentException] {
|
|
29
32
|
Cipher(Some(""))
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
test("Substitution cipher - can encode") {
|
|
36
|
+
test("Substitution cipher - can encode") {
|
|
37
|
+
pending
|
|
34
38
|
Cipher(Some("abcdefghij")).encode("aaaaaaaaaa") should be ("abcdefghij")
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
test("Substitution cipher - can decode") {
|
|
41
|
+
test("Substitution cipher - can decode") {
|
|
42
|
+
pending
|
|
38
43
|
Cipher(Some("abcdefghij")).decode("abcdefghij") should be ("aaaaaaaaaa")
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
test("Substitution cipher - is reversible") {
|
|
46
|
+
test("Substitution cipher - is reversible") {
|
|
47
|
+
pending
|
|
42
48
|
val cipher = Cipher(Some("abcdefghij"))
|
|
43
49
|
cipher.decode(cipher.encode("abcdefghij")) should be ("abcdefghij")
|
|
44
50
|
}
|
|
45
51
|
|
|
46
|
-
test("Substitution cipher - can double shift") {
|
|
52
|
+
test("Substitution cipher - can double shift") {
|
|
53
|
+
pending
|
|
47
54
|
val cipher = Cipher(Some("iamapandabear"))
|
|
48
55
|
cipher.encode("iamapandabear") should be ("qayaeaagaciai")
|
|
49
56
|
}
|
|
50
57
|
|
|
51
|
-
test("Substitution cipher - can wrap") {
|
|
58
|
+
test("Substitution cipher - can wrap") {
|
|
59
|
+
pending
|
|
52
60
|
Cipher(Some("abcdefghij")).encode("zzzzzzzzzz") should be ("zabcdefghi")
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -6,75 +6,92 @@ class SublistSpecs extends FunSuite with Matchers {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
test("empty is a sublist of anything") {
|
|
9
|
+
pending
|
|
9
10
|
Sublist.sublist(List(), List('a', 's', 'd', 'f')) should be (Sublist.Sublist)
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
test("anything is a superlist of empty") {
|
|
14
|
+
pending
|
|
13
15
|
Sublist.sublist(List('a', 's', 'd', 'f'), List()) should be (Sublist.Superlist)
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
test("List(1) is not List(2)") {
|
|
19
|
+
pending
|
|
17
20
|
Sublist.sublist(List(1), List(2)) should be (Sublist.Unequal)
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
test("compare larger equal lists") {
|
|
24
|
+
pending
|
|
21
25
|
val xs = List.fill(1000)("x")
|
|
22
26
|
Sublist.sublist(xs, xs) should be (Sublist.Equal)
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
test("sublist at start") {
|
|
30
|
+
pending
|
|
26
31
|
Sublist.sublist(List(1, 2, 3), List(1, 2, 3, 4, 5)) should be (Sublist.Sublist)
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
test("sublist in middle") {
|
|
35
|
+
pending
|
|
30
36
|
Sublist.sublist(List(4, 3, 2), List(5, 4, 3, 2, 1)) should be (Sublist.Sublist)
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
test("sublist at end") {
|
|
40
|
+
pending
|
|
34
41
|
Sublist.sublist(List(3, 4, 5), List(1, 2, 3, 4, 5)) should be (Sublist.Sublist)
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
test("partially matching sublist at start") {
|
|
45
|
+
pending
|
|
38
46
|
Sublist.sublist(List(1, 1, 2), List(1, 1, 1, 2)) should be (Sublist.Sublist)
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
test("sublist early in huge list") {
|
|
50
|
+
pending
|
|
42
51
|
val xs = List.range(1, 1000000)
|
|
43
52
|
Sublist.sublist(List(3, 4, 5), xs) should be (Sublist.Sublist)
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
test("huge sublist not in huge list") {
|
|
56
|
+
pending
|
|
47
57
|
val l1 = List.range(10, 1000001)
|
|
48
58
|
val l2 = List.range(1, 1000000)
|
|
49
59
|
Sublist.sublist(l1, l2) should be (Sublist.Unequal)
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
test("superlist at start") {
|
|
63
|
+
pending
|
|
53
64
|
Sublist.sublist(List(1, 2, 3, 4, 5), List(1, 2, 3)) should be (Sublist.Superlist)
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
test("superlist in middle") {
|
|
68
|
+
pending
|
|
57
69
|
Sublist.sublist(List(5, 4, 3, 2, 1), List(4, 3, 2)) should be (Sublist.Superlist)
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
test("superlist at end") {
|
|
73
|
+
pending
|
|
61
74
|
Sublist.sublist(List(1, 2, 3, 4, 5), List(3, 4, 5)) should be (Sublist.Superlist)
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
test("partially matching superlist at start") {
|
|
78
|
+
pending
|
|
65
79
|
Sublist.sublist(List(1, 1, 1, 2), List(1, 1, 2)) should be (Sublist.Superlist)
|
|
66
80
|
}
|
|
67
81
|
|
|
68
82
|
test("superlist early in huge list") {
|
|
83
|
+
pending
|
|
69
84
|
val l1 = List.range(1, 1000000)
|
|
70
85
|
Sublist.sublist(l1, List(3, 4, 5)) should be (Sublist.Superlist)
|
|
71
86
|
}
|
|
72
87
|
|
|
73
88
|
test("recurring values sublist") {
|
|
89
|
+
pending
|
|
74
90
|
Sublist.sublist(List(1, 2, 1, 2, 3), List(1, 2, 3, 1, 2, 1, 2, 3, 2, 1)) should be (Sublist.Sublist)
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
test("recurring values unequal") {
|
|
94
|
+
pending
|
|
78
95
|
Sublist.sublist(List(1, 2, 1, 2, 3), List(1, 2, 3, 1, 2, 3, 2, 3, 2, 1)) should be (Sublist.Unequal)
|
|
79
96
|
}
|
|
80
97
|
}
|
|
@@ -7,7 +7,8 @@ class TrinaryTest extends FlatSpec with Matchers {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
it should "invalid trinary should error" in {
|
|
10
|
+
it should "invalid trinary should error" in {
|
|
11
|
+
pending
|
|
11
12
|
intercept[IllegalArgumentException] {
|
|
12
13
|
Trinary.trinaryToInt("1239")
|
|
13
14
|
}
|
|
@@ -21,33 +22,39 @@ class TrinaryTest extends FlatSpec with Matchers {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
it should "handle zeros" in {
|
|
25
|
+
it should "handle zeros" in {
|
|
26
|
+
pending
|
|
25
27
|
Trinary.trinaryToInt("0") should equal(0)
|
|
26
28
|
Trinary.trinaryToInt("00000000") should equal(0)
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
it should "handle single digit" in {
|
|
31
|
+
it should "handle single digit" in {
|
|
32
|
+
pending
|
|
30
33
|
Trinary.trinaryToInt("2") should equal(2)
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
it should "handle multiple digits" in {
|
|
36
|
+
it should "handle multiple digits" in {
|
|
37
|
+
pending
|
|
34
38
|
Trinary.trinaryToInt("10") should equal(3)
|
|
35
39
|
Trinary.trinaryToInt("12") should equal(5)
|
|
36
40
|
Trinary.trinaryToInt("222") should equal(26)
|
|
37
41
|
Trinary.trinaryToInt("1122000120") should equal(32091)
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
it should "handle Int 0" in {
|
|
44
|
+
it should "handle Int 0" in {
|
|
45
|
+
pending
|
|
41
46
|
Trinary.intToTrinary(0) should equal("0")
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
it should "handle Int to multi digit trinary" in {
|
|
49
|
+
it should "handle Int to multi digit trinary" in {
|
|
50
|
+
pending
|
|
45
51
|
Trinary.intToTrinary(4) should equal("11")
|
|
46
52
|
Trinary.intToTrinary(26) should equal("222")
|
|
47
53
|
Trinary.intToTrinary(32091) should equal("1122000120")
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
it should "handle Int to trinary with trailing zeros" in {
|
|
56
|
+
it should "handle Int to trinary with trailing zeros" in {
|
|
57
|
+
pending
|
|
51
58
|
Trinary.intToTrinary(3) should equal("10")
|
|
52
59
|
}
|
|
53
60
|
}
|
|
@@ -6,62 +6,76 @@ class WordProblemTest extends FlatSpec with Matchers {
|
|
|
6
6
|
WordProblem("What is 1 plus 1?") should equal(Some(2))
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
it should "handle addition with negative numbers" in {
|
|
9
|
+
it should "handle addition with negative numbers" in {
|
|
10
|
+
pending
|
|
10
11
|
WordProblem("What is -1 plus -10?") should equal(Some(-11))
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
it should "handle repeated addition" in {
|
|
14
|
+
it should "handle repeated addition" in {
|
|
15
|
+
pending
|
|
14
16
|
WordProblem("What is 1 plus 1 plus 1?") should equal(Some(3))
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
it should "handle simple subtraction" in {
|
|
19
|
+
it should "handle simple subtraction" in {
|
|
20
|
+
pending
|
|
18
21
|
WordProblem("What is 1 minus 1?") should equal(Some(0))
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
it should "handle subtraction with negative numbers" in {
|
|
24
|
+
it should "handle subtraction with negative numbers" in {
|
|
25
|
+
pending
|
|
22
26
|
WordProblem("What is 4 minus -12?") should equal(Some(16))
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
it should "handle repeated subtraction" in {
|
|
29
|
+
it should "handle repeated subtraction" in {
|
|
30
|
+
pending
|
|
26
31
|
WordProblem("What is 20 minus 4 minus 13?") should equal(Some(3))
|
|
27
32
|
}
|
|
28
33
|
|
|
29
|
-
it should "handle simple multiplication" in {
|
|
34
|
+
it should "handle simple multiplication" in {
|
|
35
|
+
pending
|
|
30
36
|
WordProblem("What is 10 multiplied by 10?") should equal(Some(100))
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
it should "handle multiplication with negative numbers" in {
|
|
39
|
+
it should "handle multiplication with negative numbers" in {
|
|
40
|
+
pending
|
|
34
41
|
WordProblem("What is -10 multiplied by -10?") should equal(Some(100))
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
it should "handle repeated multiplication" in {
|
|
44
|
+
it should "handle repeated multiplication" in {
|
|
45
|
+
pending
|
|
38
46
|
WordProblem("What is 2 multiplied by -2 multiplied by 3?") should equal(Some(-12))
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
it should "handle simple division" in {
|
|
49
|
+
it should "handle simple division" in {
|
|
50
|
+
pending
|
|
42
51
|
WordProblem("What is 10 divided by 10?") should equal(Some(1))
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
it should "handle division with negative numbers" in {
|
|
54
|
+
it should "handle division with negative numbers" in {
|
|
55
|
+
pending
|
|
46
56
|
WordProblem("What is 33 divided by -3?") should equal(Some(-11))
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
it should "handle repeated division" in {
|
|
59
|
+
it should "handle repeated division" in {
|
|
60
|
+
pending
|
|
50
61
|
WordProblem("What is -12 divided by 2 divided by -3?") should equal(Some(2))
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
it should "handle mixed operations" in {
|
|
64
|
+
it should "handle mixed operations" in {
|
|
65
|
+
pending
|
|
54
66
|
WordProblem("What is 1 plus 5 minus -2?") should equal(Some(8))
|
|
55
67
|
WordProblem("What is 17 minus 6 plus 3?") should equal(Some(14))
|
|
56
68
|
WordProblem("What is -3 plus 7 multiplied by -2?") should equal(Some(-8))
|
|
57
69
|
}
|
|
58
70
|
|
|
59
|
-
it should "handle invalid word problem" in {
|
|
71
|
+
it should "handle invalid word problem" in {
|
|
72
|
+
pending
|
|
60
73
|
WordProblem("What is 1 plus 5 minus -2?") should equal(Some(8))
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
// Test for "Extension"
|
|
64
|
-
ignore should "handle powers" in {
|
|
77
|
+
ignore should "handle powers" in {
|
|
78
|
+
pending
|
|
65
79
|
WordProblem("What is 2 raised to the 5?") should equal(Some(32))
|
|
66
80
|
}
|
|
67
81
|
}
|
|
@@ -44,11 +44,11 @@ object XScalaBuild extends Build {
|
|
|
44
44
|
throw new IllegalArgumentException(s"Could not parse $configJsonFile as JSON")
|
|
45
45
|
}
|
|
46
46
|
configObj
|
|
47
|
-
.get("
|
|
47
|
+
.get("exercises")
|
|
48
48
|
.map(_.asInstanceOf[JSONArray].list)
|
|
49
49
|
.getOrElse {
|
|
50
|
-
throw new IllegalArgumentException(s"Could not find array '
|
|
50
|
+
throw new IllegalArgumentException(s"Could not find array 'exercises' in $configJsonFile")
|
|
51
51
|
}
|
|
52
|
-
.collect { case problem:
|
|
52
|
+
.collect { case problem: JSONObject => problem.obj("slug").toString }
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import play.api.libs.json.Json
|
|
2
|
+
|
|
3
|
+
import scala.io.Source
|
|
4
|
+
|
|
5
|
+
class BowlingTestGenerator {
|
|
6
|
+
implicit val testCaseReader = Json.reads[BowlingTestCase]
|
|
7
|
+
|
|
8
|
+
private val filename = "bowling.json"
|
|
9
|
+
private val fileContents = Source.fromFile(filename).getLines.mkString
|
|
10
|
+
private val json = Json.parse(fileContents)
|
|
11
|
+
|
|
12
|
+
def write {
|
|
13
|
+
print("import org.scalatest.{FunSuite, Matchers}" + System.lineSeparator())
|
|
14
|
+
print(System.lineSeparator())
|
|
15
|
+
print("class BowlingSuite extends FunSuite with Matchers {" + System.lineSeparator())
|
|
16
|
+
|
|
17
|
+
writeTestCases()
|
|
18
|
+
|
|
19
|
+
print("}" + System.lineSeparator())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private def writeTestCases(): Unit = {
|
|
23
|
+
println("// " + (json \ "score" \ "description").get.as[List[String]].mkString(" "))
|
|
24
|
+
|
|
25
|
+
val testCases = (json \ "score" \ "cases").get.as[List[BowlingTestCase]]
|
|
26
|
+
|
|
27
|
+
testCases.foreach(tc => {
|
|
28
|
+
print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
|
|
29
|
+
println("pending")
|
|
30
|
+
print("val score = List(")
|
|
31
|
+
print(tc.rolls.map(roll => roll.toString).mkString(", "))
|
|
32
|
+
println(").foldLeft(Bowling())((acc, roll) => acc.roll(roll)).score()")
|
|
33
|
+
|
|
34
|
+
println("score match {")
|
|
35
|
+
if (tc.expected == -1) {
|
|
36
|
+
println("case Right(_) => fail(\"Unexpected score returned. Failure expected\")")
|
|
37
|
+
println("case Left(_) => ")
|
|
38
|
+
} else {
|
|
39
|
+
println("case Right(n) => assert(n == " + tc.expected.toString + ")")
|
|
40
|
+
println("case Left(_) => fail(\"" + tc.description + "\")")
|
|
41
|
+
}
|
|
42
|
+
println("}")
|
|
43
|
+
print("\t}" + System.lineSeparator())
|
|
44
|
+
print(System.lineSeparator())
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
case class BowlingTestCase(description: String,
|
|
50
|
+
rolls: List[Int],
|
|
51
|
+
expected: Int)
|
|
52
|
+
|
|
53
|
+
object BowlingTestGenerator {
|
|
54
|
+
def main(args: Array[String]): Unit = {
|
|
55
|
+
new BowlingTestGenerator().write
|
|
56
|
+
}
|
|
57
|
+
}
|
data/tracks/sml/config.json
CHANGED
|
@@ -5,12 +5,47 @@
|
|
|
5
5
|
"checklist_issue": 8,
|
|
6
6
|
"active": false,
|
|
7
7
|
"test_pattern": "^test_*.sml$",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
"exercises": [
|
|
9
|
+
{
|
|
10
|
+
"slug": "accumulate",
|
|
11
|
+
"difficulty": 1,
|
|
12
|
+
"topics": []
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"slug": "allergies",
|
|
16
|
+
"difficulty": 1,
|
|
17
|
+
"topics": []
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"slug": "anagram",
|
|
21
|
+
"difficulty": 1,
|
|
22
|
+
"topics": []
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"slug": "binary",
|
|
26
|
+
"difficulty": 1,
|
|
27
|
+
"topics": []
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"slug": "flatten-array",
|
|
31
|
+
"difficulty": 1,
|
|
32
|
+
"topics": []
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"slug": "hamming",
|
|
36
|
+
"difficulty": 1,
|
|
37
|
+
"topics": []
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"slug": "raindrops",
|
|
41
|
+
"difficulty": 1,
|
|
42
|
+
"topics": []
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"slug": "nth-prime",
|
|
46
|
+
"difficulty": 1,
|
|
47
|
+
"topics": []
|
|
48
|
+
}
|
|
14
49
|
],
|
|
15
50
|
"deprecated": [
|
|
16
51
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
use "example.sml";
|
|
2
|
+
val test_cases = [
|
|
3
|
+
((Node [Leaf 1, Node [Leaf 2, Node [], Leaf 3, Node [Leaf 4, Leaf 5]]]), [1,2,3,4,5])
|
|
4
|
+
];
|
|
5
|
+
|
|
6
|
+
fun run_tests [] = []
|
|
7
|
+
| run_tests ((input,expected)::ts) =
|
|
8
|
+
(flatten input = expected) :: run_tests ts
|
|
9
|
+
|
|
10
|
+
val allTestsPass = List.foldl (fn (x,y) => x andalso y) true (run_tests test_cases);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
exception EmptyList
|
|
2
|
+
datatype 'a lazylist = Nil | Cons of ('a * (unit -> 'a lazylist));
|
|
3
|
+
fun next s = let
|
|
4
|
+
fun next' Nil = raise EmptyList
|
|
5
|
+
| next' (Cons(a,f)) = f()
|
|
6
|
+
in
|
|
7
|
+
next' s
|
|
8
|
+
end ;
|
|
9
|
+
|
|
10
|
+
fun hd s = let
|
|
11
|
+
fun hd' Nil = raise EmptyList
|
|
12
|
+
| hd' (Cons(a, _)) = a
|
|
13
|
+
in
|
|
14
|
+
hd' s
|
|
15
|
+
end ;
|
|
16
|
+
|
|
17
|
+
fun allPrimes n = let
|
|
18
|
+
fun isPrime n = let
|
|
19
|
+
fun factors n = let
|
|
20
|
+
fun factors' 0 acc = acc
|
|
21
|
+
| factors' c acc = if (n mod c) = 0
|
|
22
|
+
then factors' (c-1) (c :: acc)
|
|
23
|
+
else factors' (c-1) acc
|
|
24
|
+
in
|
|
25
|
+
factors' (n div 2) []
|
|
26
|
+
end
|
|
27
|
+
in
|
|
28
|
+
(List.length (factors n)) = 1
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
fun nextPrime n = let
|
|
32
|
+
val nextN = if (n mod 2) = 0 then n + 1 else n + 2
|
|
33
|
+
in
|
|
34
|
+
if isPrime nextN then nextN else nextPrime nextN
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
in
|
|
38
|
+
Cons(n, fn () => (allPrimes (nextPrime n)))
|
|
39
|
+
end ;
|
|
40
|
+
|
|
41
|
+
fun nthPrime n = let
|
|
42
|
+
fun nthPrime' 0 s = hd s
|
|
43
|
+
| nthPrime' n s = nthPrime' (n-1) (next s)
|
|
44
|
+
in
|
|
45
|
+
nthPrime' (n-1) (allPrimes 2)
|
|
46
|
+
end ;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
use "example.sml";
|
|
2
|
+
|
|
3
|
+
val test_cases = [
|
|
4
|
+
(1, 2),
|
|
5
|
+
(2, 3),
|
|
6
|
+
(9, 23),
|
|
7
|
+
(100, 541)
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
fun run_tests [] = []
|
|
11
|
+
| run_tests ((n, expected)::ts) =
|
|
12
|
+
(nthPrime n = expected) :: run_tests ts
|
|
13
|
+
|
|
14
|
+
val allTestsPass = List.foldl (fn (x,y) => x andalso y) true (run_tests test_cases);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
use "example.sml";
|
|
2
|
+
|
|
3
|
+
val test_cases = [
|
|
4
|
+
{
|
|
5
|
+
number = 1,
|
|
6
|
+
expected = "1"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
number = 3,
|
|
10
|
+
expected = "Pling"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
number = 5,
|
|
14
|
+
expected = "Plang"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
number = 7,
|
|
18
|
+
expected = "Plong"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
number = 6,
|
|
22
|
+
expected = "Pling"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
number = 8,
|
|
26
|
+
expected = "8"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
number = 9,
|
|
30
|
+
expected = "Pling"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
number = 10,
|
|
34
|
+
expected = "Plang"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
number = 14,
|
|
38
|
+
expected = "Plong"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
number = 15,
|
|
42
|
+
expected = "PlingPlang"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
number = 21,
|
|
46
|
+
expected = "PlingPlong"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
number = 25,
|
|
50
|
+
expected = "Plang"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
number = 27,
|
|
54
|
+
expected = "Pling"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
number = 35,
|
|
58
|
+
expected = "PlangPlong"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
number = 49,
|
|
62
|
+
expected = "Plong"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
number = 52,
|
|
66
|
+
expected = "52"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
number = 105,
|
|
70
|
+
expected = "PlingPlangPlong"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
number = 3125,
|
|
74
|
+
expected = "Plang"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
fun run_tests _ [] = []
|
|
79
|
+
| run_tests f (x :: xs) =
|
|
80
|
+
let
|
|
81
|
+
fun aux { number, expected } =
|
|
82
|
+
let
|
|
83
|
+
val output = f number
|
|
84
|
+
val is_correct = output = expected
|
|
85
|
+
val expl =
|
|
86
|
+
"convert " ^ (Int.toString number) ^ ": " ^
|
|
87
|
+
(if not is_correct then "FAILED" else "PASSED") ^ "\n"
|
|
88
|
+
in
|
|
89
|
+
(print (expl); is_correct)
|
|
90
|
+
end
|
|
91
|
+
in
|
|
92
|
+
(aux x) :: run_tests f xs
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
val allTestsPass = List.all (fn x => x) (run_tests convert test_cases)
|