trackler 2.2.1.69 → 2.2.1.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/isbn-verifier/description.md +25 -20
  4. data/tracks/c/bin/run-tests +1 -2
  5. data/tracks/c/exercises/acronym/makefile +10 -0
  6. data/tracks/c/exercises/all-your-base/makefile +10 -0
  7. data/tracks/c/exercises/allergies/makefile +10 -0
  8. data/tracks/c/exercises/anagram/makefile +9 -0
  9. data/tracks/c/exercises/atbash-cipher/makefile +9 -0
  10. data/tracks/c/exercises/beer-song/makefile +9 -0
  11. data/tracks/c/exercises/binary/makefile +9 -0
  12. data/tracks/c/exercises/binary-search/makefile +9 -0
  13. data/tracks/c/exercises/bob/makefile +9 -0
  14. data/tracks/c/exercises/clock/makefile +9 -0
  15. data/tracks/c/exercises/collatz-conjecture/makefile +10 -0
  16. data/tracks/c/exercises/difference-of-squares/makefile +9 -0
  17. data/tracks/c/exercises/gigasecond/makefile +9 -0
  18. data/tracks/c/exercises/grains/makefile +9 -0
  19. data/tracks/c/exercises/hamming/makefile +9 -0
  20. data/tracks/c/exercises/isogram/makefile +10 -0
  21. data/tracks/c/exercises/largest-series-product/makefile +9 -0
  22. data/tracks/c/exercises/leap/makefile +9 -0
  23. data/tracks/c/exercises/meetup/makefile +10 -0
  24. data/tracks/c/exercises/nth-prime/makefile +9 -0
  25. data/tracks/c/exercises/nucleotide-count/makefile +10 -0
  26. data/tracks/c/exercises/palindrome-products/makefile +9 -0
  27. data/tracks/c/exercises/pangram/makefile +9 -0
  28. data/tracks/c/exercises/pascals-triangle/makefile +9 -0
  29. data/tracks/c/exercises/perfect-numbers/makefile +8 -0
  30. data/tracks/c/exercises/phone-number/makefile +9 -0
  31. data/tracks/c/exercises/queen-attack/makefile +10 -0
  32. data/tracks/c/exercises/raindrops/makefile +9 -0
  33. data/tracks/c/exercises/react/makefile +9 -0
  34. data/tracks/c/exercises/rna-transcription/makefile +10 -0
  35. data/tracks/c/exercises/robot-simulator/makefile +9 -0
  36. data/tracks/c/exercises/roman-numerals/makefile +9 -0
  37. data/tracks/c/exercises/scrabble-score/makefile +9 -0
  38. data/tracks/c/exercises/series/makefile +9 -0
  39. data/tracks/c/exercises/sieve/makefile +10 -0
  40. data/tracks/c/exercises/space-age/makefile +9 -0
  41. data/tracks/c/exercises/sublist/makefile +10 -0
  42. data/tracks/c/exercises/sum-of-multiples/makefile +10 -0
  43. data/tracks/c/exercises/triangle/makefile +9 -0
  44. data/tracks/c/exercises/word-count/makefile +9 -0
  45. data/tracks/delphi/config.json +10 -0
  46. data/tracks/delphi/exercises/reverse-string/README.md +34 -0
  47. data/tracks/delphi/exercises/reverse-string/ReverseString.dpr +60 -0
  48. data/tracks/delphi/exercises/reverse-string/uReverseStringExample.pas +18 -0
  49. data/tracks/delphi/exercises/reverse-string/uReverseStringTests.pas +69 -0
  50. data/tracks/fsharp/exercises/forth/Example.fs +29 -25
  51. data/tracks/fsharp/exercises/forth/ForthTest.fs +190 -74
  52. data/tracks/fsharp/exercises/markdown/MarkdownTest.fs +6 -3
  53. data/tracks/fsharp/generators/Exercise.fs +4 -4
  54. data/tracks/fsharp/generators/Generators.fs +29 -1
  55. data/tracks/java/exercises/allergies/.meta/src/reference/java/Allergen.java +2 -2
  56. data/tracks/java/exercises/allergies/.meta/src/reference/java/Allergies.java +4 -4
  57. data/tracks/java/exercises/allergies/src/main/java/Allergen.java +2 -2
  58. data/tracks/java/exercises/anagram/.meta/src/reference/java/Anagram.java +5 -5
  59. data/tracks/java/exercises/bob/.meta/src/reference/java/Bob.java +8 -5
  60. data/tracks/java/exercises/kindergarten-garden/src/main/java/KindergartenGarden.java +17 -0
  61. data/tracks/java/exercises/nth-prime/src/main/java/PrimeCalculator.java +7 -0
  62. data/tracks/java/exercises/rotational-cipher/src/main/java/RotationalCipher.java +11 -0
  63. data/tracks/javascript/config.json +15 -0
  64. data/tracks/javascript/exercises/connect/README.md +59 -0
  65. data/tracks/javascript/exercises/connect/connect.spec.js +108 -0
  66. data/tracks/javascript/exercises/connect/example.js +105 -0
  67. data/tracks/kotlin/README.md +1 -1
  68. data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +2 -2
  69. metadata +12 -6
  70. data/tracks/java/exercises/book-store/.meta/src/reference/java/.keep +0 -0
  71. data/tracks/java/exercises/nth-prime/src/main/java/.keep +0 -0
  72. data/tracks/java/exercises/rotational-cipher/src/main/java/.keep +0 -0
  73. data/tracks/javascript/package-lock.json +0 -1895
@@ -1,113 +1,229 @@
1
+ // This file was auto-generated based on version 1.4.0 of the canonical data.
2
+
1
3
  module ForthTest
2
4
 
3
- open Xunit
4
5
  open FsUnit.Xunit
6
+ open Xunit
5
7
 
6
8
  open Forth
7
9
 
8
- let bind f m =
9
- match m with
10
- | Choice1Of2 x -> f x
11
- | Choice2Of2 x -> Choice2Of2 x
10
+ [<Fact>]
11
+ let ``Parsing and numbers - numbers just get pushed onto the stack`` () =
12
+ let expected = Some [1; 2; 3; 4; 5]
13
+ evaluate ["1 2 3 4 5"] |> should equal expected
12
14
 
13
- let map f =
14
- function
15
- | Choice1Of2 x -> f x |> Choice1Of2
16
- | Choice2Of2 x -> Choice2Of2 x
15
+ [<Fact(Skip = "Remove to run test")>]
16
+ let ``Addition - can add two numbers`` () =
17
+ let expected = Some [3]
18
+ evaluate ["1 2 +"] |> should equal expected
17
19
 
18
- let run text = eval text empty |> map formatStack
19
-
20
- // Note: we use the Choice<'T1, 'T2> type to represent a possible outcome of
21
- // evaluating input. When the evaluating is succesful, the result is
22
- // contained in a Choice1Of2. If an error occured, that error is contained
23
- // in a Choice2Of2.
20
+ [<Fact(Skip = "Remove to run test")>]
21
+ let ``Addition - errors if there is nothing on the stack`` () =
22
+ let expected = None
23
+ evaluate ["+"] |> should equal expected
24
24
 
25
- [<Fact>]
26
- let ``No input, no stack`` () =
27
- formatStack empty |> should be EmptyString
25
+ [<Fact(Skip = "Remove to run test")>]
26
+ let ``Addition - errors if there is only one value on the stack`` () =
27
+ let expected = None
28
+ evaluate ["1 +"] |> should equal expected
29
+
30
+ [<Fact(Skip = "Remove to run test")>]
31
+ let ``Subtraction - can subtract two numbers`` () =
32
+ let expected = Some [-1]
33
+ evaluate ["3 4 -"] |> should equal expected
34
+
35
+ [<Fact(Skip = "Remove to run test")>]
36
+ let ``Subtraction - errors if there is nothing on the stack`` () =
37
+ let expected = None
38
+ evaluate ["-"] |> should equal expected
39
+
40
+ [<Fact(Skip = "Remove to run test")>]
41
+ let ``Subtraction - errors if there is only one value on the stack`` () =
42
+ let expected = None
43
+ evaluate ["1 -"] |> should equal expected
44
+
45
+ [<Fact(Skip = "Remove to run test")>]
46
+ let ``Multiplication - can multiply two numbers`` () =
47
+ let expected = Some [8]
48
+ evaluate ["2 4 *"] |> should equal expected
49
+
50
+ [<Fact(Skip = "Remove to run test")>]
51
+ let ``Multiplication - errors if there is nothing on the stack`` () =
52
+ let expected = None
53
+ evaluate ["*"] |> should equal expected
54
+
55
+ [<Fact(Skip = "Remove to run test")>]
56
+ let ``Multiplication - errors if there is only one value on the stack`` () =
57
+ let expected = None
58
+ evaluate ["1 *"] |> should equal expected
59
+
60
+ [<Fact(Skip = "Remove to run test")>]
61
+ let ``Division - can divide two numbers`` () =
62
+ let expected = Some [4]
63
+ evaluate ["12 3 /"] |> should equal expected
28
64
 
29
65
  [<Fact(Skip = "Remove to run test")>]
30
- let ``Numbers just get pushed onto the stack`` () =
31
- run "1 2 3 4 5" |> should equal (Choice1Of2 "1 2 3 4 5": Choice<string,ForthError>)
66
+ let ``Division - performs integer division`` () =
67
+ let expected = Some [2]
68
+ evaluate ["8 3 /"] |> should equal expected
32
69
 
33
70
  [<Fact(Skip = "Remove to run test")>]
34
- let ``Non-word characters are separators`` () =
35
- run "1\b2\t3\n4\r5 6\t7" |> should equal (Choice1Of2 "1 2 3 4 5 6 7": Choice<string,ForthError>)
71
+ let ``Division - errors if dividing by zero`` () =
72
+ let expected = None
73
+ evaluate ["4 0 /"] |> should equal expected
36
74
 
37
75
  [<Fact(Skip = "Remove to run test")>]
38
- let ``Basic arithmetic`` () =
39
- run "1 2 + 4 -" |> should equal (Choice1Of2 "-1": Choice<string,ForthError>)
40
- run "2 4 * 3 /" |> should equal (Choice1Of2 "2": Choice<string,ForthError>)
76
+ let ``Division - errors if there is nothing on the stack`` () =
77
+ let expected = None
78
+ evaluate ["/"] |> should equal expected
41
79
 
42
80
  [<Fact(Skip = "Remove to run test")>]
43
- let ``Division by zero`` () =
44
- run "4 2 2 - /" |> should equal (Choice2Of2 DivisionByZero: Choice<string,ForthError>)
81
+ let ``Division - errors if there is only one value on the stack`` () =
82
+ let expected = None
83
+ evaluate ["1 /"] |> should equal expected
45
84
 
46
85
  [<Fact(Skip = "Remove to run test")>]
47
- let ``dup`` () =
48
- run "1 DUP" |> should equal (Choice1Of2 "1 1": Choice<string,ForthError>)
49
- run "1 2 Dup" |> should equal (Choice1Of2 "1 2 2": Choice<string,ForthError>)
50
- run "dup" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
86
+ let ``Combined arithmetic - addition and subtraction`` () =
87
+ let expected = Some [-1]
88
+ evaluate ["1 2 + 4 -"] |> should equal expected
51
89
 
52
90
  [<Fact(Skip = "Remove to run test")>]
53
- let ``drop`` () =
54
- run "1 drop" |> should equal (Choice1Of2 "": Choice<string,ForthError>)
55
- run "1 2 drop" |> should equal (Choice1Of2 "1": Choice<string,ForthError>)
56
- run "drop" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
91
+ let ``Combined arithmetic - multiplication and division`` () =
92
+ let expected = Some [2]
93
+ evaluate ["2 4 * 3 /"] |> should equal expected
57
94
 
58
95
  [<Fact(Skip = "Remove to run test")>]
59
- let ``swap`` () =
60
- run "1 2 swap" |> should equal (Choice1Of2 "2 1": Choice<string,ForthError>)
61
- run "1 2 3 swap" |> should equal (Choice1Of2 "1 3 2": Choice<string,ForthError>)
62
- run "1 swap" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
63
- run "swap" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
96
+ let ``Dup - copies a value on the stack`` () =
97
+ let expected = Some [1; 1]
98
+ evaluate ["1 dup"] |> should equal expected
64
99
 
65
100
  [<Fact(Skip = "Remove to run test")>]
66
- let ``over`` () =
67
- run "1 2 over" |> should equal (Choice1Of2 "1 2 1": Choice<string,ForthError>)
68
- run "1 2 3 over" |> should equal (Choice1Of2 "1 2 3 2": Choice<string,ForthError>)
69
- run "1 over" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
70
- run "over" |> should equal (Choice2Of2 StackUnderflow: Choice<string,ForthError>)
101
+ let ``Dup - copies the top value on the stack`` () =
102
+ let expected = Some [1; 2; 2]
103
+ evaluate ["1 2 dup"] |> should equal expected
71
104
 
72
105
  [<Fact(Skip = "Remove to run test")>]
73
- let ``Defining a new word`` () =
74
- let actual =
75
- empty
76
- |> eval ": dup-twice dup dup ;"
77
- |> bind (eval "1 dup-twice")
78
- |> map formatStack
106
+ let ``Dup - errors if there is nothing on the stack`` () =
107
+ let expected = None
108
+ evaluate ["dup"] |> should equal expected
79
109
 
80
- actual |> should equal (Choice1Of2 "1 1 1": Choice<string,ForthError>)
110
+ [<Fact(Skip = "Remove to run test")>]
111
+ let ``Drop - removes the top value on the stack if it is the only one`` () =
112
+ let expected: int list option = Some []
113
+ evaluate ["1 drop"] |> should equal expected
81
114
 
82
115
  [<Fact(Skip = "Remove to run test")>]
83
- let ``Redefining an existing word`` () =
84
- let actual =
85
- empty
86
- |> eval ": foo dup ;"
87
- |> bind (eval ": foo dup dup ;")
88
- |> bind (eval "1 foo")
89
- |> map formatStack
90
-
91
- actual |> should equal (Choice1Of2 "1 1 1": Choice<string,ForthError>)
116
+ let ``Drop - removes the top value on the stack if it is not the only one`` () =
117
+ let expected = Some [1]
118
+ evaluate ["1 2 drop"] |> should equal expected
92
119
 
93
120
  [<Fact(Skip = "Remove to run test")>]
94
- let ``Redefining an existing built-in word`` () =
95
- let actual =
96
- empty
97
- |> eval ": swap dup ;"
98
- |> bind (eval "1 swap")
99
- |> map formatStack
121
+ let ``Drop - errors if there is nothing on the stack`` () =
122
+ let expected = None
123
+ evaluate ["drop"] |> should equal expected
100
124
 
101
- actual |> should equal (Choice1Of2 "1 1": Choice<string,ForthError>)
125
+ [<Fact(Skip = "Remove to run test")>]
126
+ let ``Swap - swaps the top two values on the stack if they are the only ones`` () =
127
+ let expected = Some [2; 1]
128
+ evaluate ["1 2 swap"] |> should equal expected
129
+
130
+ [<Fact(Skip = "Remove to run test")>]
131
+ let ``Swap - swaps the top two values on the stack if they are not the only ones`` () =
132
+ let expected = Some [1; 3; 2]
133
+ evaluate ["1 2 3 swap"] |> should equal expected
134
+
135
+ [<Fact(Skip = "Remove to run test")>]
136
+ let ``Swap - errors if there is nothing on the stack`` () =
137
+ let expected = None
138
+ evaluate ["swap"] |> should equal expected
139
+
140
+ [<Fact(Skip = "Remove to run test")>]
141
+ let ``Swap - errors if there is only one value on the stack`` () =
142
+ let expected = None
143
+ evaluate ["1 swap"] |> should equal expected
102
144
 
103
145
  [<Fact(Skip = "Remove to run test")>]
104
- let ``Defining words with odd characters`` () =
105
- run ": 220371 ; €" |> should equal (Choice1Of2 "220371": Choice<string,ForthError>)
146
+ let ``Over - copies the second element if there are only two`` () =
147
+ let expected = Some [1; 2; 1]
148
+ evaluate ["1 2 over"] |> should equal expected
106
149
 
107
150
  [<Fact(Skip = "Remove to run test")>]
108
- let ``Defining a number`` () =
109
- run ": 1 2 ;" |> should equal (Choice2Of2 InvalidWord: Choice<string,ForthError>)
151
+ let ``Over - copies the second element if there are more than two`` () =
152
+ let expected = Some [1; 2; 3; 2]
153
+ evaluate ["1 2 3 over"] |> should equal expected
110
154
 
111
155
  [<Fact(Skip = "Remove to run test")>]
112
- let ``Calling a non-existing word`` () =
113
- run "1 foo" |> should equal (Choice2Of2 (UnknownWord "foo"): Choice<string,ForthError>)
156
+ let ``Over - errors if there is nothing on the stack`` () =
157
+ let expected = None
158
+ evaluate ["over"] |> should equal expected
159
+
160
+ [<Fact(Skip = "Remove to run test")>]
161
+ let ``Over - errors if there is only one value on the stack`` () =
162
+ let expected = None
163
+ evaluate ["1 over"] |> should equal expected
164
+
165
+ [<Fact(Skip = "Remove to run test")>]
166
+ let ``User-defined words - can consist of built-in words`` () =
167
+ let expected = Some [1; 1; 1]
168
+ evaluate [": dup-twice dup dup ;"; "1 dup-twice"] |> should equal expected
169
+
170
+ [<Fact(Skip = "Remove to run test")>]
171
+ let ``User-defined words - execute in the right order`` () =
172
+ let expected = Some [1; 2; 3]
173
+ evaluate [": countup 1 2 3 ;"; "countup"] |> should equal expected
174
+
175
+ [<Fact(Skip = "Remove to run test")>]
176
+ let ``User-defined words - can override other user-defined words`` () =
177
+ let expected = Some [1; 1; 1]
178
+ evaluate [": foo dup ;"; ": foo dup dup ;"; "1 foo"] |> should equal expected
179
+
180
+ [<Fact(Skip = "Remove to run test")>]
181
+ let ``User-defined words - can override built-in words`` () =
182
+ let expected = Some [1; 1]
183
+ evaluate [": swap dup ;"; "1 swap"] |> should equal expected
184
+
185
+ [<Fact(Skip = "Remove to run test")>]
186
+ let ``User-defined words - can override built-in operators`` () =
187
+ let expected = Some [12]
188
+ evaluate [": + * ;"; "3 4 +"] |> should equal expected
189
+
190
+ [<Fact(Skip = "Remove to run test")>]
191
+ let ``User-defined words - cannot redefine numbers`` () =
192
+ let expected = None
193
+ evaluate [": 1 2 ;"] |> should equal expected
194
+
195
+ [<Fact(Skip = "Remove to run test")>]
196
+ let ``User-defined words - errors if executing a non-existent word`` () =
197
+ let expected = None
198
+ evaluate ["foo"] |> should equal expected
199
+
200
+ [<Fact(Skip = "Remove to run test")>]
201
+ let ``Case-insensitivity - DUP is case-insensitive`` () =
202
+ let expected = Some [1; 1; 1; 1]
203
+ evaluate ["1 DUP Dup dup"] |> should equal expected
204
+
205
+ [<Fact(Skip = "Remove to run test")>]
206
+ let ``Case-insensitivity - DROP is case-insensitive`` () =
207
+ let expected = Some [1]
208
+ evaluate ["1 2 3 4 DROP Drop drop"] |> should equal expected
209
+
210
+ [<Fact(Skip = "Remove to run test")>]
211
+ let ``Case-insensitivity - SWAP is case-insensitive`` () =
212
+ let expected = Some [2; 3; 4; 1]
213
+ evaluate ["1 2 SWAP 3 Swap 4 swap"] |> should equal expected
214
+
215
+ [<Fact(Skip = "Remove to run test")>]
216
+ let ``Case-insensitivity - OVER is case-insensitive`` () =
217
+ let expected = Some [1; 2; 1; 2; 1]
218
+ evaluate ["1 2 OVER Over over"] |> should equal expected
219
+
220
+ [<Fact(Skip = "Remove to run test")>]
221
+ let ``Case-insensitivity - user-defined words are case-insensitive`` () =
222
+ let expected = Some [1; 1; 1; 1]
223
+ evaluate [": foo dup ;"; "1 FOO Foo foo"] |> should equal expected
224
+
225
+ [<Fact(Skip = "Remove to run test")>]
226
+ let ``Case-insensitivity - definitions are case-insensitive`` () =
227
+ let expected = Some [1; 1; 1; 1]
228
+ evaluate [": SWAP DUP Dup dup ;"; "1 swap"] |> should equal expected
229
+
@@ -1,7 +1,9 @@
1
+ // This file was auto-generated based on version 1.1.0 of the canonical data.
2
+
1
3
  module MarkdownTest
2
4
 
3
- open Xunit
4
5
  open FsUnit.Xunit
6
+ open Xunit
5
7
 
6
8
  open Markdown
7
9
 
@@ -10,7 +12,7 @@ let ``Parses normal text as a paragraph`` () =
10
12
  let input = "This will be a paragraph"
11
13
  let expected = "<p>This will be a paragraph</p>"
12
14
  parse input |> should equal expected
13
-
15
+
14
16
  [<Fact>]
15
17
  let ``Parsing italics`` () =
16
18
  let input = "_This will be italic_"
@@ -57,4 +59,5 @@ let ``Unordered lists`` () =
57
59
  let ``With a little bit of everything`` () =
58
60
  let input = "# Header!\n* __Bold Item__\n* _Italic Item_"
59
61
  let expected = "<h1>Header!</h1><ul><li><strong>Bold Item</strong></li><li><em>Italic Item</em></li></ul>"
60
- parse input |> should equal expected
62
+ parse input |> should equal expected
63
+
@@ -18,7 +18,7 @@ type Exercise() =
18
18
 
19
19
  // Convert canonical data to representation used when rendering
20
20
  abstract member ToTestClass : CanonicalData -> TestClass
21
- abstract member ToTestMethod : int -> CanonicalDataCase -> TestMethod
21
+ abstract member ToTestMethod : int * CanonicalDataCase -> TestMethod
22
22
  abstract member ToTestMethodBody : CanonicalDataCase -> TestMethodBody
23
23
  abstract member ToTestMethodBodyAssert : CanonicalDataCase -> TestMethodBodyAssert
24
24
  abstract member ToTestMethodBodyAssertTemplate : CanonicalDataCase -> string
@@ -98,7 +98,7 @@ type Exercise() =
98
98
  Namespaces = ["FsUnit.Xunit"; "Xunit"] @ this.AdditionalNamespaces
99
99
  Methods = List.mapi this.RenderTestMethod canonicalData.Cases }
100
100
 
101
- default this.ToTestMethod index canonicalDataCase =
101
+ default this.ToTestMethod (index, canonicalDataCase) =
102
102
  { Skip = index > 0
103
103
  Name = this.RenderTestMethodName canonicalDataCase
104
104
  Body = this.RenderTestMethodBody canonicalDataCase }
@@ -124,8 +124,8 @@ type Exercise() =
124
124
  |> renderPartialTemplate "TestClass"
125
125
 
126
126
  default this.RenderTestMethod index canonicalDataCase =
127
- canonicalDataCase
128
- |> this.ToTestMethod index
127
+ (index, canonicalDataCase)
128
+ |> this.ToTestMethod
129
129
  |> renderPartialTemplate "TestMethod"
130
130
 
131
131
  default this.RenderTestMethodBody canonicalDataCase =
@@ -15,7 +15,10 @@ type AtbashCipher() =
15
15
  type AllYourBase() =
16
16
  inherit Exercise()
17
17
 
18
- override this.RenderExpected (canonicalDataCase, key, value) = value |> Option.ofNonError |> formatValue
18
+ override this.RenderExpected (canonicalDataCase, key, value) =
19
+ value
20
+ |> Option.ofNonError
21
+ |> formatValue
19
22
 
20
23
  override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
21
24
 
@@ -269,6 +272,23 @@ type FoodChain() =
269
272
  |> Seq.map formatValue
270
273
  |> formatMultiLineList
271
274
 
275
+ type Forth() =
276
+ inherit Exercise()
277
+
278
+ override this.PropertiesWithIdentifier canonicalDataCase = ["expected"]
279
+
280
+ override this.RenderExpected (canonicalDataCase, key, value) =
281
+ value
282
+ |> Option.ofObj
283
+ |> formatValue
284
+
285
+ override this.IdentifierTypeAnnotation (canonicalDataCase, key, value) =
286
+ match value :?> JArray|> Option.ofObj |> Option.map Seq.isEmpty with
287
+ | Some true -> Some "int list option"
288
+ | _ -> None
289
+
290
+ override this.UseFullMethodName canonicalDataCase = true
291
+
272
292
  type Gigasecond() =
273
293
  inherit Exercise()
274
294
 
@@ -354,6 +374,14 @@ type Leap() =
354
374
 
355
375
  type Luhn() =
356
376
  inherit Exercise()
377
+
378
+ type Markdown() =
379
+ inherit Exercise()
380
+
381
+ override this.ToTestMethod (index, canonicalDataCase) =
382
+ { base.ToTestMethod (index, canonicalDataCase) with Skip = false }
383
+
384
+ override this.PropertiesWithIdentifier canonicalDataCase = this.Properties canonicalDataCase
357
385
 
358
386
  type Meetup() =
359
387
  inherit Exercise()
@@ -1,4 +1,4 @@
1
- public enum Allergen {
1
+ enum Allergen {
2
2
  EGGS(1),
3
3
  PEANUTS(2),
4
4
  SHELLFISH(4),
@@ -14,7 +14,7 @@ public enum Allergen {
14
14
  this.score = score;
15
15
  }
16
16
 
17
- public int getScore() {
17
+ int getScore() {
18
18
  return score;
19
19
  }
20
20
  }
@@ -2,21 +2,21 @@ import java.util.EnumSet;
2
2
  import java.util.List;
3
3
  import java.util.stream.Collectors;
4
4
 
5
- public class Allergies {
5
+ class Allergies {
6
6
 
7
7
  private int score;
8
8
 
9
- public Allergies(int score) {
9
+ Allergies(int score) {
10
10
  this.score = score;
11
11
  }
12
12
 
13
- public List<Allergen> getList() {
13
+ List<Allergen> getList() {
14
14
  return EnumSet.allOf(Allergen.class).stream()
15
15
  .filter(this::isAllergicTo)
16
16
  .collect(Collectors.toList());
17
17
  }
18
18
 
19
- public boolean isAllergicTo(Allergen allergen) {
19
+ boolean isAllergicTo(Allergen allergen) {
20
20
  return (score & allergen.getScore()) == allergen.getScore();
21
21
  }
22
22
  }
@@ -1,4 +1,4 @@
1
- public enum Allergen {
1
+ enum Allergen {
2
2
  EGGS(1),
3
3
  PEANUTS(2),
4
4
  SHELLFISH(4),
@@ -14,7 +14,7 @@ public enum Allergen {
14
14
  this.score = score;
15
15
  }
16
16
 
17
- public int getScore() {
17
+ int getScore() {
18
18
  return score;
19
19
  }
20
20
  }
@@ -1,14 +1,14 @@
1
1
  import java.util.*;
2
2
 
3
- public class Anagram {
3
+ class Anagram {
4
4
 
5
5
  private final AnagramSubject anagramSubject;
6
6
 
7
- public Anagram(String word) {
7
+ Anagram(String word) {
8
8
  anagramSubject = new AnagramSubject(word);
9
9
  }
10
10
 
11
- public List<String> match(List<String> candidates) {
11
+ List<String> match(List<String> candidates) {
12
12
  List<String> anagrams = new ArrayList<String>();
13
13
 
14
14
  for (String candidate : candidates) {
@@ -25,12 +25,12 @@ public class Anagram {
25
25
  private final String word;
26
26
  private final char[] fingerprint;
27
27
 
28
- public AnagramSubject(String other) {
28
+ AnagramSubject(String other) {
29
29
  this.word = other;
30
30
  this.fingerprint = canonicalize(other);
31
31
  }
32
32
 
33
- public boolean anagramOf(String other) {
33
+ boolean anagramOf(String other) {
34
34
  return !duplicate(other) && Arrays.equals(fingerprint,canonicalize(other));
35
35
  }
36
36
 
@@ -1,15 +1,18 @@
1
1
  /**
2
2
  * Bob is a lackadasical teenager.
3
3
  */
4
- public class Bob {
5
- public String hey(String input) {
4
+ class Bob {
5
+ String hey(String input) {
6
6
  input = normalize(input);
7
- if (isSilence(input))
7
+ if (isSilence(input)) {
8
8
  return "Fine. Be that way!";
9
- if (isShout(input))
9
+ }
10
+ if (isShout(input)) {
10
11
  return "Whoa, chill out!";
11
- if (isQuestion(input))
12
+ }
13
+ if (isQuestion(input)) {
12
14
  return "Sure.";
15
+ }
13
16
  return "Whatever.";
14
17
  }
15
18
 
@@ -0,0 +1,17 @@
1
+ import java.util.List;
2
+
3
+ class KindergartenGarden {
4
+
5
+ KindergartenGarden(String garden, String[] students) {
6
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
7
+ }
8
+
9
+ KindergartenGarden(String garden) {
10
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
11
+ }
12
+
13
+ List<Plant> getPlantsOfStudent(String student) {
14
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
15
+ }
16
+
17
+ }
@@ -0,0 +1,7 @@
1
+ class PrimeCalculator {
2
+
3
+ int nth(int nth) {
4
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+ }
6
+
7
+ }
@@ -0,0 +1,11 @@
1
+ class RotationalCipher {
2
+
3
+ RotationalCipher(int shiftKey) {
4
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+ }
6
+
7
+ String rotate(String data) {
8
+ throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9
+ }
10
+
11
+ }
@@ -1056,6 +1056,21 @@
1056
1056
  "unlocked_by": "prime-factors",
1057
1057
  "uuid" : "910fe904-7e3c-11e7-bb31-be2e44b06b34"
1058
1058
  },
1059
+ {
1060
+ "uuid": "3b779cb8-9544-4e0d-a306-e5478d741be7",
1061
+ "slug": "connect",
1062
+ "core": false,
1063
+ "unlocked_by": "grade-school",
1064
+ "difficulty": 7,
1065
+ "topics": [
1066
+ "Control-flow (loops)",
1067
+ "Control-flow (conditionals)",
1068
+ "Games",
1069
+ "Parsing",
1070
+ "Arrays",
1071
+ "Maps"
1072
+ ]
1073
+ },
1059
1074
  {
1060
1075
  "core" : false,
1061
1076
  "difficulty" : 1,
@@ -0,0 +1,59 @@
1
+ # Connect
2
+
3
+ Compute the result for a game of Hex / Polygon.
4
+
5
+ The abstract boardgame known as
6
+ [Hex](https://en.wikipedia.org/wiki/Hex_%28board_game%29) / Polygon /
7
+ CON-TAC-TIX is quite simple in rules, though complex in practice. Two players
8
+ place stones on a rhombus with hexagonal fields. The player to connect his/her
9
+ stones to the opposite side first wins. The four sides of the rhombus are
10
+ divided between the two players (i.e. one player gets assigned a side and the
11
+ side directly opposite it and the other player gets assigned the two other
12
+ sides).
13
+
14
+ Your goal is to build a program that given a simple representation of a board
15
+ computes the winner (or lack thereof). Note that all games need not be "fair".
16
+ (For example, players may have mismatched piece counts.)
17
+
18
+ The boards look like this (with spaces added for readability, which won't be in
19
+ the representation passed to your code):
20
+
21
+ ```
22
+ . O . X .
23
+ . X X O .
24
+ O O O X .
25
+ . X O X O
26
+ X O O O X
27
+ ```
28
+
29
+ "Player `O`" plays from top to bottom, "Player `X`" plays from left to right. In
30
+ the above example `O` has made a connection from left to right but nobody has
31
+ won since `O` didn't connect top and bottom.
32
+
33
+ ## Setup
34
+
35
+ Go through the setup instructions for JavaScript to
36
+ install the necessary dependencies:
37
+
38
+ http://exercism.io/languages/javascript
39
+
40
+ ## Making the test suite pass
41
+
42
+ Execute the tests with:
43
+
44
+ jasmine <exercise-name>.spec.js
45
+
46
+ Replace `<exercise-name>` with the name of the current exercise. E.g., to
47
+ test the Hello World exercise:
48
+
49
+ jasmine hello-world.spec.js
50
+
51
+ In many test suites all but the first test have been skipped.
52
+
53
+ Once you get a test passing, you can unskip the next one by
54
+ changing `xit` to `it`.
55
+
56
+
57
+
58
+ ## Submitting Incomplete Solutions
59
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.