trackler 2.2.1.98 → 2.2.1.99

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.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/complex-numbers/canonical-data.json +47 -47
  4. data/problem-specifications/exercises/custom-set/canonical-data.json +13 -7
  5. data/tracks/delphi/exercises/phone-number/uPhoneNumberTests.pas +1 -1
  6. data/tracks/elixir/exercises/protein-translation/protein_translation_test.exs +5 -0
  7. data/tracks/fsharp/config.json +10 -0
  8. data/tracks/fsharp/exercises/Exercises.sln +6 -0
  9. data/tracks/fsharp/exercises/accumulate/AccumulateTest.fs +2 -0
  10. data/tracks/fsharp/exercises/bank-account/BankAccountTest.fs +2 -0
  11. data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTreeTest.fs +2 -0
  12. data/tracks/fsharp/exercises/binary/BinaryTest.fs +2 -0
  13. data/tracks/fsharp/exercises/circular-buffer/CircularBufferTest.fs +121 -117
  14. data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fs +21 -0
  15. data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fsproj +23 -0
  16. data/tracks/fsharp/exercises/complex-numbers/ComplexNumbersTest.fs +168 -0
  17. data/tracks/fsharp/exercises/complex-numbers/Example.fs +27 -0
  18. data/tracks/fsharp/exercises/complex-numbers/Program.fs +1 -0
  19. data/tracks/fsharp/exercises/complex-numbers/README.md +35 -0
  20. data/tracks/fsharp/exercises/diamond/DiamondTest.fs +2 -0
  21. data/tracks/fsharp/exercises/diffie-hellman/DiffieHellmanTest.fs +2 -0
  22. data/tracks/fsharp/exercises/dot-dsl/DotDslTest.fs +2 -0
  23. data/tracks/fsharp/exercises/error-handling/ErrorHandlingTest.fs +2 -0
  24. data/tracks/fsharp/exercises/go-counting/GoCountingTest.fs +2 -0
  25. data/tracks/fsharp/exercises/grade-school/GradeSchoolTest.fs +2 -0
  26. data/tracks/fsharp/exercises/hangman/HangmanTest.fs +2 -0
  27. data/tracks/fsharp/exercises/hexadecimal/HexadecimalTest.fs +2 -0
  28. data/tracks/fsharp/exercises/ledger/LedgerTest.fs +2 -0
  29. data/tracks/fsharp/exercises/lens-person/LensPersonTest.fs +2 -0
  30. data/tracks/fsharp/exercises/linked-list/LinkedListTest.fs +2 -0
  31. data/tracks/fsharp/exercises/matrix/MatrixTest.fs +2 -0
  32. data/tracks/fsharp/exercises/octal/OctalTest.fs +2 -0
  33. data/tracks/fsharp/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.fs +2 -0
  34. data/tracks/fsharp/exercises/pov/PovTest.fs +2 -0
  35. data/tracks/fsharp/exercises/protein-translation/ProteinTranslationTest.fs +2 -0
  36. data/tracks/fsharp/exercises/pythagorean-triplet/PythagoreanTripletTest.fs +2 -0
  37. data/tracks/fsharp/exercises/robot-name/RobotNameTest.fs +2 -0
  38. data/tracks/fsharp/exercises/saddle-points/SaddlePointsTest.fs +2 -0
  39. data/tracks/fsharp/exercises/say/SayTest.fs +2 -0
  40. data/tracks/fsharp/exercises/scale-generator/ScaleGeneratorTest.fs +2 -0
  41. data/tracks/fsharp/exercises/secret-handshake/SecretHandshakeTest.fs +2 -0
  42. data/tracks/fsharp/exercises/series/SeriesTest.fs +2 -0
  43. data/tracks/fsharp/exercises/sgf-parsing/SgfParsingTest.fs +2 -0
  44. data/tracks/fsharp/exercises/sieve/SieveTest.fs +2 -0
  45. data/tracks/fsharp/exercises/simple-cipher/SimpleCipherTest.fs +2 -0
  46. data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedListTest.fs +2 -0
  47. data/tracks/fsharp/exercises/space-age/SpaceAgeTest.fs +2 -0
  48. data/tracks/fsharp/exercises/strain/StrainTest.fs +2 -0
  49. data/tracks/fsharp/exercises/sublist/SublistTest.fs +2 -0
  50. data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiplesTest.fs +2 -0
  51. data/tracks/fsharp/exercises/tournament/TournamentTest.fs +2 -0
  52. data/tracks/fsharp/exercises/transpose/TransposeTest.fs +2 -0
  53. data/tracks/fsharp/exercises/transpose/TrinaryTest.fs +3 -1
  54. data/tracks/fsharp/exercises/tree-building/TreeBuildingTest.fs +2 -0
  55. data/tracks/fsharp/exercises/triangle/TriangleTest.fs +2 -0
  56. data/tracks/fsharp/exercises/trinary/TrinaryTest.fs +2 -0
  57. data/tracks/fsharp/exercises/two-bucket/TwoBucketTest.fs +2 -0
  58. data/tracks/fsharp/exercises/variable-length-quantity/VariableLengthQuantityTest.fs +2 -0
  59. data/tracks/fsharp/exercises/word-count/WordCountTest.fs +2 -0
  60. data/tracks/fsharp/exercises/word-search/WordSearchTest.fs +2 -0
  61. data/tracks/fsharp/exercises/wordy/WordyTest.fs +2 -0
  62. data/tracks/fsharp/exercises/zebra-puzzle/ZebraPuzzleTest.fs +2 -0
  63. data/tracks/fsharp/exercises/zipper/ZipperTest.fs +2 -0
  64. data/tracks/fsharp/generators/CanonicalData.fs +1 -1
  65. data/tracks/fsharp/generators/Generators.fs +89 -0
  66. data/tracks/go/config.json +16 -0
  67. data/tracks/go/exercises/rail-fence-cipher/.meta/gen.go +82 -0
  68. data/tracks/go/exercises/rail-fence-cipher/README.md +83 -0
  69. data/tracks/go/exercises/rail-fence-cipher/cases_test.go +50 -0
  70. data/tracks/go/exercises/rail-fence-cipher/example.go +58 -0
  71. data/tracks/go/exercises/rail-fence-cipher/rail_fence_cipher_test.go +15 -0
  72. data/tracks/go/exercises/say/.meta/gen.go +5 -3
  73. data/tracks/go/exercises/say/cases_test.go +2 -2
  74. data/tracks/go/exercises/scrabble-score/.meta/gen.go +5 -3
  75. data/tracks/go/exercises/scrabble-score/cases_test.go +2 -2
  76. data/tracks/go/exercises/secret-handshake/.meta/gen.go +5 -3
  77. data/tracks/go/exercises/secret-handshake/cases_test.go +2 -2
  78. data/tracks/go/exercises/transpose/.meta/gen.go +5 -3
  79. data/tracks/go/exercises/transpose/cases_test.go +30 -76
  80. data/tracks/go/exercises/word-count/.meta/gen.go +5 -3
  81. data/tracks/go/exercises/word-count/cases_test.go +2 -2
  82. data/tracks/go/exercises/wordy/.meta/gen.go +5 -3
  83. data/tracks/go/exercises/wordy/cases_test.go +2 -2
  84. data/tracks/java/exercises/largest-series-product/.meta/src/reference/java/LargestSeriesProductCalculator.java +1 -3
  85. data/tracks/java/exercises/largest-series-product/.meta/version +1 -0
  86. data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +9 -44
  87. data/tracks/ocaml/exercises/grade-school/.meta/description.md +21 -0
  88. data/tracks/ocaml/exercises/palindrome-products/.meta/description.md +35 -0
  89. data/tracks/ocaml/exercises/palindrome-products/README.md +13 -9
  90. metadata +16 -2
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SgfParsingTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SieveTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SimpleCipherTest
2
4
 
3
5
  open System
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SimpleLinkedListTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SpaceAgeTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module StrainTest
2
4
 
3
5
  open System.Collections.Specialized
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SublistTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module SumOfMultiplesTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TournamentTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TransposeTest
2
4
 
3
5
  open Xunit
@@ -1,4 +1,6 @@
1
- module TrinaryTest
1
+ // This file was created manually and its version is 1.0.0.
2
+
3
+ module TrinaryTest
2
4
 
3
5
  open NUnit.Framework
4
6
  open Trinary
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TreeBuildingTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TriangleTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TrinaryTest
2
4
 
3
5
  open FsUnit.Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module TwoBucketTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module VariableLengthQuantityTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module WordCountTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module WordSearchTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module WordyTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module ZebraPuzzleTest
2
4
 
3
5
  open Xunit
@@ -1,3 +1,5 @@
1
+ // This file was created manually and its version is 1.0.0.
2
+
1
3
  module ZipperTest
2
4
 
3
5
  open Xunit
@@ -99,7 +99,7 @@ type CanonicalDataConverter() =
99
99
  let properties = jTokenToMap jToken
100
100
 
101
101
  { Input = createInputFromJToken properties
102
- Expected = properties.["expected"]
102
+ Expected = if properties.ContainsKey "expected" then properties.["expected"] else ("" :> obj)
103
103
  Property = string properties.["property"]
104
104
  Properties = properties
105
105
  Description = string properties.["description"]
@@ -176,6 +176,56 @@ type Change() =
176
176
  | _ -> None
177
177
  | _ -> None
178
178
 
179
+ type CircularBuffer() =
180
+ inherit GeneratorExercise()
181
+
182
+ override __.AdditionalNamespaces = [ "System" ]
183
+
184
+ override __.RenderAssert _ = ""
185
+
186
+ member __.ExceptionCheck command =
187
+ sprintf "(fun () -> %s |> ignore) |> should throw typeof<Exception>" command
188
+
189
+ override this.RenderArrange canonicalDataCase =
190
+ seq {
191
+ yield sprintf "let buffer1 = mkCircularBuffer %i" (canonicalDataCase.Properties.["capacity"] :?> int64)
192
+ let operations = (canonicalDataCase.Properties.["operations"] :?> JArray)
193
+ let mutable ind = 2
194
+ let lastInd = operations.Count + 1
195
+ for op in operations do
196
+ let dict = (op :?> JObject).ToObject<Collections.Generic.Dictionary<string, JToken>>();
197
+ let funcName = dict.["operation"].ToObject<string>()
198
+ match funcName with
199
+ | "write" as operation ->
200
+ let item = dict.["item"].ToObject<int>()
201
+ let command = sprintf "%s %i buffer%i" operation item (ind - 1)
202
+ match dict.ContainsKey "should_succeed", (dict.["should_succeed"].ToObject<bool>()) with
203
+ | true, false ->
204
+ yield this.ExceptionCheck command
205
+ | _, _ ->
206
+ yield sprintf "let buffer%i = %s" ind command
207
+ | "read" as operation ->
208
+ let command = sprintf "%s buffer%i" operation (ind - 1)
209
+ match dict.ContainsKey "should_succeed", dict.["should_succeed"].ToObject<bool>() with
210
+ | true, false ->
211
+ yield this.ExceptionCheck command
212
+ | _, _ ->
213
+ let expected = dict.["expected"].ToObject<int64>()
214
+ if ind = lastInd then
215
+ yield sprintf "let (val%i, _) = %s" ind command
216
+ else
217
+ yield sprintf "let (val%i, buffer%i) = %s" ind ind command
218
+ yield sprintf "val%i |> should equal %i" ind expected
219
+ | "overwrite" ->
220
+ yield sprintf "let buffer%i = forceWrite %i buffer%i" ind (dict.["item"].ToObject<int>()) (ind-1)
221
+ | "clear" ->
222
+ yield sprintf "let buffer%i = clear buffer%i" ind (ind - 1)
223
+ | _ -> ()
224
+ ind <- ind + 1
225
+
226
+ }
227
+ |> Seq.toList
228
+
179
229
  type Clock() =
180
230
  inherit GeneratorExercise()
181
231
 
@@ -216,6 +266,45 @@ type Clock() =
216
266
  | _ ->
217
267
  base.RenderSut canonicalDataCase
218
268
 
269
+ type ComplexNumbers() =
270
+ inherit GeneratorExercise()
271
+
272
+ let renderNumber (input: JToken) =
273
+ match string input with
274
+ | "e" -> "Math.E"
275
+ | "pi" -> "Math.PI"
276
+ | int when int.IndexOf('.') = -1 -> sprintf "%s.0" int
277
+ | float -> float
278
+
279
+ let renderComplexNumber (input: JArray) =
280
+ sprintf "(create %s %s)" (renderNumber input.[0]) (renderNumber input.[1])
281
+
282
+ override __.RenderValue (canonicalDataCase, key, value) =
283
+ match value with
284
+ | :? JArray as jArray -> renderComplexNumber jArray
285
+ | :? int64 as i -> sprintf "%d.0" i
286
+ | _ -> base.RenderValue (canonicalDataCase, key, value)
287
+
288
+ override __.RenderAssert canonicalDataCase =
289
+ match canonicalDataCase.Expected with
290
+ | :? JArray as jArray ->
291
+ let renderAssertion testedFunction expected =
292
+ { Sut = sprintf "%s sut" testedFunction; Expected = expected }
293
+ |> renderInlineTemplate "{{ Sut }} |> should (equalWithin 0.000000001) {{ Expected }}"
294
+
295
+ [ renderAssertion "real" (renderNumber jArray.[0])
296
+ renderAssertion "imaginary" (renderNumber jArray.[1]) |> indent 1 ]
297
+ |> String.concat "\n"
298
+ | _ ->
299
+ base.RenderAssert(canonicalDataCase)
300
+
301
+ override __.PropertiesWithIdentifier canonicalDataCase =
302
+ match canonicalDataCase.Expected with
303
+ | :? JArray -> ["sut"]
304
+ | _ -> base.PropertiesWithIdentifier canonicalDataCase
305
+
306
+ override __.AdditionalNamespaces = [typeof<Math>.Namespace]
307
+
219
308
  type Connect() =
220
309
  inherit GeneratorExercise()
221
310
 
@@ -587,6 +587,22 @@
587
587
  "unlocked_by": "grains",
588
588
  "uuid": "cbfd4cfb-abe7-45f9-80e4-3de3b2639fc8"
589
589
  },
590
+ {
591
+ "core": false,
592
+ "difficulty": 4,
593
+ "slug": "rail-fence-cipher",
594
+ "topics": [
595
+ "algorithms",
596
+ "cryptography",
597
+ "loops",
598
+ "sorting",
599
+ "strings",
600
+ "text_formatting",
601
+ "transforming"
602
+ ],
603
+ "unlocked_by": "ledger",
604
+ "uuid": "bafd87ad-1dc5-4bbe-b853-ed330c3f155a"
605
+ },
590
606
  {
591
607
  "core": false,
592
608
  "difficulty": 2,
@@ -0,0 +1,82 @@
1
+ package main
2
+
3
+ import (
4
+ "encoding/json"
5
+ "log"
6
+ "text/template"
7
+
8
+ "../../../gen"
9
+ )
10
+
11
+ func main() {
12
+ t, err := template.New("").Parse(tmpl)
13
+ if err != nil {
14
+ log.Fatal(err)
15
+ }
16
+ var j js
17
+ if err := gen.Gen("rail-fence-cipher", &j, t); err != nil {
18
+ log.Fatal(err)
19
+ }
20
+ }
21
+
22
+ // The JSON structure we expect to be able to unmarshal into
23
+ type js struct {
24
+ Groups []testGroup `json:"cases"`
25
+ }
26
+
27
+ type testGroup struct {
28
+ Description string
29
+ Cases []json.RawMessage `property:"RAW"`
30
+ EncodeCases []oneCase `property:"encode"`
31
+ DecodeCases []oneCase `property:"decode"`
32
+ }
33
+
34
+ // Test cases
35
+ type oneCase struct {
36
+ Description string
37
+ Property string
38
+ Message string `json:"msg"`
39
+ Rails int
40
+ Expected string
41
+ }
42
+
43
+ // Template to generate test cases.
44
+ var tmpl = `package railfence
45
+
46
+ {{.Header}}
47
+
48
+ type testCase struct {
49
+ description string
50
+ message string
51
+ rails int
52
+ expected string
53
+ }
54
+
55
+ {{range .J.Groups}}
56
+ // {{ .Description }}
57
+ {{- if .EncodeCases }}
58
+ var encodeTests = []testCase{
59
+ {{- range .EncodeCases }}
60
+
61
+ { {{.Description | printf "%q"}},
62
+ {{.Message | printf "%q"}},
63
+ {{.Rails}},
64
+ {{.Expected | printf "%q"}}},
65
+ {{- end }}
66
+ }
67
+ {{- end }}
68
+
69
+ {{- if .DecodeCases }}
70
+ var decodeTests = []testCase{
71
+ {{- range .DecodeCases }}
72
+
73
+ { {{.Description | printf "%q"}},
74
+ {{.Message | printf "%q"}},
75
+ {{.Rails}},
76
+ {{.Expected | printf "%q"}}},
77
+ {{- end }}
78
+ }
79
+ {{- end }}
80
+
81
+ {{end}}
82
+ `
@@ -0,0 +1,83 @@
1
+ # Rail Fence Cipher
2
+
3
+ Implement encoding and decoding for the rail fence cipher.
4
+
5
+ The Rail Fence cipher is a form of transposition cipher that gets its name from
6
+ the way in which it's encoded. It was already used by the ancient Greeks.
7
+
8
+ In the Rail Fence cipher, the message is written downwards on successive "rails"
9
+ of an imaginary fence, then moving up when we get to the bottom (like a zig-zag).
10
+ Finally the message is then read off in rows.
11
+
12
+ For example, using three "rails" and the message "WE ARE DISCOVERED FLEE AT ONCE",
13
+ the cipherer writes out:
14
+
15
+ ```text
16
+ W . . . E . . . C . . . R . . . L . . . T . . . E
17
+ . E . R . D . S . O . E . E . F . E . A . O . C .
18
+ . . A . . . I . . . V . . . D . . . E . . . N . .
19
+ ```
20
+
21
+ Then reads off:
22
+
23
+ ```text
24
+ WECRLTEERDSOEEFEAOCAIVDEN
25
+ ```
26
+
27
+ To decrypt a message you take the zig-zag shape and fill the ciphertext along the rows.
28
+
29
+ ```text
30
+ ? . . . ? . . . ? . . . ? . . . ? . . . ? . . . ?
31
+ . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? .
32
+ . . ? . . . ? . . . ? . . . ? . . . ? . . . ? . .
33
+ ```
34
+
35
+ The first row has seven spots that can be filled with "WECRLTE".
36
+
37
+ ```text
38
+ W . . . E . . . C . . . R . . . L . . . T . . . E
39
+ . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? . ? .
40
+ . . ? . . . ? . . . ? . . . ? . . . ? . . . ? . .
41
+ ```
42
+
43
+ Now the 2nd row takes "ERDSOEEFEAOC".
44
+
45
+ ```text
46
+ W . . . E . . . C . . . R . . . L . . . T . . . E
47
+ . E . R . D . S . O . E . E . F . E . A . O . C .
48
+ . . ? . . . ? . . . ? . . . ? . . . ? . . . ? . .
49
+ ```
50
+
51
+ Leaving "AIVDEN" for the last row.
52
+
53
+ ```text
54
+ W . . . E . . . C . . . R . . . L . . . T . . . E
55
+ . E . R . D . S . O . E . E . F . E . A . O . C .
56
+ . . A . . . I . . . V . . . D . . . E . . . N . .
57
+ ```
58
+
59
+ If you now read along the zig-zag shape you can read the original message.
60
+
61
+ ## Running the tests
62
+
63
+ To run the tests run the command `go test` from within the exercise directory.
64
+
65
+ If the test suite contains benchmarks, you can run these with the `-bench`
66
+ flag:
67
+
68
+ go test -bench .
69
+
70
+ Keep in mind that each reviewer will run benchmarks on a different machine, with
71
+ different specs, so the results from these benchmark tests may vary.
72
+
73
+ ## Further information
74
+
75
+ For more detailed information about the Go track, including how to get help if
76
+ you're having trouble, please visit the exercism.io [Go language page](http://exercism.io/languages/go/about).
77
+
78
+ ## Source
79
+
80
+ Wikipedia [https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher](https://en.wikipedia.org/wiki/Transposition_cipher#Rail_Fence_cipher)
81
+
82
+ ## Submitting Incomplete Solutions
83
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.