trackler 2.2.1.111 → 2.2.1.113

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/README.md +6 -2
  4. data/problem-specifications/exercises/go-counting/canonical-data.json +200 -0
  5. data/problem-specifications/exercises/go-counting/description.md +2 -0
  6. data/tracks/c/config.json +24 -0
  7. data/tracks/c/exercises/minesweeper/README.md +26 -0
  8. data/tracks/c/exercises/minesweeper/makefile +25 -0
  9. data/tracks/c/exercises/minesweeper/src/example.c +64 -0
  10. data/tracks/c/exercises/minesweeper/src/example.h +7 -0
  11. data/tracks/c/exercises/minesweeper/test/test_minesweeper.c +261 -0
  12. data/tracks/c/exercises/minesweeper/test/vendor/unity.c +1300 -0
  13. data/tracks/c/exercises/minesweeper/test/vendor/unity.h +274 -0
  14. data/tracks/c/exercises/minesweeper/test/vendor/unity_internals.h +701 -0
  15. data/tracks/c/exercises/run-length-encoding/README.md +23 -0
  16. data/tracks/c/exercises/run-length-encoding/makefile +27 -0
  17. data/tracks/c/exercises/run-length-encoding/src/example.c +126 -0
  18. data/tracks/c/exercises/run-length-encoding/src/example.h +7 -0
  19. data/tracks/c/exercises/run-length-encoding/test/test_run_length_encoding.c +139 -0
  20. data/tracks/c/exercises/run-length-encoding/test/vendor/unity.c +1300 -0
  21. data/tracks/c/exercises/run-length-encoding/test/vendor/unity.h +274 -0
  22. data/tracks/c/exercises/run-length-encoding/test/vendor/unity_internals.h +701 -0
  23. data/tracks/delphi/exercises/clock/uClockTest.pas +6 -6
  24. data/tracks/ecmascript/config.json +11 -0
  25. data/tracks/ecmascript/exercises/armstrong-numbers/README.md +48 -0
  26. data/tracks/ecmascript/exercises/armstrong-numbers/armstrong-numbers.spec.js +43 -0
  27. data/tracks/ecmascript/exercises/armstrong-numbers/example.js +11 -0
  28. data/tracks/ecmascript/exercises/armstrong-numbers/package.json +70 -0
  29. data/tracks/javascript/config.json +11 -0
  30. data/tracks/javascript/exercises/armstrong-numbers/README.md +46 -0
  31. data/tracks/javascript/exercises/armstrong-numbers/armstrong-numbers.spec.js +43 -0
  32. data/tracks/javascript/exercises/armstrong-numbers/example.js +11 -0
  33. data/tracks/objective-c/config.json +12 -0
  34. data/tracks/objective-c/exercises/series/README.md +50 -0
  35. data/tracks/objective-c/exercises/series/SeriesExample.h +12 -0
  36. data/tracks/objective-c/exercises/series/SeriesExample.m +50 -0
  37. data/tracks/objective-c/exercises/series/SeriesTest.m +97 -0
  38. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  39. data/tracks/rust/exercises/gigasecond/.meta/hints.md +1 -0
  40. data/tracks/rust/exercises/gigasecond/README.md +3 -0
  41. data/tracks/rust/exercises/gigasecond/example.rs +1 -1
  42. data/tracks/rust/exercises/gigasecond/src/lib.rs +7 -7
  43. data/tracks/rust/exercises/gigasecond/tests/gigasecond.rs +1 -1
  44. data/tracks/rust/exercises/prime-factors/src/lib.rs +3 -0
  45. data/tracks/scala/exercises/saddle-points/src/test/scala/SaddlePointsTest.scala +1 -1
  46. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +18 -19
  47. data/tracks/scala/exercises/scrabble-score/src/test/scala/ScrabbleScoreTest.scala +13 -13
  48. data/tracks/scala/testgen/src/main/scala/SaddlePointsTestGenerator.scala +3 -3
  49. data/tracks/scala/testgen/src/main/scala/SayTestGenerator.scala +6 -6
  50. data/tracks/scala/testgen/src/main/scala/ScrabbleScoreTestGenerator.scala +2 -2
  51. data/tracks/typescript/config.json +16 -0
  52. data/tracks/typescript/exercises/simple-cipher/README.md +114 -0
  53. data/tracks/typescript/exercises/simple-cipher/package.json +36 -0
  54. data/tracks/typescript/exercises/simple-cipher/simple-cipher.example.ts +42 -0
  55. data/tracks/typescript/exercises/simple-cipher/simple-cipher.test.ts +84 -0
  56. data/tracks/typescript/exercises/simple-cipher/simple-cipher.ts +11 -0
  57. data/tracks/typescript/exercises/simple-cipher/tsconfig.json +22 -0
  58. data/tracks/typescript/exercises/simple-cipher/tslint.json +127 -0
  59. data/tracks/typescript/exercises/simple-cipher/yarn.lock +2624 -0
  60. metadata +39 -2
@@ -1,7 +1,7 @@
1
1
  import java.io.File
2
2
 
3
3
  import PrimeFactorsTestGenerator.toString
4
- import testgen.TestSuiteBuilder.{sutArgs, _}
4
+ import testgen.TestSuiteBuilder.{sutArgs, toString, _}
5
5
  import testgen._
6
6
 
7
7
  object SayTestGenerator {
@@ -16,8 +16,8 @@ object SayTestGenerator {
16
16
  }
17
17
  }
18
18
 
19
- def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
20
- argNames map (name => toArgString(parseResult(name))) mkString ", "
19
+ def sutArgsFromInput(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
20
+ argNames map (name => toArgString(parseResult("input").asInstanceOf[Map[String, Any]](name))) mkString ", "
21
21
 
22
22
  def toArgString(any: Any): String = {
23
23
  any match {
@@ -31,10 +31,10 @@ object SayTestGenerator {
31
31
  }
32
32
  }
33
33
 
34
- def fromLabeledTest(argNames: String*): ToTestCaseData =
34
+ def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
35
35
  withLabeledTest { sut =>
36
36
  labeledTest =>
37
- val args = sutArgs(labeledTest.result, argNames: _*)
37
+ val args = sutArgsFromInput(labeledTest.result, argNames: _*)
38
38
  val property = labeledTest.property
39
39
  val sutCall =
40
40
  s"""$sut.inEnglish($args)"""
@@ -42,7 +42,7 @@ object SayTestGenerator {
42
42
  TestCaseData(labeledTest.description, sutCall, expected)
43
43
  }
44
44
 
45
- val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
45
+ val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("number"))
46
46
  println(s"-------------")
47
47
  println(code)
48
48
  println(s"-------------")
@@ -1,13 +1,13 @@
1
1
  import java.io.File
2
2
 
3
3
  import testgen.TestSuiteBuilder
4
- import testgen.TestSuiteBuilder.fromLabeledTest
4
+ import testgen.TestSuiteBuilder.fromLabeledTestFromInput
5
5
 
6
6
  object ScrabbleScoreTestGenerator {
7
7
  def main(args: Array[String]): Unit = {
8
8
  val file = new File("src/main/resources/scrabble-score.json")
9
9
 
10
- val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
10
+ val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("word"))
11
11
  println(s"-------------")
12
12
  println(code)
13
13
  println(s"-------------")
@@ -36,6 +36,22 @@
36
36
  ],
37
37
  "uuid": "fb80f76c-42da-4f62-9f0f-8c85d984908b"
38
38
  },
39
+ {
40
+ "core": true,
41
+ "difficulty": 1,
42
+ "slug": "simple-cipher",
43
+ "topics": [
44
+ "algorithms",
45
+ "control_flow_conditionals",
46
+ "control_flow_loops",
47
+ "mathematics",
48
+ "randomness",
49
+ "strings",
50
+ "text_formatting",
51
+ "transforming"
52
+ ],
53
+ "uuid": "3ea9d03e-6d06-48e5-a4d3-6e1bb9367c2f"
54
+ },
39
55
  {
40
56
  "core": false,
41
57
  "difficulty": 2,
@@ -0,0 +1,114 @@
1
+ # Simple Cipher
2
+
3
+ Implement a simple shift cipher like Caesar and a more secure substitution cipher.
4
+
5
+ ## Step 1
6
+
7
+ "If he had anything confidential to say, he wrote it in cipher, that is,
8
+ by so changing the order of the letters of the alphabet, that not a word
9
+ could be made out. If anyone wishes to decipher these, and get at their
10
+ meaning, he must substitute the fourth letter of the alphabet, namely D,
11
+ for A, and so with the others."
12
+ —Suetonius, Life of Julius Caesar
13
+
14
+ Ciphers are very straight-forward algorithms that allow us to render
15
+ text less readable while still allowing easy deciphering. They are
16
+ vulnerable to many forms of cryptoanalysis, but we are lucky that
17
+ generally our little sisters are not cryptoanalysts.
18
+
19
+ The Caesar Cipher was used for some messages from Julius Caesar that
20
+ were sent afield. Now Caesar knew that the cipher wasn't very good, but
21
+ he had one ally in that respect: almost nobody could read well. So even
22
+ being a couple letters off was sufficient so that people couldn't
23
+ recognize the few words that they did know.
24
+
25
+ Your task is to create a simple shift cipher like the Caesar Cipher.
26
+ This image is a great example of the Caesar Cipher:
27
+
28
+ ![Caesar Cipher][1]
29
+
30
+ For example:
31
+
32
+ Giving "iamapandabear" as input to the encode function returns the cipher "ldpdsdqgdehdu". Obscure enough to keep our message secret in transit.
33
+
34
+ When "ldpdsdqgdehdu" is put into the decode function it would return
35
+ the original "iamapandabear" letting your friend read your original
36
+ message.
37
+
38
+ ## Step 2
39
+
40
+ Shift ciphers are no fun though when your kid sister figures it out. Try
41
+ amending the code to allow us to specify a key and use that for the
42
+ shift distance. This is called a substitution cipher.
43
+
44
+ Here's an example:
45
+
46
+ Given the key "aaaaaaaaaaaaaaaaaa", encoding the string "iamapandabear"
47
+ would return the original "iamapandabear".
48
+
49
+ Given the key "ddddddddddddddddd", encoding our string "iamapandabear"
50
+ would return the obscured "ldpdsdqgdehdu"
51
+
52
+ In the example above, we've set a = 0 for the key value. So when the
53
+ plaintext is added to the key, we end up with the same message coming
54
+ out. So "aaaa" is not an ideal key. But if we set the key to "dddd", we
55
+ would get the same thing as the Caesar Cipher.
56
+
57
+ ## Step 3
58
+
59
+ The weakest link in any cipher is the human being. Let's make your
60
+ substitution cipher a little more fault tolerant by providing a source
61
+ of randomness and ensuring that the key contains only lowercase letters.
62
+
63
+ If someone doesn't submit a key at all, generate a truly random key of
64
+ at least 100 characters in length.
65
+
66
+ If the key submitted is not composed only of lowercase letters, your
67
+ solution should handle the error in a language-appropriate way.
68
+
69
+ ## Extensions
70
+
71
+ Shift ciphers work by making the text slightly odd, but are vulnerable
72
+ to frequency analysis. Substitution ciphers help that, but are still
73
+ very vulnerable when the key is short or if spaces are preserved. Later
74
+ on you'll see one solution to this problem in the exercise
75
+ "crypto-square".
76
+
77
+ If you want to go farther in this field, the questions begin to be about
78
+ how we can exchange keys in a secure way. Take a look at [Diffie-Hellman
79
+ on Wikipedia][dh] for one of the first implementations of this scheme.
80
+
81
+ [1]: https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Caesar_cipher_left_shift_of_3.svg/320px-Caesar_cipher_left_shift_of_3.svg.png
82
+ [dh]: http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
83
+
84
+ ## Setup
85
+
86
+ Go through the setup instructions for TypeScript to
87
+ install the necessary dependencies:
88
+
89
+ http://exercism.io/languages/typescript
90
+
91
+ ## Requirements
92
+
93
+ Install assignment dependencies:
94
+
95
+ ```bash
96
+ $ yarn install
97
+ ```
98
+
99
+ ## Making the test suite pass
100
+
101
+ Execute the tests with:
102
+
103
+ ```bash
104
+ $ yarn test
105
+ ```
106
+
107
+
108
+
109
+ ## Source
110
+
111
+ Substitution Cipher at Wikipedia [http://en.wikipedia.org/wiki/Substitution_cipher](http://en.wikipedia.org/wiki/Substitution_cipher)
112
+
113
+ ## Submitting Incomplete Solutions
114
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "xtypescript",
3
+ "version": "1.0.0",
4
+ "description": "Exercism exercises in Typescript.",
5
+ "author": "",
6
+ "private": true,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/exercism/xtypescript"
10
+ },
11
+ "devDependencies": {},
12
+ "scripts": {
13
+ "test": "tsc --noEmit -p . && jest --no-cache",
14
+ "lint": "tsc --noEmit -p . && tslint \"*.ts?(x)\"",
15
+ "lintci": "tslint \"*.ts?(x)\" --force"
16
+ },
17
+ "dependencies": {
18
+ "@types/jest": "^21.1.5",
19
+ "@types/node": "^8.0.47",
20
+ "jest": "^21.2.1",
21
+ "ts-jest": "^21.1.3",
22
+ "tslint": "^5.8.0",
23
+ "typescript": "^2.5.3"
24
+ },
25
+ "jest": {
26
+ "transform": {
27
+ ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
28
+ },
29
+ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
30
+ "moduleFileExtensions": [
31
+ "ts",
32
+ "tsx",
33
+ "js"
34
+ ]
35
+ }
36
+ }
@@ -0,0 +1,42 @@
1
+ class SimpleCipher {
2
+ key: string
3
+
4
+ constructor(key?: string) {
5
+ if (key === undefined) {
6
+ for (let i = 0; i < 100; i++) {
7
+ this.key += String.fromCharCode(Math.random() * 26 + 97)
8
+ }
9
+ } else {
10
+ this.key = key!
11
+ }
12
+ if (!/[a-z]/.test(key!)) {
13
+ throw new Error('Bad key')
14
+ }
15
+ }
16
+
17
+ encode(decodedMessage: string): string {
18
+ let encodedMessage = ''
19
+ for (let i = 0; i < decodedMessage.length; i++) {
20
+ let encodedChar = String.fromCharCode(decodedMessage.charCodeAt(i) + (this.key.charCodeAt(i % this.key.length) - 97))
21
+ if (encodedChar.charCodeAt(0) > 122) {
22
+ encodedChar = String.fromCharCode(encodedChar.charCodeAt(0) - 26)
23
+ }
24
+ encodedMessage += encodedChar
25
+ }
26
+ return encodedMessage
27
+ }
28
+
29
+ decode(encodedMessage: string): string {
30
+ let decodedMessage = ''
31
+ for (let i = 0; i < encodedMessage.length; i++) {
32
+ let decodedChar = String.fromCharCode(encodedMessage.charCodeAt(i) - (this.key.charCodeAt(i % this.key.length) - 97))
33
+ if (decodedChar.charCodeAt(0) < 97) {
34
+ decodedChar = String.fromCharCode(decodedChar.charCodeAt(0) + 26)
35
+ }
36
+ decodedMessage += decodedChar
37
+ }
38
+ return decodedMessage
39
+ }
40
+ }
41
+
42
+ export default SimpleCipher
@@ -0,0 +1,84 @@
1
+ import SimpleCipher from './simple-cipher'
2
+
3
+ describe('Random key cipher', () => {
4
+ const simpleCipher = new SimpleCipher()
5
+
6
+ it('has a key made of letters', () => {
7
+ expect(simpleCipher.key).toMatch(/^[a-z]+$/)
8
+ })
9
+
10
+ // Here we take advantage of the fact that plaintext of "aaa..."
11
+ // outputs the key. This is a critical problem with shift ciphers, some
12
+ // characters will always output the key verbatim.
13
+ xit('can encode', () => {
14
+ expect(simpleCipher.encode('aaaaaaaaaa')).toEqual(simpleCipher.key.substr(0, 10))
15
+ })
16
+
17
+ xit('can decode', () => {
18
+ expect(simpleCipher.decode(simpleCipher.key.substr(0, 10))).toEqual('aaaaaaaaaa')
19
+ })
20
+
21
+ xit('is reversible', () => {
22
+ const plaintext = 'abcdefghij'
23
+ expect(simpleCipher.decode(simpleCipher.encode(plaintext))).toEqual(plaintext)
24
+ })
25
+ })
26
+
27
+ describe('Incorrect key cipher', () => {
28
+ xit('throws an error with an all caps key', () => {
29
+ expect(() => {
30
+ new SimpleCipher('ABCDEF')
31
+ }).toThrowError('Bad key')
32
+ })
33
+
34
+ xit('throws an error with a numeric key', () => {
35
+ expect(() => {
36
+ new SimpleCipher('12345')
37
+ }).toThrow('Bad key')
38
+ })
39
+
40
+ xit('throws an error with an empty key', () => {
41
+ expect(() => {
42
+ new SimpleCipher('')
43
+ }).toThrow('Bad key')
44
+ })
45
+ })
46
+
47
+ describe('Substitution cipher', () => {
48
+ const key = 'abcdefghij'
49
+ const simpleCipher = new SimpleCipher(key)
50
+
51
+ xit('keeps the submitted key', () => {
52
+ expect(simpleCipher.key).toEqual(key)
53
+ })
54
+
55
+ xit('can encode', () => {
56
+ expect(simpleCipher.encode('aaaaaaaaaa')).toEqual('abcdefghij')
57
+ })
58
+
59
+ xit('can decode', () => {
60
+ expect(simpleCipher.decode('abcdefghij')).toEqual('aaaaaaaaaa')
61
+ })
62
+
63
+ xit('is reversible', () => {
64
+ expect(simpleCipher.decode(simpleCipher.encode('abcdefghij'))).toEqual('abcdefghij')
65
+ })
66
+
67
+ xit(': double shift encode', () => {
68
+ expect(new SimpleCipher('iamapandabear').encode('iamapandabear'))
69
+ .toEqual('qayaeaagaciai')
70
+ })
71
+
72
+ xit('can wrap on encode', () => {
73
+ expect(simpleCipher.encode('zzzzzzzzzz')).toEqual('zabcdefghi')
74
+ })
75
+
76
+ xit('can wrap on decode', () => {
77
+ expect(simpleCipher.decode('zabcdefghi')).toEqual('zzzzzzzzzz')
78
+ })
79
+
80
+ xit('can handle messages longer than the key', () => {
81
+ expect(new SimpleCipher('abc').encode('iamapandabear'))
82
+ .toEqual('iboaqcnecbfcr')
83
+ })
84
+ })
@@ -0,0 +1,11 @@
1
+ class SimpleCipher {
2
+ encode( /* Parameters go here */ ) {
3
+ // Your code here
4
+ }
5
+
6
+ decode( /* Parameters go here */ ) {
7
+ // Your code here
8
+ }
9
+ }
10
+
11
+ export default SimpleCipher
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "commonjs",
5
+ "alwaysStrict": true,
6
+ "noUnusedLocals": true,
7
+ "noUnusedParameters": true,
8
+ "noImplicitAny": true,
9
+ "strictNullChecks": true,
10
+ "preserveConstEnums": true,
11
+ "noFallthroughCasesInSwitch":true,
12
+ "noImplicitThis":true,
13
+ "noImplicitReturns":true,
14
+ "sourceMap": true,
15
+ "noEmitOnError": true,
16
+ "outDir": "./build"
17
+ },
18
+ "compileOnSave": true,
19
+ "exclude": [
20
+ "node_modules"
21
+ ]
22
+ }
@@ -0,0 +1,127 @@
1
+ {
2
+ "jsRules": {
3
+ "class-name": true,
4
+ "comment-format": [
5
+ true,
6
+ "check-space"
7
+ ],
8
+ "indent": [
9
+ true,
10
+ "spaces"
11
+ ],
12
+ "no-duplicate-variable": true,
13
+ "no-eval": true,
14
+ "no-trailing-whitespace": true,
15
+ "no-unsafe-finally": true,
16
+ "one-line": [
17
+ true,
18
+ "check-open-brace",
19
+ "check-whitespace"
20
+ ],
21
+ "quotemark": [
22
+ false,
23
+ "double"
24
+ ],
25
+ "semicolon": [
26
+ true,
27
+ "never"
28
+ ],
29
+ "triple-equals": [
30
+ true,
31
+ "allow-null-check"
32
+ ],
33
+ "variable-name": [
34
+ true,
35
+ "ban-keywords"
36
+ ],
37
+ "whitespace": [
38
+ true,
39
+ "check-branch",
40
+ "check-decl",
41
+ "check-operator",
42
+ "check-separator",
43
+ "check-type"
44
+ ]
45
+ },
46
+ "rules": {
47
+ "class-name": true,
48
+ "comment-format": [
49
+ true,
50
+ "check-space"
51
+ ],
52
+ "indent": [
53
+ true,
54
+ "spaces"
55
+ ],
56
+ "no-eval": true,
57
+ "no-internal-module": true,
58
+ "no-trailing-whitespace": true,
59
+ "no-unsafe-finally": true,
60
+ "no-var-keyword": true,
61
+ "one-line": [
62
+ true,
63
+ "check-open-brace",
64
+ "check-whitespace"
65
+ ],
66
+ "semicolon": [
67
+ true,
68
+ "never"
69
+ ],
70
+ "triple-equals": [
71
+ true,
72
+ "allow-null-check"
73
+ ],
74
+ "typedef-whitespace": [
75
+ true,
76
+ {
77
+ "call-signature": "nospace",
78
+ "index-signature": "nospace",
79
+ "parameter": "nospace",
80
+ "property-declaration": "nospace",
81
+ "variable-declaration": "nospace"
82
+ }
83
+ ],
84
+ "variable-name": [
85
+ true,
86
+ "ban-keywords"
87
+ ],
88
+ "whitespace": [
89
+ true,
90
+ "check-branch",
91
+ "check-decl",
92
+ "check-operator",
93
+ "check-separator",
94
+ "check-type"
95
+ ],
96
+ "no-namespace": true,
97
+ "prefer-for-of": true,
98
+ "only-arrow-functions": [true, "allow-declarations"],
99
+ "no-var-requires": true,
100
+ "no-any": true,
101
+ "curly": true,
102
+ "forin": true,
103
+ "no-arg": true,
104
+ "label-position": true,
105
+ "no-conditional-assignment": true,
106
+ "no-console": [true, "log", "error"],
107
+ "no-construct": true,
108
+ "no-duplicate-variable": true,
109
+ "no-empty": true,
110
+ "no-invalid-this": [true, "check-function-in-method"],
111
+ "no-misused-new": true,
112
+ "no-null-keyword": true,
113
+ "no-string-literal": true,
114
+ "radix": true,
115
+ "typeof-compare": true,
116
+ "use-isnan": true,
117
+ "prefer-const": true,
118
+ "array-type": [true, "array-simple"],
119
+ "arrow-parens": true,
120
+ "new-parens": true,
121
+ "no-consecutive-blank-lines": [true,1],
122
+ "no-parameter-properties": true,
123
+ "no-unnecessary-initializer": true,
124
+ "object-literal-shorthand": true,
125
+ "object-literal-key-quotes": [true, "as-needed"]
126
+ }
127
+ }