trackler 2.2.1.137 → 2.2.1.138

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/diffie-hellman/canonical-data.json +72 -0
  4. data/problem-specifications/exercises/yacht/description.md +2 -2
  5. data/tracks/csharp/exercises/sgf-parsing/Example.cs +1 -1
  6. data/tracks/csharp/exercises/sgf-parsing/SgfParsingTest.cs +1 -1
  7. data/tracks/csharp/exercises/sublist/SublistTest.cs +37 -78
  8. data/tracks/csharp/generators/Exercises/Sublist.cs +32 -0
  9. data/tracks/elisp/exercises/bob/README.md +2 -0
  10. data/tracks/elisp/exercises/bob/bob-test.el +60 -15
  11. data/tracks/elisp/exercises/bob/example.el +15 -5
  12. data/tracks/elisp/exercises/hamming/hamming-test.el +1 -1
  13. data/tracks/fsharp/build.ps1 +3 -3
  14. data/tracks/fsharp/build.sh +3 -3
  15. data/tracks/fsharp/exercises/bracket-push/BracketPushTest.fs +5 -1
  16. data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifierTest.fs +5 -1
  17. data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +1 -1
  18. data/tracks/fsharp/exercises/pov/PovTest.fs +6 -1
  19. data/tracks/fsharp/exercises/react/Example.fs +2 -2
  20. data/tracks/fsharp/exercises/react/React.fsproj +1 -0
  21. data/tracks/fsharp/exercises/react/ReactTest.fs +55 -33
  22. data/tracks/fsharp/exercises/series/Example.fs +2 -12
  23. data/tracks/fsharp/exercises/series/SeriesTest.fs +33 -56
  24. data/tracks/fsharp/generators/Generators.fs +81 -46
  25. data/tracks/idris/exercises/rna-transcription/src/{example.idr → Example.idr} +0 -0
  26. data/tracks/java/config.json +14 -0
  27. data/tracks/java/exercises/acronym/src/test/java/AcronymTest.java +10 -10
  28. data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +39 -39
  29. data/tracks/java/exercises/grep/.meta/hints.md +58 -0
  30. data/tracks/java/exercises/grep/.meta/src/reference/java/GrepTool.java +65 -0
  31. data/tracks/java/exercises/grep/.meta/version +1 -0
  32. data/tracks/java/exercises/grep/README.md +145 -0
  33. data/tracks/java/exercises/grep/build.gradle +18 -0
  34. data/tracks/java/exercises/grep/src/main/java/.keep +0 -0
  35. data/tracks/java/exercises/grep/src/test/java/GrepToolTest.java +395 -0
  36. data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +36 -36
  37. data/tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java +36 -36
  38. data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +14 -14
  39. data/tracks/java/exercises/poker/src/test/java/PokerTest.java +40 -40
  40. data/tracks/java/exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java +10 -10
  41. data/tracks/java/exercises/settings.gradle +1 -0
  42. data/tracks/ocaml/exercises/anagram/example.ml +1 -1
  43. data/tracks/ocaml/exercises/change/example.ml +1 -1
  44. data/tracks/ocaml/exercises/custom-set/example.ml +4 -3
  45. data/tracks/ocaml/exercises/custom-set/test.ml +0 -1
  46. data/tracks/ocaml/exercises/dominoes/test.ml +1 -1
  47. data/tracks/ocaml/exercises/etl/example.ml +1 -1
  48. data/tracks/ocaml/exercises/grade-school/example.ml +1 -1
  49. data/tracks/ocaml/exercises/palindrome-products/example.ml +2 -2
  50. data/tracks/ocaml/exercises/prime-factors/example.ml +1 -1
  51. data/tracks/ocaml/exercises/robot-name/test.ml +1 -1
  52. data/tracks/ocaml/exercises/triangle/example.ml +1 -1
  53. data/tracks/ocaml/make-exercise.sh +1 -0
  54. data/tracks/ocaml/tools/test-generator/src/controller.ml +1 -1
  55. data/tracks/perl5/exercises/raindrops/.meta/solutions/Raindrops.pm +13 -12
  56. data/tracks/perl5/exercises/raindrops/raindrops.t +166 -111
  57. data/tracks/perl6/docs/INSTALLATION.md +1 -3
  58. data/tracks/perl6/exercises/raindrops/.meta/exercise-data.yaml +5 -5
  59. data/tracks/perl6/exercises/raindrops/.meta/solutions/Raindrops.pm6 +2 -2
  60. data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +2 -2
  61. data/tracks/perl6/exercises/raindrops/raindrops.t +3 -3
  62. data/tracks/python/exercises/food-chain/example.py +11 -2
  63. data/tracks/python/exercises/food-chain/food_chain_test.py +48 -45
  64. data/tracks/python/exercises/pov/pov_test.py +12 -1
  65. data/tracks/python/exercises/series/README.md +6 -6
  66. data/tracks/python/exercises/series/example.py +2 -3
  67. data/tracks/python/exercises/series/series_test.py +27 -28
  68. data/tracks/python/exercises/sgf-parsing/example.py +1 -1
  69. data/tracks/python/exercises/sgf-parsing/sgf_parsing_test.py +1 -1
  70. data/tracks/python/exercises/yacht/README.md +2 -2
  71. data/tracks/ruby/Gemfile +0 -1
  72. data/tracks/ruby/README.md +23 -0
  73. data/tracks/ruby/bin/generate +1 -0
  74. data/tracks/ruby/exercises/complex-numbers/complex_numbers_test.rb +1 -1
  75. data/tracks/ruby/lib/generator.rb +1 -2
  76. data/tracks/ruby/lib/generator/command_line.rb +3 -0
  77. data/tracks/ruby/lib/generator/command_line/generator_optparser.rb +1 -0
  78. data/tracks/ruby/lib/generator/exercise.rb +2 -0
  79. data/tracks/ruby/lib/generator/exercise_case.rb +3 -0
  80. data/tracks/ruby/lib/generator/files.rb +1 -0
  81. data/tracks/ruby/lib/generator/files/metadata_files.rb +2 -0
  82. data/tracks/ruby/lib/generator/files/track_files.rb +1 -0
  83. data/tracks/ruby/lib/generator/implementation.rb +1 -0
  84. data/tracks/ruby/lib/generator/repository.rb +3 -0
  85. data/tracks/ruby/lib/generator/template_values.rb +1 -0
  86. data/tracks/ruby/test/generator/case_values_test.rb +2 -0
  87. data/tracks/ruby/test/generator/command_line_test.rb +1 -0
  88. data/tracks/ruby/test/generator/files/metadata_files_test.rb +2 -0
  89. data/tracks/ruby/test/generator/files/track_files_test.rb +1 -0
  90. data/tracks/ruby/test/generator/implementation_test.rb +1 -0
  91. data/tracks/ruby/test/tasks/exercise_test.rb +1 -0
  92. data/tracks/ruby/test/tasks/exercise_test_tasks_test.rb +2 -0
  93. data/tracks/ruby/test/test_helper.rb +1 -3
  94. data/tracks/rust/config.json +12 -0
  95. data/tracks/rust/exercises/atbash-cipher/src/lib.rs +9 -0
  96. data/tracks/rust/exercises/hamming/src/lib.rs +6 -0
  97. data/tracks/rust/exercises/isogram/src/lib.rs +3 -0
  98. data/tracks/rust/exercises/luhn/src/lib.rs +4 -0
  99. data/tracks/rust/exercises/palindrome-products/.meta/test-in-release-mode +1 -0
  100. data/tracks/rust/exercises/palindrome-products/Cargo.toml +6 -0
  101. data/tracks/rust/exercises/palindrome-products/README.md +72 -0
  102. data/tracks/rust/exercises/palindrome-products/example.rs +25 -0
  103. data/tracks/rust/exercises/palindrome-products/src/lib.rs +22 -0
  104. data/tracks/rust/exercises/palindrome-products/tests/palindrome-products.rs +57 -0
  105. data/tracks/rust/exercises/pangram/src/lib.rs +4 -0
  106. data/tracks/rust/exercises/run-length-encoding/src/lib.rs +7 -0
  107. data/tracks/rust/exercises/say/src/lib.rs +3 -4
  108. data/tracks/rust/exercises/scrabble-score/src/lib.rs +4 -0
  109. data/tracks/rust/exercises/word-count/src/lib.rs +6 -0
  110. data/tracks/scheme/exercises/hello-world/example.scm +1 -4
  111. data/tracks/scheme/exercises/hello-world/hello-world-test.scm +1 -5
  112. data/tracks/scheme/exercises/scrabble-score/scrabble-score-test.scm +2 -2
  113. data/tracks/typescript/config.json +30 -0
  114. data/tracks/typescript/exercises/queen-attack/README.md +59 -0
  115. data/tracks/typescript/exercises/queen-attack/package.json +36 -0
  116. data/tracks/typescript/exercises/queen-attack/queen-attack.example.ts +56 -0
  117. data/tracks/typescript/exercises/queen-attack/queen-attack.test.ts +71 -0
  118. data/tracks/typescript/exercises/queen-attack/queen-attack.ts +0 -0
  119. data/tracks/typescript/exercises/queen-attack/tsconfig.json +22 -0
  120. data/tracks/typescript/exercises/queen-attack/tslint.json +127 -0
  121. data/tracks/typescript/exercises/queen-attack/yarn.lock +2624 -0
  122. data/tracks/typescript/exercises/spiral-matrix/README.md +56 -0
  123. data/tracks/typescript/exercises/spiral-matrix/package.json +36 -0
  124. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.example.ts +33 -0
  125. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.test.ts +49 -0
  126. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.ts +0 -0
  127. data/tracks/typescript/exercises/spiral-matrix/tsconfig.json +22 -0
  128. data/tracks/typescript/exercises/spiral-matrix/tslint.json +127 -0
  129. data/tracks/typescript/exercises/spiral-matrix/yarn.lock +2624 -0
  130. metadata +35 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60bf2574faa34a60a9794b94d789c9e73fb4cbe1
4
- data.tar.gz: 40a8dc9eaba4aae1b7dacc47d7f7df71c2ad0ef5
3
+ metadata.gz: 904ea15d99f928d3a60c4a94f9f6f487b5c56bb4
4
+ data.tar.gz: 5e14581709b274c20adacd33233c8e268534c83e
5
5
  SHA512:
6
- metadata.gz: 2f84292883fa84fe0e3531f411e790247ea3f405a2ac4073b19e2330952b6e088598c41f900d47c79bf7ebb3445b624f639fd11b3a660e60c08d829afe223d71
7
- data.tar.gz: 62435ae5728a1ff10a08382ea7a11c43985d97f5842a33ea1b27923c43c2a90fba640ccd42e3f71228a7a5ab9b1cf3b253260d93537d8f8201b7150b83991925
6
+ metadata.gz: e02921838fab6c43ad19a3eabbf7d832e1e6f6568065420af7fa31484393f601d6e990af8eacf8093e5e3caf7885c07aa2436d2eb417977bcebc68f7cac0f2de
7
+ data.tar.gz: cb188e5c1cea7a4e79f2e8bc6af2561c7b4113cbeef75feab4921d475cb5d3315a20929ade4f705a9c6a51bb1974ec6959a365065e1f7aefd6ae780c4a9f4533
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.2.1.137"
2
+ VERSION = "2.2.1.138"
3
3
  end
@@ -0,0 +1,72 @@
1
+ {
2
+ "exercise": "diffie-hellman",
3
+ "version": "1.0.0",
4
+ "comments": [
5
+ "Optional tests to consider:",
6
+ "* Validation of parameters:",
7
+ " Validate that `p`, `g` are valid.",
8
+ " Validate that keys given as inputs are valid.",
9
+ " Resources that show what happens if parameters are not validated:",
10
+ " http://cryptopals.com/sets/5/challenges/34",
11
+ " http://cryptopals.com/sets/5/challenges/35",
12
+ "* Large numbers:",
13
+ " Although the calculations fundamentally do not require large numbers,",
14
+ " this is a reasonable real-world use for them",
15
+ " and it may be instructive to have an exercise on their use.",
16
+ " Consult tracks with this exercise (such as the Go track) for possible inputs to use."
17
+ ],
18
+ "cases": [
19
+ {
20
+ "description": "private key is in range 1 .. p",
21
+ "property": "privateKeyIsInRange",
22
+ "input": {},
23
+ "expected": {
24
+ "greaterThan": 1,
25
+ "lessThan": "p"
26
+ }
27
+ },
28
+ {
29
+ "description": "private key is random",
30
+ "property": "privateKeyIsRandom",
31
+ "input": {},
32
+ "expected": {
33
+ "random": true
34
+ }
35
+ },
36
+ {
37
+ "description": "can calculate public key using private key",
38
+ "property": "publicKey",
39
+ "input": {
40
+ "p": 23,
41
+ "g": 5,
42
+ "privateKey": 6
43
+ },
44
+ "expected": 8
45
+ },
46
+ {
47
+ "description": "can calculate secret using other party's public key",
48
+ "property": "secret",
49
+ "input": {
50
+ "p": 23,
51
+ "theirPublicKey": 19,
52
+ "myPrivateKey": 6
53
+ },
54
+ "expected": 2
55
+ },
56
+ {
57
+ "description": "key exchange",
58
+ "property": "keyExchange",
59
+ "input": {
60
+ "p": 23,
61
+ "g": 5,
62
+ "alicePrivateKey": "privateKey(p)",
63
+ "bobPrivateKey": "privateKey(p)",
64
+ "alicePublicKey": "publicKey(p, g, alicePrivateKey)",
65
+ "bobPublicKey": "publicKey(p, g, bobPrivateKey)",
66
+ "secretA": "secret(p, bobPublicKey, alicePrivateKey)",
67
+ "secretB": "secret(p, alicePublicKey, bobPrivateKey)"
68
+ },
69
+ "expected": "secretA == secretB"
70
+ }
71
+ ]
72
+ }
@@ -17,7 +17,7 @@ category chosen.
17
17
  Sixes 6 × number of sixes 2 3 4 5 6 scores 6
18
18
  Full House Total of the dice 3 3 3 5 5 scores 19
19
19
  Four of a Kind Total of the four dice 4 4 4 4 6 scores 16
20
- Little Straight 30 points 1 2 3 4 5 scores 30
20
+ Little Straight 30 points 1 2 3 4 5 scores 30
21
21
  Big Straight 30 points 2 3 4 5 6 scores 30
22
22
  Choice Sum of the dice 2 3 3 4 6 scores 18
23
23
  Yacht 50 points 4 4 4 4 4 scores 50
@@ -26,7 +26,7 @@ If the dice do not satisfy the requirements of a category, the score is zero.
26
26
  If, for example, *Four Of A Kind* is entered in the *Yacht* category, zero
27
27
  points are scored. A *Yacht* scores zero if entered in the *Full House* category.
28
28
 
29
- ## Task
29
+ ## Task
30
30
  Given a list of values for five dice and a category, your solution should return
31
31
  the score of the dice for that category. If the dice do not satisfy the requirements
32
32
  of the category your solution should return 0. You can assume that five values
@@ -17,7 +17,7 @@ public SgfTree(IDictionary<string, string[]> data, params SgfTree[] children)
17
17
 
18
18
  public static class SgfParser
19
19
  {
20
- private static char Unescape(char c) => c == 'n' || c == 'r' || c == 't' ? ' ' : c;
20
+ private static char Unescape(char c) => c == 'n' ? '\n' : c == 'r' || c == 't' ? ' ' : c;
21
21
  private static string ToString(IEnumerable<char> chars) => new string(chars.ToArray());
22
22
 
23
23
  private static readonly Parser<char> NormalChar = Parse.Char(c => c != '\\' && c != ']', "Normal char");
@@ -112,7 +112,7 @@ public void Multiple_properties()
112
112
  public void Escaped_property()
113
113
  {
114
114
  const string input = @"(;A[\]b\nc\nd\t\te \n\]])";
115
- var expected = TreeWithNoChildren(CreateData("A", @"]b c d e ]"));
115
+ var expected = TreeWithNoChildren(CreateData("A", "]b\nc\nd e \n]"));
116
116
  Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance);
117
117
  }
118
118
 
@@ -1,150 +1,109 @@
1
- using System.Collections.Generic;
2
- using System.Linq;
1
+ // This file was auto-generated based on version 1.1.0 of the canonical data.
2
+
3
3
  using Xunit;
4
+ using System.Collections.Generic;
4
5
 
5
6
  public class SublistTest
6
7
  {
7
8
  [Fact]
8
- public void Empty_equals_empty()
9
+ public void Empty_lists()
9
10
  {
10
- var list1 = new List<int>();
11
- var list2 = new List<int>();
12
- Assert.Equal(SublistType.Equal, Sublist.Classify(list1, list2));
11
+ Assert.Equal(SublistType.Equal, Sublist.Classify(new List<int>() { }, new List<int>() { }));
13
12
  }
14
13
 
15
14
  [Fact(Skip = "Remove to run test")]
16
- public void Empty_is_a_sublist_of_anything()
15
+ public void Empty_list_within_non_empty_list()
17
16
  {
18
- var list1 = new List<int>();
19
- var list2 = new List<int> { 1, 2, 3, 4 };
20
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
17
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { }, new List<int>() { 1, 2, 3 }));
21
18
  }
22
19
 
23
20
  [Fact(Skip = "Remove to run test")]
24
- public void Anything_is_a_superlist_of_empty()
21
+ public void Non_empty_list_contains_empty_list()
25
22
  {
26
- var list1 = new List<int> { 1, 2, 3, 4 };
27
- var list2 = new List<int>();
28
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
23
+ Assert.Equal(SublistType.Superlist, Sublist.Classify(new List<int>() { 1, 2, 3 }, new List<int>() { }));
29
24
  }
30
25
 
31
26
  [Fact(Skip = "Remove to run test")]
32
- public void One_is_not_two()
27
+ public void List_equals_itself()
33
28
  {
34
- var list1 = new List<int> { 1 };
35
- var list2 = new List<int> { 2 };
36
- Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2));
29
+ Assert.Equal(SublistType.Equal, Sublist.Classify(new List<int>() { 1, 2, 3 }, new List<int>() { 1, 2, 3 }));
37
30
  }
38
31
 
39
32
  [Fact(Skip = "Remove to run test")]
40
- public void Compare_larger_equal_lists()
33
+ public void Different_lists()
41
34
  {
42
- var list1 = new List<char>(Enumerable.Repeat('x', 1000));
43
- var list2 = new List<char>(Enumerable.Repeat('x', 1000));
44
- Assert.Equal(SublistType.Equal, Sublist.Classify(list1, list2));
35
+ Assert.Equal(SublistType.Unequal, Sublist.Classify(new List<int>() { 1, 2, 3 }, new List<int>() { 2, 3, 4 }));
45
36
  }
46
37
 
47
38
  [Fact(Skip = "Remove to run test")]
48
- public void Sublist_at_start()
39
+ public void False_start()
49
40
  {
50
- var list1 = new List<int> { 1, 2, 3 };
51
- var list2 = new List<int> { 1, 2, 3, 4, 5 };
52
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
41
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { 1, 2, 5 }, new List<int>() { 0, 1, 2, 3, 1, 2, 5, 6 }));
53
42
  }
54
43
 
55
44
  [Fact(Skip = "Remove to run test")]
56
- public void Sublist_in_middle()
45
+ public void Consecutive()
57
46
  {
58
- var list1 = new List<int> { 4, 3, 2 };
59
- var list2 = new List<int> { 5, 4, 3, 2, 1 };
60
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
47
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { 1, 1, 2 }, new List<int>() { 0, 1, 1, 1, 2, 1, 2 }));
61
48
  }
62
49
 
63
50
  [Fact(Skip = "Remove to run test")]
64
- public void Sublist_at_end()
65
- {
66
- var list1 = new List<int> { 3, 4, 5 };
67
- var list2 = new List<int> { 1, 2, 3, 4, 5 };
68
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
69
- }
70
-
71
- [Fact(Skip = "Remove to run test")]
72
- public void Partially_matching_sublist_at_start()
51
+ public void Sublist_at_start()
73
52
  {
74
- var list1 = new List<int> { 1, 1, 2 };
75
- var list2 = new List<int> { 1, 1, 1, 2 };
76
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
53
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { 0, 1, 2 }, new List<int>() { 0, 1, 2, 3, 4, 5 }));
77
54
  }
78
55
 
79
56
  [Fact(Skip = "Remove to run test")]
80
- public void Sublist_early_in_huge_list()
57
+ public void Sublist_in_middle()
81
58
  {
82
- var list1 = new List<int> { 3, 4, 5 };
83
- var list2 = new List<int>(Enumerable.Range(1, 1000000));
84
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
59
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { 2, 3, 4 }, new List<int>() { 0, 1, 2, 3, 4, 5 }));
85
60
  }
86
61
 
87
62
  [Fact(Skip = "Remove to run test")]
88
- public void Huge_sublist_not_in_huge_list()
63
+ public void Sublist_at_end()
89
64
  {
90
- var list1 = new List<int>(Enumerable.Range(10, 1000001));
91
- var list2 = new List<int>(Enumerable.Range(1, 1000000));
92
- Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2));
65
+ Assert.Equal(SublistType.Sublist, Sublist.Classify(new List<int>() { 3, 4, 5 }, new List<int>() { 0, 1, 2, 3, 4, 5 }));
93
66
  }
94
67
 
95
68
  [Fact(Skip = "Remove to run test")]
96
- public void Superlist_at_start()
69
+ public void At_start_of_superlist()
97
70
  {
98
- var list1 = new List<int> { 1, 2, 3, 4, 5 };
99
- var list2 = new List<int> { 1, 2, 3 };
100
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
71
+ Assert.Equal(SublistType.Superlist, Sublist.Classify(new List<int>() { 0, 1, 2, 3, 4, 5 }, new List<int>() { 0, 1, 2 }));
101
72
  }
102
73
 
103
74
  [Fact(Skip = "Remove to run test")]
104
- public void Superlist_in_middle()
75
+ public void In_middle_of_superlist()
105
76
  {
106
- var list1 = new List<int> { 5, 4, 3, 2, 1 };
107
- var list2 = new List<int> { 4, 3, 2 };
108
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
77
+ Assert.Equal(SublistType.Superlist, Sublist.Classify(new List<int>() { 0, 1, 2, 3, 4, 5 }, new List<int>() { 2, 3 }));
109
78
  }
110
79
 
111
80
  [Fact(Skip = "Remove to run test")]
112
- public void Superlist_at_end()
81
+ public void At_end_of_superlist()
113
82
  {
114
- var list1 = new List<int> { 1, 2, 3, 4, 5 };
115
- var list2 = new List<int> { 3, 4, 5 };
116
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
83
+ Assert.Equal(SublistType.Superlist, Sublist.Classify(new List<int>() { 0, 1, 2, 3, 4, 5 }, new List<int>() { 3, 4, 5 }));
117
84
  }
118
85
 
119
86
  [Fact(Skip = "Remove to run test")]
120
- public void Partially_matching_superlist_at_start()
87
+ public void First_list_missing_element_from_second_list()
121
88
  {
122
- var list1 = new List<int> { 1, 1, 1, 2 };
123
- var list2 = new List<int> { 1, 1, 2 };
124
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
89
+ Assert.Equal(SublistType.Unequal, Sublist.Classify(new List<int>() { 1, 3 }, new List<int>() { 1, 2, 3 }));
125
90
  }
126
91
 
127
92
  [Fact(Skip = "Remove to run test")]
128
- public void Superlist_early_in_huge_list()
93
+ public void Second_list_missing_element_from_first_list()
129
94
  {
130
- var list1 = new List<int>(Enumerable.Range(1, 1000000));
131
- var list2 = new List<int> { 3, 4, 5 };
132
- Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2));
95
+ Assert.Equal(SublistType.Unequal, Sublist.Classify(new List<int>() { 1, 2, 3 }, new List<int>() { 1, 3 }));
133
96
  }
134
97
 
135
98
  [Fact(Skip = "Remove to run test")]
136
- public void Recurring_values_sublist()
99
+ public void Order_matters_to_a_list()
137
100
  {
138
- var list1 = new List<int> { 1, 2, 1, 2, 3 };
139
- var list2 = new List<int> { 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 };
140
- Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2));
101
+ Assert.Equal(SublistType.Unequal, Sublist.Classify(new List<int>() { 1, 2, 3 }, new List<int>() { 3, 2, 1 }));
141
102
  }
142
103
 
143
104
  [Fact(Skip = "Remove to run test")]
144
- public void Recurring_values_unequal()
105
+ public void Same_digits_but_different_numbers()
145
106
  {
146
- var list1 = new List<int> { 1, 2, 1, 2, 3 };
147
- var list2 = new List<int> { 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 };
148
- Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2));
107
+ Assert.Equal(SublistType.Unequal, Sublist.Classify(new List<int>() { 1, 0, 1 }, new List<int>() { 10, 1 }));
149
108
  }
150
109
  }
@@ -0,0 +1,32 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using Generators.Input;
4
+ using Generators.Output;
5
+ using Humanizer;
6
+
7
+ namespace Generators.Exercises
8
+ {
9
+ public class Sublist : GeneratorExercise
10
+ {
11
+ protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string>() { typeof(IList<int>).Namespace };
12
+
13
+ private UnescapedValue InputValues(int[] list)
14
+ {
15
+ var template = (list != null) ? string.Join(", ", Array.ConvertAll<int, string>(list, (x) => { return $"{x}"; })) : "";
16
+ return new UnescapedValue($"new List<int>() {{ {template} }}".Replace(" ", " "));
17
+ }
18
+ protected override void UpdateCanonicalData(CanonicalData canonicalData)
19
+ {
20
+ foreach (var canonicalDataCase in canonicalData.Cases)
21
+ {
22
+ var input = canonicalDataCase.Properties["input"] as Dictionary<string, object>;
23
+ input["listOne"] = InputValues(input["listOne"] as int[]);
24
+ input["listTwo"] = InputValues(input["listTwo"] as int[]);
25
+
26
+ canonicalDataCase.Property = "classify";
27
+ canonicalDataCase.Properties["expected"] = new UnescapedValue($"SublistType.{(canonicalDataCase.Properties["expected"] as string).Dehumanize()}");
28
+ }
29
+ }
30
+ }
31
+ }
32
+
@@ -6,6 +6,8 @@ Bob answers 'Sure.' if you ask him a question.
6
6
 
7
7
  He answers 'Whoa, chill out!' if you yell at him.
8
8
 
9
+ He answers 'Calm down, I know what I'm doing!' if you yell a question at him.
10
+
9
11
  He says 'Fine. Be that way!' if you address him without actually saying
10
12
  anything.
11
13
 
@@ -1,43 +1,64 @@
1
1
  ;;; bob-test.el --- ERT tests for Bob (exercism)
2
2
 
3
3
  ;;; Commentary:
4
+ ;; Common test data version: 1.2.0 6dc2014
4
5
 
5
6
  ;;; Code:
6
7
 
7
8
  (load-file "bob.el")
8
9
 
9
10
 
10
- (ert-deftest responds-to-something ()
11
+ (ert-deftest responds-to-stating-something ()
11
12
  (should (string= "Whatever." (response-for "Tom-ay-to, tom-aaaah-to."))))
12
13
 
13
- (ert-deftest responds-to-shouts ()
14
+ (ert-deftest responds-to-shouting ()
14
15
  (should
15
16
  (string= "Whoa, chill out!" (response-for "WATCH OUT!"))))
16
17
 
17
- (ert-deftest responds-to-questions ()
18
+ (ert-deftest responds-to-shouting-gibberish ()
19
+ (should
20
+ (string= "Whoa, chill out!" (response-for "FCECDFCAAB"))))
21
+
22
+ (ert-deftest responds-to-asking-a-question ()
18
23
  (should
19
24
  (string= "Sure." (response-for "Does this cryogenic chamber make me look fat?"))))
20
25
 
21
- (ert-deftest responds-to-forceful-talking ()
26
+ (ert-deftest responds-to-asking-a-numeric-question ()
22
27
  (should
23
- (string= "Whatever." (response-for "Let's go make out behind the gym!"))))
28
+ (string= "Sure." (response-for "You are, what, like 15?"))))
24
29
 
25
- (ert-deftest responds-to-acronyms ()
30
+ (ert-deftest responds-to-asking-gibberish ()
26
31
  (should
27
- (string= "Whatever." (response-for "It's OK if you don't want to go to the DMV."))))
32
+ (string= "Sure." (response-for "fffbbcbeab?"))))
28
33
 
29
- (ert-deftest responds-to-forceful-questions ()
34
+ (ert-deftest responds-to-talking-forcefully ()
30
35
  (should
31
- (string= "Whoa, chill out!" (response-for "WHAT THE HELL WERE YOU THINKING?"))))
36
+ (string= "Whatever." (response-for "Let's go make out behind the gym!"))))
32
37
 
33
- (ert-deftest responds-to-shouting-with-special-chars ()
38
+ (ert-deftest responds-to-using-acronyms-in-regular-speech ()
34
39
  (should
35
- (string= "Whoa, chill out!" (response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))
40
+ (string= "Whatever." (response-for "It's OK if you don't want to go to the DMV."))))
41
+
42
+ (ert-deftest responds-to-forceful-question ()
43
+ (should
44
+ (string= "Calm down, I know what I'm doing!" (response-for "WHAT THE HELL WERE YOU THINKING?"))))
36
45
 
37
46
  (ert-deftest responds-to-shouting-numbers ()
38
47
  (should
39
48
  (string= "Whoa, chill out!" (response-for "1, 2, 3, GO!"))))
40
49
 
50
+ (ert-deftest responds-to-only-numbers ()
51
+ (should
52
+ (string= "Whatever." (response-for "1, 2, 3"))))
53
+
54
+ (ert-deftest responds-to-questions-with-only-numbers ()
55
+ (should
56
+ (string= "Sure." (response-for "4?"))))
57
+
58
+ (ert-deftest responds-to-shouting-with-special-chars ()
59
+ (should
60
+ (string= "Whoa, chill out!" (response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))
61
+
41
62
  (ert-deftest responds-to-shouting-with-no-exclamation-mark ()
42
63
  (should
43
64
  (string= "Whoa, chill out!" (response-for "I HATE YOU"))))
@@ -46,6 +67,14 @@
46
67
  (should
47
68
  (string= "Whatever." (response-for "Ending with ? means a question."))))
48
69
 
70
+ (ert-deftest responds-to-non-letters-with-question ()
71
+ (should
72
+ (string= "Sure." (response-for ":) ?"))))
73
+
74
+ (ert-deftest responds-to-prattling-on ()
75
+ (should
76
+ (string= "Sure." (response-for "Wait! Hang on. Are you going to be OK?"))))
77
+
49
78
  (ert-deftest responds-to-silence ()
50
79
  (should
51
80
  (string= "Fine. Be that way!" (response-for ""))))
@@ -54,13 +83,29 @@
54
83
  (should
55
84
  (string= "Fine. Be that way!" (response-for " "))))
56
85
 
57
- (ert-deftest responds-to-only-numbers ()
86
+ (ert-deftest responds-to-alternate-silence ()
58
87
  (should
59
- (string= "Whatever." (response-for "1, 2, 3"))))
88
+ (string= "Fine. Be that way!" (response-for "\t\t\t\t\t\t\t\t\t\t"))))
60
89
 
61
- (ert-deftest responds-to-number-questions ()
90
+ (ert-deftest responds-to-multiple-line-question ()
62
91
  (should
63
- (string= "Sure." (response-for "4?"))))
92
+ (string= "Whatever." (response-for "\nDoes this cryogenic chamber make me look fat?\nno"))))
93
+
94
+ (ert-deftest responds-to-starting-with-whitespace ()
95
+ (should
96
+ (string= "Whatever." (response-for " hmmmmmmm..."))))
97
+
98
+ (ert-deftest responds-to-ending-with-whitespace ()
99
+ (should
100
+ (string= "Sure." (response-for "Okay if like my spacebar quite a bit? "))))
101
+
102
+ (ert-deftest responds-to-other-whitespace ()
103
+ (should
104
+ (string= "Fine. Be that way!" (response-for "\n\r \t"))))
105
+
106
+ (ert-deftest responds-to-non-question-ending-with-whitespace ()
107
+ (should
108
+ (string= "Whatever." (response-for "This is a statement ending with whitespace "))))
64
109
 
65
110
  (provide 'bob-test)
66
111
  ;;;bob-test.el ends here