trackler 2.2.1.98 → 2.2.1.99
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/complex-numbers/canonical-data.json +47 -47
- data/problem-specifications/exercises/custom-set/canonical-data.json +13 -7
- data/tracks/delphi/exercises/phone-number/uPhoneNumberTests.pas +1 -1
- data/tracks/elixir/exercises/protein-translation/protein_translation_test.exs +5 -0
- data/tracks/fsharp/config.json +10 -0
- data/tracks/fsharp/exercises/Exercises.sln +6 -0
- data/tracks/fsharp/exercises/accumulate/AccumulateTest.fs +2 -0
- data/tracks/fsharp/exercises/bank-account/BankAccountTest.fs +2 -0
- data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTreeTest.fs +2 -0
- data/tracks/fsharp/exercises/binary/BinaryTest.fs +2 -0
- data/tracks/fsharp/exercises/circular-buffer/CircularBufferTest.fs +121 -117
- data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fs +21 -0
- data/tracks/fsharp/exercises/complex-numbers/ComplexNumbers.fsproj +23 -0
- data/tracks/fsharp/exercises/complex-numbers/ComplexNumbersTest.fs +168 -0
- data/tracks/fsharp/exercises/complex-numbers/Example.fs +27 -0
- data/tracks/fsharp/exercises/complex-numbers/Program.fs +1 -0
- data/tracks/fsharp/exercises/complex-numbers/README.md +35 -0
- data/tracks/fsharp/exercises/diamond/DiamondTest.fs +2 -0
- data/tracks/fsharp/exercises/diffie-hellman/DiffieHellmanTest.fs +2 -0
- data/tracks/fsharp/exercises/dot-dsl/DotDslTest.fs +2 -0
- data/tracks/fsharp/exercises/error-handling/ErrorHandlingTest.fs +2 -0
- data/tracks/fsharp/exercises/go-counting/GoCountingTest.fs +2 -0
- data/tracks/fsharp/exercises/grade-school/GradeSchoolTest.fs +2 -0
- data/tracks/fsharp/exercises/hangman/HangmanTest.fs +2 -0
- data/tracks/fsharp/exercises/hexadecimal/HexadecimalTest.fs +2 -0
- data/tracks/fsharp/exercises/ledger/LedgerTest.fs +2 -0
- data/tracks/fsharp/exercises/lens-person/LensPersonTest.fs +2 -0
- data/tracks/fsharp/exercises/linked-list/LinkedListTest.fs +2 -0
- data/tracks/fsharp/exercises/matrix/MatrixTest.fs +2 -0
- data/tracks/fsharp/exercises/octal/OctalTest.fs +2 -0
- data/tracks/fsharp/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.fs +2 -0
- data/tracks/fsharp/exercises/pov/PovTest.fs +2 -0
- data/tracks/fsharp/exercises/protein-translation/ProteinTranslationTest.fs +2 -0
- data/tracks/fsharp/exercises/pythagorean-triplet/PythagoreanTripletTest.fs +2 -0
- data/tracks/fsharp/exercises/robot-name/RobotNameTest.fs +2 -0
- data/tracks/fsharp/exercises/saddle-points/SaddlePointsTest.fs +2 -0
- data/tracks/fsharp/exercises/say/SayTest.fs +2 -0
- data/tracks/fsharp/exercises/scale-generator/ScaleGeneratorTest.fs +2 -0
- data/tracks/fsharp/exercises/secret-handshake/SecretHandshakeTest.fs +2 -0
- data/tracks/fsharp/exercises/series/SeriesTest.fs +2 -0
- data/tracks/fsharp/exercises/sgf-parsing/SgfParsingTest.fs +2 -0
- data/tracks/fsharp/exercises/sieve/SieveTest.fs +2 -0
- data/tracks/fsharp/exercises/simple-cipher/SimpleCipherTest.fs +2 -0
- data/tracks/fsharp/exercises/simple-linked-list/SimpleLinkedListTest.fs +2 -0
- data/tracks/fsharp/exercises/space-age/SpaceAgeTest.fs +2 -0
- data/tracks/fsharp/exercises/strain/StrainTest.fs +2 -0
- data/tracks/fsharp/exercises/sublist/SublistTest.fs +2 -0
- data/tracks/fsharp/exercises/sum-of-multiples/SumOfMultiplesTest.fs +2 -0
- data/tracks/fsharp/exercises/tournament/TournamentTest.fs +2 -0
- data/tracks/fsharp/exercises/transpose/TransposeTest.fs +2 -0
- data/tracks/fsharp/exercises/transpose/TrinaryTest.fs +3 -1
- data/tracks/fsharp/exercises/tree-building/TreeBuildingTest.fs +2 -0
- data/tracks/fsharp/exercises/triangle/TriangleTest.fs +2 -0
- data/tracks/fsharp/exercises/trinary/TrinaryTest.fs +2 -0
- data/tracks/fsharp/exercises/two-bucket/TwoBucketTest.fs +2 -0
- data/tracks/fsharp/exercises/variable-length-quantity/VariableLengthQuantityTest.fs +2 -0
- data/tracks/fsharp/exercises/word-count/WordCountTest.fs +2 -0
- data/tracks/fsharp/exercises/word-search/WordSearchTest.fs +2 -0
- data/tracks/fsharp/exercises/wordy/WordyTest.fs +2 -0
- data/tracks/fsharp/exercises/zebra-puzzle/ZebraPuzzleTest.fs +2 -0
- data/tracks/fsharp/exercises/zipper/ZipperTest.fs +2 -0
- data/tracks/fsharp/generators/CanonicalData.fs +1 -1
- data/tracks/fsharp/generators/Generators.fs +89 -0
- data/tracks/go/config.json +16 -0
- data/tracks/go/exercises/rail-fence-cipher/.meta/gen.go +82 -0
- data/tracks/go/exercises/rail-fence-cipher/README.md +83 -0
- data/tracks/go/exercises/rail-fence-cipher/cases_test.go +50 -0
- data/tracks/go/exercises/rail-fence-cipher/example.go +58 -0
- data/tracks/go/exercises/rail-fence-cipher/rail_fence_cipher_test.go +15 -0
- data/tracks/go/exercises/say/.meta/gen.go +5 -3
- data/tracks/go/exercises/say/cases_test.go +2 -2
- data/tracks/go/exercises/scrabble-score/.meta/gen.go +5 -3
- data/tracks/go/exercises/scrabble-score/cases_test.go +2 -2
- data/tracks/go/exercises/secret-handshake/.meta/gen.go +5 -3
- data/tracks/go/exercises/secret-handshake/cases_test.go +2 -2
- data/tracks/go/exercises/transpose/.meta/gen.go +5 -3
- data/tracks/go/exercises/transpose/cases_test.go +30 -76
- data/tracks/go/exercises/word-count/.meta/gen.go +5 -3
- data/tracks/go/exercises/word-count/cases_test.go +2 -2
- data/tracks/go/exercises/wordy/.meta/gen.go +5 -3
- data/tracks/go/exercises/wordy/cases_test.go +2 -2
- data/tracks/java/exercises/largest-series-product/.meta/src/reference/java/LargestSeriesProductCalculator.java +1 -3
- data/tracks/java/exercises/largest-series-product/.meta/version +1 -0
- data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +9 -44
- data/tracks/ocaml/exercises/grade-school/.meta/description.md +21 -0
- data/tracks/ocaml/exercises/palindrome-products/.meta/description.md +35 -0
- data/tracks/ocaml/exercises/palindrome-products/README.md +13 -9
- metadata +16 -2
@@ -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
|
|
data/tracks/go/config.json
CHANGED
@@ -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.
|