trackler 2.2.1.95 → 2.2.1.96
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/problem-specifications/exercises/two-bucket/canonical-data.json +31 -31
- data/tracks/csharp/docs/ABOUT.md +21 -3
- data/tracks/dart/.travis.yml +1 -2
- data/tracks/dart/README.md +2 -2
- data/tracks/dart/{tool/create-exercise → bin/create_exercise.dart} +14 -10
- data/tracks/dart/test/create_exercise_test.dart +132 -0
- data/tracks/dart/test/exercises_test.dart +1 -1
- data/tracks/fsharp/exercises/list-ops/Example.fs +5 -5
- data/tracks/fsharp/exercises/list-ops/ListOps.fs +1 -1
- data/tracks/fsharp/exercises/list-ops/ListOpsTest.fs +41 -62
- data/tracks/fsharp/generators/Common.fs +3 -0
- data/tracks/fsharp/generators/Formatting.fs +3 -1
- data/tracks/fsharp/generators/Generators.fs +21 -0
- data/tracks/go/config.json +14 -0
- data/tracks/go/exercises/grep/.meta/gen.go +76 -0
- data/tracks/go/exercises/grep/.meta/hints.md +13 -0
- data/tracks/go/exercises/grep/README.md +104 -0
- data/tracks/go/exercises/grep/cases_test.go +202 -0
- data/tracks/go/exercises/grep/example.go +102 -0
- data/tracks/go/exercises/grep/grep_test.go +84 -0
- data/tracks/java/exercises/anagram/.meta/version +1 -1
- data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +0 -32
- data/tracks/java/exercises/space-age/.meta/src/reference/java/SpaceAge.java +0 -4
- data/tracks/java/exercises/space-age/.meta/version +1 -0
- data/tracks/java/exercises/space-age/src/test/java/SpaceAgeTest.java +0 -16
- data/tracks/julia/.gitignore +1 -0
- data/tracks/julia/exercises/complex-numbers/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/julia/exercises/custom-set/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/julia/exercises/robot-name/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/julia/exercises/rotational-cipher/{HINTS.md → .meta/hints.md} +0 -0
- data/tracks/julia/runtests.jl +24 -25
- data/tracks/perl6/.travis.yml +7 -3
- data/tracks/perl6/Dockerfile +4 -0
- data/tracks/perl6/exercises/accumulate/Accumulate.pm6 +1 -1
- data/tracks/perl6/exercises/accumulate/Example.pm6 +1 -1
- data/tracks/perl6/exercises/accumulate/accumulate.t +6 -15
- data/tracks/perl6/exercises/accumulate/example.yaml +2 -3
- data/tracks/perl6/exercises/acronym/Acronym.pm6 +1 -1
- data/tracks/perl6/exercises/acronym/Example.pm6 +1 -1
- data/tracks/perl6/exercises/acronym/acronym.t +7 -29
- data/tracks/perl6/exercises/acronym/example.yaml +2 -3
- data/tracks/perl6/exercises/all-your-base/AllYourBase.pm6 +1 -1
- data/tracks/perl6/exercises/all-your-base/Example.pm6 +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +7 -29
- data/tracks/perl6/exercises/all-your-base/example.yaml +2 -3
- data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/Example.pm6 +1 -1
- data/tracks/perl6/exercises/allergies/allergies.t +7 -29
- data/tracks/perl6/exercises/allergies/example.yaml +2 -3
- data/tracks/perl6/exercises/anagram/Anagram.pm6 +1 -1
- data/tracks/perl6/exercises/anagram/Example.pm6 +1 -1
- data/tracks/perl6/exercises/anagram/anagram.t +7 -29
- data/tracks/perl6/exercises/anagram/example.yaml +2 -3
- data/tracks/perl6/exercises/atbash-cipher/AtbashCipher.pm6 +1 -1
- data/tracks/perl6/exercises/atbash-cipher/Example.pm6 +1 -1
- data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +7 -29
- data/tracks/perl6/exercises/atbash-cipher/example.yaml +2 -3
- data/tracks/{julia/exercises/.keep → perl6/exercises/binary/Binary.pm6} +0 -0
- data/tracks/perl6/exercises/binary/binary.t +3 -5
- data/tracks/perl6/exercises/bob/Bob.pm6 +1 -1
- data/tracks/perl6/exercises/bob/Example.pm6 +1 -1
- data/tracks/perl6/exercises/bob/bob.t +9 -32
- data/tracks/perl6/exercises/bob/example.yaml +3 -7
- data/tracks/perl6/exercises/clock/Clock.pm6 +1 -1
- data/tracks/perl6/exercises/clock/Example.pm6 +1 -1
- data/tracks/perl6/exercises/clock/clock.t +12 -32
- data/tracks/perl6/exercises/clock/example.yaml +6 -6
- data/tracks/perl6/exercises/etl/ETL.pm6 +1 -1
- data/tracks/perl6/exercises/etl/Example.pm6 +1 -1
- data/tracks/perl6/exercises/etl/etl.t +7 -29
- data/tracks/perl6/exercises/etl/example.yaml +2 -3
- data/tracks/perl6/exercises/flatten-array/Example.pm6 +1 -1
- data/tracks/perl6/exercises/flatten-array/FlattenArray.pm6 +1 -1
- data/tracks/perl6/exercises/flatten-array/example.yaml +2 -3
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +7 -29
- data/tracks/perl6/exercises/grade-school/Example.pm6 +1 -1
- data/tracks/perl6/exercises/grade-school/GradeSchool.pm6 +1 -1
- data/tracks/perl6/exercises/grade-school/example.yaml +2 -3
- data/tracks/perl6/exercises/grade-school/grade-school.t +6 -15
- data/tracks/perl6/exercises/grains/Example.pm6 +1 -1
- data/tracks/perl6/exercises/grains/Grains.pm6 +1 -1
- data/tracks/perl6/exercises/grains/example.yaml +2 -3
- data/tracks/perl6/exercises/grains/grains.t +7 -29
- data/tracks/perl6/exercises/hamming/Example.pm6 +1 -1
- data/tracks/perl6/exercises/hamming/Hamming.pm6 +1 -1
- data/tracks/perl6/exercises/hamming/example.yaml +2 -3
- data/tracks/perl6/exercises/hamming/hamming.t +7 -29
- data/tracks/perl6/exercises/hello-world/Example.pm6 +1 -1
- data/tracks/perl6/exercises/hello-world/HelloWorld.pm6 +1 -1
- data/tracks/perl6/exercises/hello-world/example.yaml +2 -8
- data/tracks/perl6/exercises/hello-world/hello-world.t +7 -33
- data/tracks/perl6/exercises/leap/Example.pm6 +1 -1
- data/tracks/perl6/exercises/leap/Leap.pm6 +1 -1
- data/tracks/perl6/exercises/leap/example.yaml +2 -3
- data/tracks/perl6/exercises/leap/leap.t +7 -29
- data/tracks/perl6/exercises/linked-list/Example.pm6 +1 -1
- data/tracks/perl6/exercises/linked-list/LinkedList.pm6 +1 -1
- data/tracks/perl6/exercises/linked-list/example.yaml +3 -3
- data/tracks/perl6/exercises/linked-list/linked-list.t +9 -16
- data/tracks/perl6/exercises/luhn/Example.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/Luhn.pm6 +1 -1
- data/tracks/perl6/exercises/luhn/example.yaml +2 -3
- data/tracks/perl6/exercises/luhn/luhn.t +7 -29
- data/tracks/perl6/exercises/meetup/Example.pm6 +1 -1
- data/tracks/perl6/exercises/meetup/Meetup.pm6 +1 -1
- data/tracks/perl6/exercises/meetup/example.yaml +2 -3
- data/tracks/perl6/exercises/meetup/meetup.t +7 -29
- data/tracks/perl6/exercises/nucleotide-count/Example.pm6 +1 -1
- data/tracks/perl6/exercises/nucleotide-count/NucleotideCount.pm6 +1 -1
- data/tracks/perl6/exercises/nucleotide-count/example.yaml +2 -3
- data/tracks/perl6/exercises/nucleotide-count/nucleotide-count.t +7 -29
- data/tracks/perl6/exercises/pangram/Example.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/Pangram.pm6 +1 -1
- data/tracks/perl6/exercises/pangram/example.yaml +2 -3
- data/tracks/perl6/exercises/pangram/pangram.t +7 -29
- data/tracks/perl6/exercises/phone-number/Example.pm6 +1 -1
- data/tracks/perl6/exercises/phone-number/Phone.pm6 +1 -1
- data/tracks/perl6/exercises/phone-number/example.yaml +2 -3
- data/tracks/perl6/exercises/phone-number/phone-number.t +7 -29
- data/tracks/perl6/exercises/raindrops/Example.pm6 +1 -1
- data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +1 -1
- data/tracks/perl6/exercises/raindrops/example.yaml +2 -3
- data/tracks/perl6/exercises/raindrops/raindrops.t +7 -29
- data/tracks/perl6/exercises/rna-transcription/Example.pm6 +1 -1
- data/tracks/perl6/exercises/rna-transcription/RNA.pm6 +1 -1
- data/tracks/perl6/exercises/rna-transcription/example.yaml +2 -3
- data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +7 -29
- data/tracks/perl6/exercises/robot-name/Example.pm6 +1 -1
- data/tracks/perl6/exercises/robot-name/Robot.pm6 +1 -1
- data/tracks/perl6/exercises/robot-name/example.yaml +5 -5
- data/tracks/perl6/exercises/robot-name/robot-name.t +10 -17
- data/tracks/perl6/exercises/roman-numerals/Example.pm6 +1 -1
- data/tracks/perl6/exercises/roman-numerals/RomanNumerals.pm6 +1 -1
- data/tracks/perl6/exercises/roman-numerals/example.yaml +2 -3
- data/tracks/perl6/exercises/roman-numerals/roman-numerals.t +7 -29
- data/tracks/perl6/exercises/scrabble-score/Example.pm6 +1 -1
- data/tracks/perl6/exercises/scrabble-score/Scrabble.pm6 +1 -1
- data/tracks/perl6/exercises/scrabble-score/example.yaml +2 -3
- data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +7 -29
- data/tracks/perl6/exercises/space-age/Example.pm6 +1 -1
- data/tracks/perl6/exercises/space-age/SpaceAge.pm6 +1 -1
- data/tracks/perl6/exercises/space-age/example.yaml +2 -3
- data/tracks/perl6/exercises/space-age/space-age.t +7 -29
- data/tracks/perl6/exercises/trinary/Trinary.pm6 +0 -0
- data/tracks/perl6/exercises/trinary/trinary.t +2 -5
- data/tracks/perl6/exercises/two-fer/Example.pm6 +1 -1
- data/tracks/perl6/exercises/two-fer/TwoFer.pm6 +1 -1
- data/tracks/perl6/exercises/two-fer/example.yaml +2 -8
- data/tracks/perl6/exercises/two-fer/two-fer.t +7 -33
- data/tracks/perl6/exercises/word-count/Example.pm6 +1 -1
- data/tracks/perl6/exercises/word-count/WordCount.pm6 +1 -1
- data/tracks/perl6/exercises/word-count/example.yaml +2 -3
- data/tracks/perl6/exercises/word-count/word-count.t +7 -29
- data/tracks/perl6/exercises/wordy/Example.pm6 +1 -1
- data/tracks/perl6/exercises/wordy/Wordy.pm6 +1 -1
- data/tracks/perl6/exercises/wordy/example.yaml +2 -3
- data/tracks/perl6/exercises/wordy/wordy.t +7 -29
- data/tracks/perl6/templates/test.mustache +10 -39
- data/tracks/python/config.json +10 -0
- data/tracks/python/exercises/all-your-base/all_your_base_test.py +2 -2
- data/tracks/python/exercises/binary-search/binary_search_test.py +2 -2
- data/tracks/python/exercises/binary/binary_test.py +2 -2
- data/tracks/python/exercises/bob/bob_test.py +4 -2
- data/tracks/python/exercises/bob/example.py +5 -2
- data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +2 -2
- data/tracks/python/exercises/custom-set/README.md +20 -0
- data/tracks/python/exercises/custom-set/custom_set.py +30 -0
- data/tracks/python/exercises/custom-set/custom_set_test.py +212 -0
- data/tracks/python/exercises/custom-set/example.py +45 -0
- data/tracks/python/exercises/dot-dsl/dot_dsl_test.py +20 -10
- data/tracks/python/exercises/error-handling/error_handling_test.py +2 -2
- data/tracks/python/exercises/forth/forth_test.py +18 -18
- data/tracks/python/exercises/grains/grains_test.py +2 -2
- data/tracks/python/exercises/hamming/hamming_test.py +2 -2
- data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +2 -2
- data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +2 -2
- data/tracks/python/exercises/meetup/meetup_test.py +2 -2
- data/tracks/python/exercises/minesweeper/minesweeper_test.py +2 -2
- data/tracks/python/exercises/nth-prime/nth_prime_test.py +2 -2
- data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +2 -2
- data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +2 -2
- data/tracks/python/exercises/octal/octal_test.py +2 -2
- data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +2 -2
- data/tracks/python/exercises/phone-number/phone_number_test.py +2 -2
- data/tracks/python/exercises/pov/pov_test.py +2 -2
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +2 -2
- data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +2 -2
- data/tracks/python/exercises/queen-attack/queen_attack_test.py +2 -2
- data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +2 -2
- data/tracks/python/exercises/saddle-points/saddle_points_test.py +2 -2
- data/tracks/python/exercises/say/say_test.py +2 -2
- data/tracks/python/exercises/scale-generator/scale_generator_test.py +2 -2
- data/tracks/python/exercises/series/series_test.py +2 -2
- data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +2 -2
- data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +2 -2
- data/tracks/python/exercises/tree-building/tree_building_test.py +2 -2
- data/tracks/python/exercises/triangle/example.py +14 -24
- data/tracks/python/exercises/triangle/triangle.py +6 -6
- data/tracks/python/exercises/triangle/triangle_test.py +42 -44
- data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +2 -2
- data/tracks/python/exercises/wordy/wordy_test.py +2 -2
- data/tracks/python/test/check-exercises.py +2 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81eca53e081d3529ffccdc505c2470677bcd75fa
|
4
|
+
data.tar.gz: 5c658d2fdc47d731a5c12857851e327019bfcf0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcb54de6244b11bc2ac9ade0eee35db7a0436a8fbb1eabcd8f5d6be9e46df5a4d35015df8f3f0c31ffb470b766bce0d0b07fb426566a22de1ca454809860f3a1
|
7
|
+
data.tar.gz: b188c9715563d6aa42540f7f85295b58c99841515fdcc8ef9e3322d8887006a8a08ac664bc05bf7a0875d94019e9e8901f46d0a6e4a937283162775204e9fe57
|
data/lib/trackler/version.rb
CHANGED
@@ -1,95 +1,95 @@
|
|
1
1
|
{
|
2
2
|
"exercise": "two-bucket",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.4.0",
|
4
4
|
"cases": [
|
5
5
|
{
|
6
6
|
"description": "Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one",
|
7
7
|
"property": "measure",
|
8
8
|
"input": {
|
9
|
-
"
|
10
|
-
"
|
9
|
+
"bucketOne": 3,
|
10
|
+
"bucketTwo": 5,
|
11
11
|
"goal": 1,
|
12
|
-
"
|
12
|
+
"startBucket": "one"
|
13
13
|
},
|
14
14
|
"expected": {
|
15
15
|
"moves": 4,
|
16
|
-
"
|
17
|
-
"
|
16
|
+
"goalBucket": "one",
|
17
|
+
"otherBucket": 5
|
18
18
|
}
|
19
19
|
},
|
20
20
|
{
|
21
21
|
"description": "Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two",
|
22
22
|
"property": "measure",
|
23
23
|
"input": {
|
24
|
-
"
|
25
|
-
"
|
24
|
+
"bucketOne": 3,
|
25
|
+
"bucketTwo": 5,
|
26
26
|
"goal": 1,
|
27
|
-
"
|
27
|
+
"startBucket": "two"
|
28
28
|
},
|
29
29
|
"expected": {
|
30
30
|
"moves": 8,
|
31
|
-
"
|
32
|
-
"
|
31
|
+
"goalBucket": "two",
|
32
|
+
"otherBucket": 3
|
33
33
|
}
|
34
34
|
},
|
35
35
|
{
|
36
36
|
"description": "Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one",
|
37
37
|
"property": "measure",
|
38
38
|
"input": {
|
39
|
-
"
|
40
|
-
"
|
39
|
+
"bucketOne": 7,
|
40
|
+
"bucketTwo": 11,
|
41
41
|
"goal": 2,
|
42
|
-
"
|
42
|
+
"startBucket": "one"
|
43
43
|
},
|
44
44
|
"expected": {
|
45
45
|
"moves": 14,
|
46
|
-
"
|
47
|
-
"
|
46
|
+
"goalBucket": "one",
|
47
|
+
"otherBucket": 11
|
48
48
|
}
|
49
49
|
},
|
50
50
|
{
|
51
51
|
"description": "Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two",
|
52
52
|
"property": "measure",
|
53
53
|
"input": {
|
54
|
-
"
|
55
|
-
"
|
54
|
+
"bucketOne": 7,
|
55
|
+
"bucketTwo": 11,
|
56
56
|
"goal": 2,
|
57
|
-
"
|
57
|
+
"startBucket": "two"
|
58
58
|
},
|
59
59
|
"expected": {
|
60
60
|
"moves": 18,
|
61
|
-
"
|
62
|
-
"
|
61
|
+
"goalBucket": "two",
|
62
|
+
"otherBucket": 7
|
63
63
|
}
|
64
64
|
},
|
65
65
|
{
|
66
66
|
"description": "Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two",
|
67
67
|
"property": "measure",
|
68
68
|
"input": {
|
69
|
-
"
|
70
|
-
"
|
69
|
+
"bucketOne": 1,
|
70
|
+
"bucketTwo": 3,
|
71
71
|
"goal": 3,
|
72
|
-
"
|
72
|
+
"startBucket": "two"
|
73
73
|
},
|
74
74
|
"expected": {
|
75
75
|
"moves": 1,
|
76
|
-
"
|
77
|
-
"
|
76
|
+
"goalBucket": "two",
|
77
|
+
"otherBucket": 0
|
78
78
|
}
|
79
79
|
},
|
80
80
|
{
|
81
81
|
"description": "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two",
|
82
82
|
"property": "measure",
|
83
83
|
"input": {
|
84
|
-
"
|
85
|
-
"
|
84
|
+
"bucketOne": 2,
|
85
|
+
"bucketTwo": 3,
|
86
86
|
"goal": 3,
|
87
|
-
"
|
87
|
+
"startBucket": "one"
|
88
88
|
},
|
89
89
|
"expected": {
|
90
90
|
"moves": 2,
|
91
|
-
"
|
92
|
-
"
|
91
|
+
"goalBucket": "two",
|
92
|
+
"otherBucket": 2
|
93
93
|
}
|
94
94
|
}
|
95
95
|
]
|
data/tracks/csharp/docs/ABOUT.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
|
-
C# is a
|
1
|
+
C# is a multi-paradigm, statically-typed programming language with object-oriented, declarative, functional, generic, lazy, integrated querying features and type inference.
|
2
2
|
|
3
|
-
|
3
|
+
__Statically-typed__ means that identifiers have a [type](https://en.wikipedia.org/wiki/Type_system#Static_type_checking) set at compile time--like those in Java, C++ or Haskell--instead of holding data of any type like those in Python, Ruby or JavaScript.
|
4
4
|
|
5
|
-
|
5
|
+
__Object-oriented__ means that C# provides imperative [class-based objects](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/object-oriented-programming) with features such as single inheritance, interfaces and encapsulation.
|
6
|
+
|
7
|
+
__Declarative__ means programming [what is to be done](https://stackoverflow.com/questions/1784664/what-is-the-difference-between-declarative-and-imperative-programming), as opposed to how it is done (a.k.a imperative programming) (which is an implementation detail which can distract from the domain or business logic).
|
8
|
+
|
9
|
+
__Functional__ means that [functions are first-class data types](https://livebook.manning.com/#!/book/functional-programming-in-c-sharp/chapter-1) that can be passed as arguments to and returned from other functions.
|
10
|
+
|
11
|
+
__Generic__ means that algorithms are written in terms of types [to-be-specified-later](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generic-type-parameters) that are then instantiated, when needed, for the specific types provided as parameters.
|
12
|
+
|
13
|
+
__Lazy__ [(a.k.a "deferred execution")](https://blogs.msdn.microsoft.com/pedram/2007/06/02/lazy-evaluation-in-c/) means that the compiler will put off evaluating an item until required. This lets one safely do weird stuff like operating on an infinite list--the language will only create the list up to the last value needed.
|
14
|
+
|
15
|
+
__Integrated Querying__ means the language feature called [LINQ "Language-Integrated Query"](https://msdn.microsoft.com/en-us/library/bb308959.aspx), which enables lazy querying directly within the language, not only its own objects but, also, external data sources through formats such as XML, JSON, SQL, NoSQL DBs and event streams.
|
16
|
+
|
17
|
+
__Type inference__ means that the compiler will often figure out the type of an identifier by itself so you don't have to specify it. Scala and F# both do this.
|
18
|
+
|
19
|
+
__Syntax__ is similar to that of other C-style languages such as C, C++ and Java.
|
20
|
+
|
21
|
+
__.NET__ is the managed environment within which C# runs, so you get access to the entire .NET ecosystem, including all packages on [nuget.org](http://www.nuget.org). .NET used to be Windows-only but, with the release of [.NET Core](https://www.microsoft.com/net/core) -- as well as [Mono](http://www.mono-project.com/) -- you can also use C# on Mac, Linux or Unix-based systems and on mobile platforms too.
|
22
|
+
|
23
|
+
C# also has features, amongst others, to make programming with multiple threads/processors, parallelisation, asynchrony, unmanaged code in a managed environment and language interoperability easier. It is developed and maintained by Microsoft, who provides the official [documentation](https://docs.microsoft.com/en-us/dotnet/csharp/).
|
data/tracks/dart/.travis.yml
CHANGED
data/tracks/dart/README.md
CHANGED
@@ -12,7 +12,7 @@ Clone the repo and run `pub get` to download all the dependencies for this proje
|
|
12
12
|
|
13
13
|
To run all the tests execute: `pub run test`
|
14
14
|
|
15
|
-
To create a new exercise, use the
|
15
|
+
To create a new exercise, use the executable in the tool directory: `dart bin/create_exercise.dart`
|
16
16
|
|
17
17
|
## Exercise Tests ##
|
18
18
|
|
@@ -42,4 +42,4 @@ We welcome pull requests of all kinds. No contribution is too small.
|
|
42
42
|
|
43
43
|
We encourage contributions that provide fixes and improvements to existing exercises. Please note that this track's exercises must conform to the standards determined in the [exercism/problem-specifications](https://github.com/exercism/problem-specifications) repo. Changes to the tests or documentation of a common exercise will often warrant a PR in that repo before it can be incorporated into this track's exercises. If you're unsure, then go ahead and open a GitHub issue, and we'll discuss the change.
|
44
44
|
|
45
|
-
Please read our [Contribution guidelines](CONTRIBUTING.md) on how to help this track!
|
45
|
+
Please read our [Contribution guidelines](CONTRIBUTING.md) on how to help this track!
|
@@ -1,6 +1,3 @@
|
|
1
|
-
#!/usr/bin/env dart
|
2
|
-
// vim: set syntax=dart:
|
3
|
-
|
4
1
|
import "dart:io";
|
5
2
|
import "dart:async";
|
6
3
|
import "dart:convert";
|
@@ -11,11 +8,13 @@ import "package:path/path.dart" show dirname;
|
|
11
8
|
const ME = "create-exercise";
|
12
9
|
|
13
10
|
final parser = new ArgParser()
|
14
|
-
..addSeparator("Usage: $ME
|
11
|
+
..addSeparator("Usage: $ME [--spec-path path] <slug>")
|
15
12
|
..addOption("spec-path", help: "The location of the problem-specifications directory.", valueHelp: 'path');
|
16
13
|
|
17
14
|
/** Helpers */
|
18
15
|
List<String> words(String str) {
|
16
|
+
if (str == null) return [''];
|
17
|
+
|
19
18
|
return str
|
20
19
|
.toLowerCase()
|
21
20
|
.replaceAll(new RegExp(r"[^a-z0-9]"), " ")
|
@@ -25,6 +24,8 @@ List<String> words(String str) {
|
|
25
24
|
}
|
26
25
|
|
27
26
|
String upperFirst(String str) {
|
27
|
+
if (str == null || str.length == 0) return '';
|
28
|
+
|
28
29
|
final chars = str.split("");
|
29
30
|
final first = chars.first;
|
30
31
|
|
@@ -127,7 +128,7 @@ String testCaseTemplate(String name, Map<String, Object> testCase, {bool firstTe
|
|
127
128
|
/// Based on the python `repr` function, but only works for basic types: String, Iterable, Map, and primitive types
|
128
129
|
String repr(Object x) {
|
129
130
|
if (x is String) {
|
130
|
-
x = x.replaceAll('"', r'\"').replaceAll("\n", r"\n").replaceAll(r"$", r"\$");
|
131
|
+
x = (x as String).replaceAll('"', r'\"').replaceAll("\n", r"\n").replaceAll(r"$", r"\$");
|
131
132
|
return '"$x"';
|
132
133
|
}
|
133
134
|
|
@@ -148,7 +149,7 @@ String repr(Object x) {
|
|
148
149
|
}
|
149
150
|
|
150
151
|
/// A helper method to get the inside type of an iterable
|
151
|
-
String getIterableType(
|
152
|
+
String getIterableType(Iterable iter) {
|
152
153
|
Set<String> types = iter.map(getFriendlyType).toSet();
|
153
154
|
|
154
155
|
if (types.length == 1) {
|
@@ -176,7 +177,7 @@ String getFriendlyType(Object x) {
|
|
176
177
|
return "num";
|
177
178
|
}
|
178
179
|
|
179
|
-
return x.runtimeType;
|
180
|
+
return x.runtimeType.toString();
|
180
181
|
}
|
181
182
|
|
182
183
|
// runProcess runs a process, writes any stdout/stderr output.
|
@@ -217,6 +218,7 @@ Future main(args) async {
|
|
217
218
|
File file = new File(filename);
|
218
219
|
final specification = JSON.decode(await file.readAsString());
|
219
220
|
testCasesString = testCaseTemplate(name, specification);
|
221
|
+
print("Found: ${arguments['spec-path']}/exercises/$name/canonical-data.json");
|
220
222
|
} on FileSystemException {
|
221
223
|
stderr.write("Could not open file '$filename', exiting.\n");
|
222
224
|
exit(1);
|
@@ -224,6 +226,8 @@ Future main(args) async {
|
|
224
226
|
stderr.write("File '$filename' is not valid JSON, exiting.\n");
|
225
227
|
exit(1);
|
226
228
|
}
|
229
|
+
} else {
|
230
|
+
print("Could not find: ${arguments['spec-path']}/exercises/$name/canonical-data.json");
|
227
231
|
}
|
228
232
|
|
229
233
|
if (await exerciseDir.exists()) {
|
@@ -257,10 +261,10 @@ Future main(args) async {
|
|
257
261
|
// The output from file generation is not always well-formatted, use dartfmt to clean it up
|
258
262
|
final fmtSuccess = await runProcess("dartfmt", ["-l", "120", "-w", exerciseDir.path]);
|
259
263
|
if (fmtSuccess) {
|
260
|
-
|
261
|
-
|
264
|
+
stdout.write("Successfully created a rough-draft of tests at '$testFileName'.\n");
|
265
|
+
stdout.write("You should check this over and fix or refine as necessary.\n");
|
262
266
|
} else {
|
263
|
-
|
267
|
+
stderr.write("Warning: dartfmt exited with an error, files in '${exerciseDir.path}' may be malformed.\n");
|
264
268
|
}
|
265
269
|
|
266
270
|
// Install deps
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import 'package:test/test.dart';
|
2
|
+
import '../bin/create_exercise.dart';
|
3
|
+
|
4
|
+
void main() {
|
5
|
+
group('create-exercise tool', () {
|
6
|
+
group('helpers', () {
|
7
|
+
group('words', () {
|
8
|
+
test('null returns empty list', () {
|
9
|
+
expect(words(null), equals(['']));
|
10
|
+
});
|
11
|
+
|
12
|
+
test('empty string returns empty list', () {
|
13
|
+
expect(words(''), equals(['']));
|
14
|
+
});
|
15
|
+
|
16
|
+
test('single word returns list with single element', () {
|
17
|
+
expect(words('foobar'), equals(['foobar']));
|
18
|
+
});
|
19
|
+
|
20
|
+
test('upper case characters are converted to lower case', () {
|
21
|
+
expect(words('FOOBAR'), equals(['foobar']));
|
22
|
+
});
|
23
|
+
|
24
|
+
test('words separated by a space become individual list elements', () {
|
25
|
+
expect(words('foo bar'), equals(['foo', 'bar']));
|
26
|
+
});
|
27
|
+
|
28
|
+
test('all symbols are replaced by a space', () {
|
29
|
+
expect(words('foo@bar'), equals(['foo', 'bar']));
|
30
|
+
});
|
31
|
+
|
32
|
+
test('words can only contain letters and digits', () {
|
33
|
+
expect(words('foo bar...123'), equals(['foo', 'bar', '123']));
|
34
|
+
});
|
35
|
+
|
36
|
+
test('multiple occurrences of spaces are trimmed', () {
|
37
|
+
expect(words(' foo bar '), equals(['foo', 'bar']));
|
38
|
+
});
|
39
|
+
|
40
|
+
test('all symbols are discarded', () {
|
41
|
+
expect(words('<foobar>'), equals(['foobar']));
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
group('upperFirst()', () {
|
46
|
+
test('null returns empty string', () {
|
47
|
+
expect(upperFirst(null), equals(''));
|
48
|
+
});
|
49
|
+
|
50
|
+
test('empty string returns empty string', () {
|
51
|
+
expect(upperFirst(''), equals(''));
|
52
|
+
});
|
53
|
+
|
54
|
+
test('a single lower case character is converted to upper case', () {
|
55
|
+
expect(upperFirst('a'), equals('A'));
|
56
|
+
});
|
57
|
+
|
58
|
+
test('a single upper case character remains upper case', () {
|
59
|
+
expect(upperFirst('A'), equals('A'));
|
60
|
+
});
|
61
|
+
|
62
|
+
test('a digit remains the same', () {
|
63
|
+
expect(upperFirst('0'), equals('0'));
|
64
|
+
});
|
65
|
+
|
66
|
+
test('a symbol remains the same', () {
|
67
|
+
expect(upperFirst('?'), equals('?'));
|
68
|
+
});
|
69
|
+
|
70
|
+
test('a lower case string returns the same string capitalized', () {
|
71
|
+
expect(upperFirst('foobar'), equals('Foobar'));
|
72
|
+
});
|
73
|
+
|
74
|
+
test('a capitalized string remains the same', () {
|
75
|
+
expect(upperFirst('Foobar'), equals('Foobar'));
|
76
|
+
});
|
77
|
+
|
78
|
+
test('only the first word in a string is capitalized', () {
|
79
|
+
expect(upperFirst('foo bar'), equals('Foo bar'));
|
80
|
+
});
|
81
|
+
});
|
82
|
+
|
83
|
+
group('camelCase()', () {
|
84
|
+
test('a lower case string remains the same', () {
|
85
|
+
expect(camelCase('foobar'), equals('foobar'));
|
86
|
+
});
|
87
|
+
|
88
|
+
test('returns capitalized string if isUpperFirst is true', () {
|
89
|
+
expect(camelCase('foobar', isUpperFirst: true), equals('Foobar'));
|
90
|
+
});
|
91
|
+
|
92
|
+
test('every word after the first is capitalized', () {
|
93
|
+
expect(camelCase('foo bar'), equals('fooBar'));
|
94
|
+
});
|
95
|
+
|
96
|
+
test('every word is capitalized if isUpperFirst is true', () {
|
97
|
+
expect(camelCase('foo bar', isUpperFirst: true), equals('FooBar'));
|
98
|
+
});
|
99
|
+
});
|
100
|
+
|
101
|
+
group('pascalCase()', () {
|
102
|
+
test('the first character is converted to upper case', () {
|
103
|
+
expect(pascalCase('foobar'), equals('Foobar'));
|
104
|
+
});
|
105
|
+
|
106
|
+
test('every word is capitalized', () {
|
107
|
+
expect(pascalCase('foo bar'), equals('FooBar'));
|
108
|
+
});
|
109
|
+
});
|
110
|
+
|
111
|
+
group('snakeCase()', () {
|
112
|
+
test('every word is separated by an underscore', () {
|
113
|
+
expect(snakeCase('foo bar'), equals('foo_bar'));
|
114
|
+
});
|
115
|
+
|
116
|
+
test('symbols are replaced by an underscore', () {
|
117
|
+
expect(snakeCase('foo-bar'), equals('foo_bar'));
|
118
|
+
});
|
119
|
+
});
|
120
|
+
|
121
|
+
group('kebabCase()', () {
|
122
|
+
test('every word is separated by a dash', () {
|
123
|
+
expect(kebabCase('foo bar'), equals('foo-bar'));
|
124
|
+
});
|
125
|
+
|
126
|
+
test('symbols are replaced by a dash', () {
|
127
|
+
expect(kebabCase('foo_bar'), equals('foo-bar'));
|
128
|
+
});
|
129
|
+
});
|
130
|
+
});
|
131
|
+
});
|
132
|
+
}
|
@@ -5,7 +5,7 @@ let rec foldl folder state list =
|
|
5
5
|
| [] -> state
|
6
6
|
| x::xs -> foldl folder (folder state x) xs
|
7
7
|
|
8
|
-
let rec foldr folder list
|
8
|
+
let rec foldr folder state list =
|
9
9
|
list
|
10
10
|
|> List.rev
|
11
11
|
|> foldl (fun acc item -> folder item acc) state
|
@@ -14,10 +14,10 @@ let length list = foldl (fun acc _ -> acc + 1) 0 list
|
|
14
14
|
|
15
15
|
let reverse list = foldl (fun acc item -> item :: acc) [] list
|
16
16
|
|
17
|
-
let map f list = foldr (fun item acc -> f item :: acc)
|
17
|
+
let map f list = foldr (fun item acc -> f item :: acc) [] list
|
18
18
|
|
19
|
-
let filter f list = foldr (fun item acc -> if f item then item :: acc else acc)
|
19
|
+
let filter f list = foldr (fun item acc -> if f item then item :: acc else acc) [] list
|
20
20
|
|
21
|
-
let append xs ys = foldr (fun item acc -> item :: acc) xs
|
21
|
+
let append xs ys = foldr (fun item acc -> item :: acc) ys xs
|
22
22
|
|
23
|
-
let concat xs = foldr append
|
23
|
+
let concat xs = foldr append [] xs
|