trackler 2.2.1.43 → 2.2.1.44
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/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/lens-person/description.md +1 -1
- data/problem-specifications/exercises/palindrome-products/description.md +5 -12
- data/problem-specifications/exercises/pascals-triangle/canonical-data.json +1 -7
- data/tracks/c/exercises/meetup/src/example.c +64 -60
- data/tracks/c/exercises/meetup/src/example.h +2 -2
- data/tracks/c/exercises/meetup/test/test_meetup.c +4 -4
- data/tracks/cfml/config.json +179 -169
- data/tracks/cfml/exercises/markdown/.meta/HINTS.md +0 -0
- data/tracks/cfml/exercises/markdown/Markdown.cfc +121 -0
- data/tracks/cfml/exercises/markdown/MarkdownTest.cfc +51 -0
- data/tracks/cfml/exercises/markdown/Solution.cfc +204 -0
- data/tracks/cfml/exercises/markdown/SolutionTest.cfc +7 -0
- data/tracks/cfml/exercises/markdown/TestRunner.cfc +103 -0
- data/tracks/cfml/exercises/markdown/box.json +8 -0
- data/tracks/cfml/exercises/markdown/index.cfm +37 -0
- data/tracks/csharp/exercises/dominoes/DominoesTest.cs +40 -45
- data/tracks/csharp/exercises/meetup/MeetupTest.cs +761 -83
- data/tracks/csharp/generators/Exercises/Dominoes.cs +33 -0
- data/tracks/csharp/generators/Exercises/Meetup.cs +46 -0
- data/tracks/csharp/generators/Output/FormattingExtensions.cs +11 -1
- data/tracks/csharp/generators/Output/TypesExtensions.cs +23 -0
- data/tracks/csharp/generators/Output/ValueFormatter.cs +70 -69
- data/tracks/dart/config.json +15 -3
- data/tracks/dart/exercises/word-count/README.md +18 -0
- data/tracks/dart/exercises/word-count/lib/example.dart +26 -0
- data/tracks/dart/exercises/word-count/lib/word_count.dart +3 -0
- data/tracks/dart/exercises/word-count/pubspec.lock +293 -0
- data/tracks/dart/exercises/word-count/pubspec.yaml +3 -0
- data/tracks/dart/exercises/word-count/test/word_count_test.dart +64 -0
- data/tracks/ecmascript/docs/INSTALLATION.md +4 -7
- data/tracks/elixir/exercises/hello-world/README.md +1 -26
- data/tracks/elixir/exercises/hello-world/example.exs +3 -7
- data/tracks/elixir/exercises/hello-world/hello_world.exs +3 -25
- data/tracks/elixir/exercises/hello-world/hello_world_test.exs +2 -13
- data/tracks/elixir/mix.lock +1 -1
- data/tracks/elm/config.json +11 -0
- data/tracks/elm/exercises/pascals-triangle/README.md +51 -0
- data/tracks/elm/exercises/pascals-triangle/Triangle.elm +1 -0
- data/tracks/elm/exercises/pascals-triangle/Triangle.example.elm +23 -0
- data/tracks/elm/exercises/pascals-triangle/elm-package.json +14 -0
- data/tracks/elm/exercises/pascals-triangle/package.json +14 -0
- data/tracks/elm/exercises/pascals-triangle/tests/Tests.elm +34 -0
- data/tracks/elm/exercises/pascals-triangle/tests/elm-package.json +16 -0
- data/tracks/fsharp/exercises/grade-school/GradeSchool.fs +2 -2
- data/tracks/fsharp/exercises/grade-school/GradeSchoolTest.fs +3 -2
- data/tracks/java/CONTRIBUTING.md +34 -0
- data/tracks/java/config.json +42 -6
- data/tracks/java/exercises/largest-series-product/src/main/java/LargestSeriesProductCalculator.java +7 -3
- data/tracks/java/exercises/matrix/src/main/java/Matrix.java +23 -0
- data/tracks/julia/config.json +11 -2
- data/tracks/julia/exercises/grains/README.md +33 -0
- data/tracks/julia/exercises/grains/example.jl +23 -0
- data/tracks/julia/exercises/grains/grains.jl +9 -0
- data/tracks/julia/exercises/grains/runtests.jl +27 -0
- data/tracks/lua/README.md +1 -1
- data/tracks/mips/exercises/octal/README.md +3 -8
- data/tracks/ocaml/exercises/palindrome-products/README.md +8 -14
- data/tracks/perl6/.travis.yml +7 -3
- data/tracks/perl6/bin/exercise-gen.pl6 +5 -1
- data/tracks/perl6/exercises/accumulate/README.md +0 -3
- data/tracks/perl6/exercises/accumulate/accumulate.t +9 -3
- data/tracks/perl6/exercises/all-your-base/README.md +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +23 -11
- data/tracks/perl6/exercises/all-your-base/example.yaml +1 -1
- data/tracks/perl6/exercises/allergies/README.md +0 -1
- data/tracks/perl6/exercises/allergies/allergies.t +22 -10
- data/tracks/perl6/exercises/anagram/anagram.t +22 -10
- data/tracks/perl6/exercises/atbash-cipher/README.md +2 -1
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +22 -10
- data/tracks/perl6/exercises/binary/README.md +2 -0
- data/tracks/perl6/exercises/bob/bob.t +24 -11
- data/tracks/perl6/exercises/bob/example.yaml +2 -2
- data/tracks/perl6/exercises/clock/clock.t +22 -10
- data/tracks/perl6/exercises/flatten-array/README.md +1 -2
- data/tracks/perl6/exercises/flatten-array/example.yaml +1 -1
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +23 -11
- data/tracks/perl6/exercises/grade-school/README.md +0 -1
- data/tracks/perl6/exercises/grade-school/grade-school.t +9 -3
- data/tracks/perl6/exercises/grains/README.md +0 -1
- data/tracks/perl6/exercises/grains/grains.t +22 -10
- data/tracks/perl6/exercises/hello-world/example.yaml +3 -3
- data/tracks/perl6/exercises/hello-world/hello-world.t +25 -12
- data/tracks/perl6/exercises/leap/README.md +1 -1
- data/tracks/perl6/exercises/leap/example.yaml +1 -1
- data/tracks/perl6/exercises/leap/leap.t +23 -11
- data/tracks/perl6/exercises/linked-list/README.md +10 -10
- data/tracks/perl6/exercises/linked-list/linked-list.t +9 -3
- data/tracks/perl6/exercises/luhn/README.md +7 -7
- data/tracks/perl6/exercises/luhn/luhn.t +22 -10
- data/tracks/perl6/exercises/phone-number/README.md +3 -2
- data/tracks/perl6/exercises/phone-number/phone-number.t +22 -10
- data/tracks/perl6/exercises/raindrops/raindrops.t +22 -10
- data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +22 -10
- data/tracks/perl6/exercises/robot-name/robot-name.t +9 -3
- data/tracks/perl6/exercises/scrabble-score/README.md +3 -1
- data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +22 -10
- data/tracks/perl6/exercises/space-age/README.md +2 -1
- data/tracks/perl6/exercises/space-age/space-age.t +22 -10
- data/tracks/perl6/exercises/trinary/README.md +1 -1
- data/tracks/perl6/exercises/word-count/README.md +1 -2
- data/tracks/perl6/exercises/word-count/word-count.t +22 -10
- data/tracks/perl6/exercises/wordy/README.md +0 -5
- data/tracks/perl6/exercises/wordy/wordy.t +22 -10
- data/tracks/perl6/templates/test.mustache +26 -15
- data/tracks/python/config.json +10 -0
- data/tracks/python/exercises/book-store/book_store.py +1 -1
- data/tracks/python/exercises/flatten-array/flatten_array.py +1 -1
- data/tracks/python/exercises/matrix/matrix.py +1 -1
- data/tracks/python/exercises/palindrome-products/palindrome_products.py +2 -2
- data/tracks/python/exercises/perfect-numbers/perfect_numbers.py +2 -2
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet.py +3 -3
- data/tracks/python/exercises/raindrops/raindrops.py +1 -1
- data/tracks/python/exercises/scale-generator/scale_generator.py +1 -1
- data/tracks/python/exercises/sieve/sieve.py +1 -1
- data/tracks/python/exercises/sublist/sublist.py +1 -1
- data/tracks/python/exercises/transpose/transpose.py +1 -1
- data/tracks/python/exercises/triangle/triangle.py +4 -1
- data/tracks/python/exercises/two-bucket/example.py +59 -0
- data/tracks/python/exercises/two-bucket/two_bucket.py +2 -0
- data/tracks/python/exercises/two-bucket/two_bucket_test.py +32 -0
- data/tracks/scheme/config.json +59 -89
- data/tracks/scheme/config/maintainers.json +11 -11
- data/tracks/sml/exercises/allergies/README.md +20 -5
- data/tracks/sml/exercises/allergies/allergies.sml +11 -14
- data/tracks/sml/exercises/allergies/example.sml +9 -9
- data/tracks/sml/exercises/allergies/test.sml +65 -129
- data/tracks/sml/exercises/allergies/testlib.sml +159 -0
- data/tracks/sml/exercises/hamming/README.md +21 -5
- data/tracks/sml/exercises/hamming/example.sml +14 -10
- data/tracks/sml/exercises/hamming/hamming.sml +4 -3
- data/tracks/sml/exercises/hamming/test.sml +55 -64
- data/tracks/sml/exercises/hamming/testlib.sml +159 -0
- data/tracks/typescript/config.json +15 -0
- data/tracks/typescript/exercises/linked-list/linked-list.test.ts +11 -11
- data/tracks/typescript/exercises/nth-prime/README.md +36 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.example.ts +28 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.test.ts +25 -0
- data/tracks/typescript/exercises/nth-prime/nth-prime.ts +0 -0
- data/tracks/typescript/exercises/nth-prime/package.json +36 -0
- data/tracks/typescript/exercises/nth-prime/tsconfig.json +22 -0
- data/tracks/typescript/exercises/nth-prime/tslint.json +127 -0
- data/tracks/typescript/exercises/nth-prime/yarn.lock +2305 -0
- data/tracks/typescript/exercises/prime-factors/README.md +1 -1
- data/tracks/typescript/exercises/prime-factors/prime-factors.test.ts +11 -11
- data/tracks/typescript/exercises/series/README.md +1 -1
- data/tracks/typescript/exercises/series/series.test.ts +11 -11
- data/tracks/typescript/img/icon.png +0 -0
- data/tracks/typescript/img/icon.svg +3 -8
- metadata +44 -2
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
exception NonEqualLengthStringsFound
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
exception NonEqualLengthStringsFound
|
|
2
|
+
|
|
3
|
+
fun distance (strand1: string, strand2: string): int =
|
|
4
|
+
let
|
|
5
|
+
val chars1 = explode strand1
|
|
6
|
+
val chars2 = explode strand2
|
|
7
|
+
fun distance' ([], []) acc = acc
|
|
8
|
+
| distance' ((x::xs), (y::ys)) acc =
|
|
9
|
+
distance' (xs, ys) (acc + (if x = y then 0 else 1))
|
|
10
|
+
in
|
|
11
|
+
if (length chars1) <> (length chars2) then
|
|
12
|
+
raise NonEqualLengthStringsFound
|
|
13
|
+
else distance' (chars1, chars2) 0
|
|
14
|
+
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
exception NonEqualLengthStringsFound
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
exception NonEqualLengthStringsFound
|
|
2
|
+
|
|
3
|
+
fun distance (strand1: string, strand2: string): int =
|
|
4
|
+
raise Fail "'distance' is not implemented"
|
|
@@ -1,66 +1,57 @@
|
|
|
1
|
+
(* version 2.0.0 *)
|
|
2
|
+
|
|
3
|
+
use "testlib.sml";
|
|
1
4
|
use "hamming.sml";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
fun evaluateErrorTestCase f { description, input, expected } =
|
|
57
|
-
{ description = description, is_correct = (f input handle expected => 1) = 1 }
|
|
58
|
-
|
|
59
|
-
val testResults = run_tests hamming (List.map (evaluateGoodTestCase hamming) test_cases)
|
|
60
|
-
@ run_tests hamming (List.map (evaluateErrorTestCase hamming) error_test_cases);
|
|
61
|
-
val passedTests = List.filter (fn x => x) testResults;
|
|
62
|
-
val failedTests = List.filter (fn x => not x) testResults;
|
|
63
|
-
|
|
64
|
-
if (List.length testResults) = (List.length passedTests)
|
|
65
|
-
then (print "ALL TESTS PASSED")
|
|
66
|
-
else (print (Int.toString (List.length failedTests) ^ " TEST(S) FAILED"));
|
|
6
|
+
infixr |>
|
|
7
|
+
fun x |> f = f x
|
|
8
|
+
|
|
9
|
+
val testsuite =
|
|
10
|
+
describe "hamming" [
|
|
11
|
+
test "empty strands"
|
|
12
|
+
(fn _ => distance ("", "") |> Expect.equalTo 0),
|
|
13
|
+
|
|
14
|
+
test "identical strands"
|
|
15
|
+
(fn _ => distance ("A", "A") |> Expect.equalTo 0),
|
|
16
|
+
|
|
17
|
+
test "long identical strands"
|
|
18
|
+
(fn _ => distance ("GGACTGA", "GGACTGA") |> Expect.equalTo 0),
|
|
19
|
+
|
|
20
|
+
test "complete distance in single nucleotide strands"
|
|
21
|
+
(fn _ => distance ("A", "G") |> Expect.equalTo 1),
|
|
22
|
+
|
|
23
|
+
test "complete distance in small strands"
|
|
24
|
+
(fn _ => distance ("AG", "CT") |> Expect.equalTo 2),
|
|
25
|
+
|
|
26
|
+
test "small distance in small strands"
|
|
27
|
+
(fn _ => distance ("AT", "CT") |> Expect.equalTo 1),
|
|
28
|
+
|
|
29
|
+
test "small distance"
|
|
30
|
+
(fn _ => distance ("GGACG", "GGTCG") |> Expect.equalTo 1),
|
|
31
|
+
|
|
32
|
+
test "small distance in long strands"
|
|
33
|
+
(fn _ => distance ("ACCAGGG", "ACTATGG") |> Expect.equalTo 2),
|
|
34
|
+
|
|
35
|
+
test "non-unique character in first strand"
|
|
36
|
+
(fn _ => distance ("AGA", "AGG") |> Expect.equalTo 1),
|
|
37
|
+
|
|
38
|
+
test "non-unique character in second strand"
|
|
39
|
+
(fn _ => distance ("AGG", "AGA") |> Expect.equalTo 1),
|
|
40
|
+
|
|
41
|
+
test "same nucleotides in different positions"
|
|
42
|
+
(fn _ => distance ("TAG", "GAT") |> Expect.equalTo 2),
|
|
43
|
+
|
|
44
|
+
test "large distance"
|
|
45
|
+
(fn _ => distance ("GATACA", "GCATAA") |> Expect.equalTo 4),
|
|
46
|
+
|
|
47
|
+
test "large distance in off-by-one strand"
|
|
48
|
+
(fn _ => distance ("GGACGGATTCTG", "AGGACGGATTCT") |> Expect.equalTo 9),
|
|
49
|
+
|
|
50
|
+
test "disallow first strand longer"
|
|
51
|
+
(fn _ => (fn _ => distance ("AATG", "AAA")) |> Expect.error NonEqualLengthStringsFound),
|
|
52
|
+
|
|
53
|
+
test "disallow second strand longer"
|
|
54
|
+
(fn _ => (fn _ => distance ("ATA", "AGTG")) |> Expect.error NonEqualLengthStringsFound)
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
val _ = Test.run testsuite
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
structure Expect =
|
|
2
|
+
struct
|
|
3
|
+
datatype expectation = Pass | Fail of string * string
|
|
4
|
+
|
|
5
|
+
local
|
|
6
|
+
fun failEq b a =
|
|
7
|
+
Fail ("Expected: " ^ b, "Got: " ^ a)
|
|
8
|
+
|
|
9
|
+
fun failExn b a =
|
|
10
|
+
Fail ("Expected: " ^ b, "Raised: " ^ a)
|
|
11
|
+
|
|
12
|
+
fun exnName (e: exn): string = General.exnName e
|
|
13
|
+
in
|
|
14
|
+
fun truthy a =
|
|
15
|
+
if a
|
|
16
|
+
then Pass
|
|
17
|
+
else failEq "true" "false"
|
|
18
|
+
|
|
19
|
+
fun falsy a =
|
|
20
|
+
if a
|
|
21
|
+
then failEq "false" "true"
|
|
22
|
+
else Pass
|
|
23
|
+
|
|
24
|
+
fun equalTo b a =
|
|
25
|
+
if a = b
|
|
26
|
+
then Pass
|
|
27
|
+
else failEq (PolyML.makestring b) (PolyML.makestring a)
|
|
28
|
+
|
|
29
|
+
fun nearTo b a =
|
|
30
|
+
if Real.== (a, b)
|
|
31
|
+
then Pass
|
|
32
|
+
else failEq (Real.toString b) (Real.toString a)
|
|
33
|
+
|
|
34
|
+
fun anyError f =
|
|
35
|
+
(
|
|
36
|
+
f ();
|
|
37
|
+
failExn "an exception" "Nothing"
|
|
38
|
+
) handle _ => Pass
|
|
39
|
+
|
|
40
|
+
fun error e f =
|
|
41
|
+
(
|
|
42
|
+
f ();
|
|
43
|
+
failExn (exnName e) "Nothing"
|
|
44
|
+
) handle e' => if exnMessage e' = exnMessage e
|
|
45
|
+
then Pass
|
|
46
|
+
else failExn (exnMessage e) (exnMessage e')
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
structure TermColor =
|
|
51
|
+
struct
|
|
52
|
+
datatype color = Red | Green | Yellow | Normal
|
|
53
|
+
|
|
54
|
+
fun f Red = "\027[31m"
|
|
55
|
+
| f Green = "\027[32m"
|
|
56
|
+
| f Yellow = "\027[33m"
|
|
57
|
+
| f Normal = "\027[0m"
|
|
58
|
+
|
|
59
|
+
fun colorize color s = (f color) ^ s ^ (f Normal)
|
|
60
|
+
|
|
61
|
+
val redit = colorize Red
|
|
62
|
+
|
|
63
|
+
val greenit = colorize Green
|
|
64
|
+
|
|
65
|
+
val yellowit = colorize Yellow
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
structure Test =
|
|
69
|
+
struct
|
|
70
|
+
datatype testnode = TestGroup of string * testnode list
|
|
71
|
+
| Test of string * (unit -> Expect.expectation)
|
|
72
|
+
|
|
73
|
+
local
|
|
74
|
+
datatype evaluation = Success of string
|
|
75
|
+
| Failure of string * string * string
|
|
76
|
+
| Error of string * string
|
|
77
|
+
|
|
78
|
+
fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
|
|
79
|
+
|
|
80
|
+
fun fmt indentlvl ev =
|
|
81
|
+
let
|
|
82
|
+
val check = TermColor.greenit "\226\156\148 " (* ✔ *)
|
|
83
|
+
val cross = TermColor.redit "\226\156\150 " (* ✖ *)
|
|
84
|
+
val indentlvl = indentlvl * 2
|
|
85
|
+
in
|
|
86
|
+
case ev of
|
|
87
|
+
Success descr => indent indentlvl (check ^ descr)
|
|
88
|
+
| Failure (descr, exp, got) =>
|
|
89
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
90
|
+
indent (indentlvl + 2) exp,
|
|
91
|
+
indent (indentlvl + 2) got]
|
|
92
|
+
| Error (descr, reason) =>
|
|
93
|
+
String.concatWith "\n" [indent indentlvl (cross ^ descr),
|
|
94
|
+
indent (indentlvl + 2) (TermColor.redit reason)]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
|
|
98
|
+
| eval (Test (descr, thunk)) =
|
|
99
|
+
(
|
|
100
|
+
case thunk () of
|
|
101
|
+
Expect.Pass => ((1, 0, 0), Success descr)
|
|
102
|
+
| Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
|
|
103
|
+
)
|
|
104
|
+
handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
|
|
105
|
+
|
|
106
|
+
fun flatten depth testnode =
|
|
107
|
+
let
|
|
108
|
+
fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
|
|
109
|
+
|
|
110
|
+
fun aux (t, (counter, acc)) =
|
|
111
|
+
let
|
|
112
|
+
val (counter', texts) = flatten (depth + 1) t
|
|
113
|
+
in
|
|
114
|
+
(sum counter' counter, texts :: acc)
|
|
115
|
+
end
|
|
116
|
+
in
|
|
117
|
+
case testnode of
|
|
118
|
+
TestGroup (descr, ts) =>
|
|
119
|
+
let
|
|
120
|
+
val (counter, texts) = foldr aux ((0, 0, 0), []) ts
|
|
121
|
+
in
|
|
122
|
+
(counter, (indent (depth * 2) descr) :: List.concat texts)
|
|
123
|
+
end
|
|
124
|
+
| Test _ =>
|
|
125
|
+
let
|
|
126
|
+
val (counter, evaluation) = eval testnode
|
|
127
|
+
in
|
|
128
|
+
(counter, [fmt depth evaluation])
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
fun println s = print (s ^ "\n")
|
|
133
|
+
in
|
|
134
|
+
fun run suite =
|
|
135
|
+
let
|
|
136
|
+
val ((succeeded, failed, errored), texts) = flatten 0 suite
|
|
137
|
+
|
|
138
|
+
val summary = String.concatWith ", " [
|
|
139
|
+
TermColor.greenit ((Int.toString succeeded) ^ " passed"),
|
|
140
|
+
TermColor.redit ((Int.toString failed) ^ " failed"),
|
|
141
|
+
TermColor.redit ((Int.toString errored) ^ " errored"),
|
|
142
|
+
(Int.toString (succeeded + failed + errored)) ^ " total"
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
val status = if failed = 0 andalso errored = 0
|
|
146
|
+
then OS.Process.success
|
|
147
|
+
else OS.Process.failure
|
|
148
|
+
|
|
149
|
+
in
|
|
150
|
+
List.app println texts;
|
|
151
|
+
println "";
|
|
152
|
+
println ("Tests: " ^ summary);
|
|
153
|
+
OS.Process.exit status
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
fun describe description tests = Test.TestGroup (description, tests)
|
|
159
|
+
fun test description thunk = Test.Test (description, thunk)
|
|
@@ -90,6 +90,21 @@
|
|
|
90
90
|
"Integers"
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
|
+
{
|
|
94
|
+
"uuid": "4c1392d7-8779-496f-b0bb-81605e777e3b",
|
|
95
|
+
"slug": "nth-prime",
|
|
96
|
+
"core": false,
|
|
97
|
+
"unlocked_by": "prime-factors",
|
|
98
|
+
"difficulty": 5,
|
|
99
|
+
"topics": [
|
|
100
|
+
"Control-flow (conditionals)",
|
|
101
|
+
"Control-flow (loops)",
|
|
102
|
+
"Exception handling",
|
|
103
|
+
"Algorithms",
|
|
104
|
+
"Mathematics",
|
|
105
|
+
"Integers"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
93
108
|
{
|
|
94
109
|
"uuid": "e431fb10-766a-4542-94ad-9c30224a3885",
|
|
95
110
|
"slug": "sum-of-multiples",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import LinkedList from './linked-list'
|
|
2
2
|
|
|
3
3
|
describe('LinkedList', () => {
|
|
4
|
-
|
|
4
|
+
it('add/extract elements to the end of the list with push/pop', () => {
|
|
5
5
|
const list = new LinkedList<number>()
|
|
6
6
|
list.push(10)
|
|
7
7
|
list.push(20)
|
|
@@ -9,7 +9,7 @@ describe('LinkedList', () => {
|
|
|
9
9
|
expect(list.pop()).toBe(10)
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
xit('extract elements from the beginning of the list with shift', () => {
|
|
13
13
|
const list = new LinkedList<number>()
|
|
14
14
|
list.push(10)
|
|
15
15
|
list.push(20)
|
|
@@ -17,7 +17,7 @@ describe('LinkedList', () => {
|
|
|
17
17
|
expect(list.shift()).toBe(20)
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
xit('add/extract elements from the beginning of the list with unshift/shift', () => {
|
|
21
21
|
const list = new LinkedList<number>()
|
|
22
22
|
list.unshift(10)
|
|
23
23
|
list.unshift(20)
|
|
@@ -25,7 +25,7 @@ describe('LinkedList', () => {
|
|
|
25
25
|
expect(list.shift()).toBe(10)
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
xit('unshift/pop', () => {
|
|
29
29
|
const list = new LinkedList<number>()
|
|
30
30
|
list.unshift(10)
|
|
31
31
|
list.unshift(20)
|
|
@@ -33,7 +33,7 @@ describe('LinkedList', () => {
|
|
|
33
33
|
expect(list.pop()).toBe(20)
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
xit('example', () => {
|
|
37
37
|
const list = new LinkedList<number>()
|
|
38
38
|
list.push(10)
|
|
39
39
|
list.push(20)
|
|
@@ -47,7 +47,7 @@ describe('LinkedList', () => {
|
|
|
47
47
|
expect(list.shift()).toBe(30)
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
xit('can count its elements', () => {
|
|
51
51
|
const list = new LinkedList<number>()
|
|
52
52
|
expect(list.count()).toBe(0)
|
|
53
53
|
list.push(10)
|
|
@@ -56,7 +56,7 @@ describe('LinkedList', () => {
|
|
|
56
56
|
expect(list.count()).toBe(2)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
xit('sets head/tail after popping last element', () => {
|
|
60
60
|
const list = new LinkedList<number>()
|
|
61
61
|
list.push(10)
|
|
62
62
|
list.pop()
|
|
@@ -65,7 +65,7 @@ describe('LinkedList', () => {
|
|
|
65
65
|
expect(list.pop()).toBe(20)
|
|
66
66
|
})
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
xit('sets head/tail after shifting last element', () => {
|
|
69
69
|
const list = new LinkedList<number>()
|
|
70
70
|
list.unshift(10)
|
|
71
71
|
list.shift()
|
|
@@ -74,7 +74,7 @@ describe('LinkedList', () => {
|
|
|
74
74
|
expect(list.shift()).toBe(20)
|
|
75
75
|
})
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
xit('deletes the element with the specified value from the list', () => {
|
|
78
78
|
const list = new LinkedList<number>()
|
|
79
79
|
list.push(10)
|
|
80
80
|
list.push(20)
|
|
@@ -85,14 +85,14 @@ describe('LinkedList', () => {
|
|
|
85
85
|
expect(list.shift()).toBe(10)
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
xit('deletes the only element', () => {
|
|
89
89
|
const list = new LinkedList<number>()
|
|
90
90
|
list.push(10)
|
|
91
91
|
list.delete(10)
|
|
92
92
|
expect(list.count()).toBe(0)
|
|
93
93
|
})
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
xit('delete does not modify the list if the element is not found', () => {
|
|
96
96
|
const list = new LinkedList<number>()
|
|
97
97
|
list.push(10)
|
|
98
98
|
list.delete(20)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Nth Prime
|
|
2
|
+
|
|
3
|
+
Given a number n, determine what the nth prime is.
|
|
4
|
+
|
|
5
|
+
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that
|
|
6
|
+
the 6th prime is 13.
|
|
7
|
+
|
|
8
|
+
If your language provides methods in the standard library to deal with prime
|
|
9
|
+
numbers, pretend they don't exist and implement them yourself.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Setup
|
|
13
|
+
|
|
14
|
+
Go through the setup instructions for TypeScript to
|
|
15
|
+
install the necessary dependencies:
|
|
16
|
+
|
|
17
|
+
http://exercism.io/languages/typescript
|
|
18
|
+
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
Install assignment dependencies:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ yarn install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Making the test suite pass
|
|
28
|
+
|
|
29
|
+
Execute the tests with:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ yarn test
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Submitting Incomplete Solutions
|
|
36
|
+
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|