trackler 2.2.1.115 → 2.2.1.116

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/yacht/canonical-data.json +251 -0
  4. data/problem-specifications/exercises/yacht/description.md +34 -0
  5. data/problem-specifications/exercises/yacht/metadata.yml +5 -0
  6. data/tracks/c/docs/C_STYLE_GUIDE.md +4 -4
  7. data/tracks/csharp/config.json +1 -1
  8. data/tracks/dart/.travis.yml +2 -4
  9. data/tracks/dart/CONTRIBUTING.md +2 -6
  10. data/tracks/dart/bin/check_formatting.dart +17 -0
  11. data/tracks/dart/bin/presubmit.dart +20 -0
  12. data/tracks/dart/config.json +1 -1
  13. data/tracks/dart/exercises/hamming/lib/example.dart +1 -1
  14. data/tracks/dart/exercises/hamming/test/hamming_test.dart +33 -20
  15. data/tracks/dart/exercises/word-count/pubspec.yaml +1 -1
  16. data/tracks/dart/exercises/word-count/test/word_count_test.dart +30 -20
  17. data/tracks/dart/lib/src/utils.dart +58 -0
  18. data/tracks/dart/pubspec.yaml +1 -0
  19. data/tracks/python/.github/stale.yml +1 -0
  20. data/tracks/scala/config.json +2 -2
  21. data/tracks/scala/exercises/space-age/src/test/scala/SpaceAgeTest.scala +2 -2
  22. data/tracks/scala/exercises/spiral-matrix/src/test/scala/SpiralMatrixTest.scala +20 -25
  23. data/tracks/scala/exercises/sublist/src/test/scala/SublistTest.scala +27 -19
  24. data/tracks/scala/exercises/sum-of-multiples/src/test/scala/SumOfMultiplesTest.scala +15 -15
  25. data/tracks/scala/testgen/src/main/scala/SpaceAgeTestGenerator.scala +9 -8
  26. data/tracks/scala/testgen/src/main/scala/SpiralMatrixTestGenerator.scala +2 -4
  27. data/tracks/scala/testgen/src/main/scala/SublistTestGenerator.scala +3 -3
  28. data/tracks/scala/testgen/src/main/scala/SumOfMultiplesTestGenerator.scala +6 -6
  29. data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +8 -0
  30. data/tracks/typescript/config.json +45 -15
  31. data/tracks/typescript/exercises/bracket-push/README.md +36 -0
  32. data/tracks/typescript/exercises/bracket-push/bracket-push.example.ts +50 -0
  33. data/tracks/typescript/exercises/bracket-push/bracket-push.test.ts +73 -0
  34. data/tracks/typescript/exercises/bracket-push/bracket-push.ts +0 -0
  35. data/tracks/typescript/exercises/bracket-push/package.json +36 -0
  36. data/tracks/typescript/exercises/bracket-push/tsconfig.json +22 -0
  37. data/tracks/typescript/exercises/bracket-push/tslint.json +127 -0
  38. data/tracks/typescript/exercises/bracket-push/yarn.lock +2624 -0
  39. data/tracks/typescript/exercises/variable-length-quantity/README.md +64 -0
  40. data/tracks/typescript/exercises/variable-length-quantity/package.json +36 -0
  41. data/tracks/typescript/exercises/variable-length-quantity/tsconfig.json +22 -0
  42. data/tracks/typescript/exercises/variable-length-quantity/tslint.json +127 -0
  43. data/tracks/typescript/exercises/variable-length-quantity/variable-length-quantity.example.ts +55 -0
  44. data/tracks/typescript/exercises/variable-length-quantity/variable-length-quantity.test.ts +115 -0
  45. data/tracks/typescript/exercises/variable-length-quantity/variable-length-quantity.ts +0 -0
  46. data/tracks/typescript/exercises/variable-length-quantity/yarn.lock +2624 -0
  47. metadata +24 -5
  48. data/tracks/dart/bin/check_formatting +0 -9
@@ -1,6 +1,7 @@
1
1
  import java.io.File
2
2
 
3
- import testgen.TestSuiteBuilder._
3
+ import testgen.CanonicalDataParser.ParseResult
4
+ import testgen.TestSuiteBuilder.{toString, _}
4
5
  import testgen._
5
6
 
6
7
  object SpaceAgeTestGenerator {
@@ -14,26 +15,26 @@ object SpaceAgeTestGenerator {
14
15
  }
15
16
  }
16
17
 
17
- def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
18
- argNames map (name => TestSuiteBuilder.toString(parseResult(name))) mkString ", "
18
+ def sutArgsFromInput(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
19
+ argNames map (name => TestSuiteBuilder.toString(fromInputMap(parseResult, name))) mkString ", "
19
20
 
20
21
  def functionName(parseResult: CanonicalDataParser.ParseResult): String =
21
- "on" + parseResult("planet").toString
22
+ "on" + fromInputMap(parseResult, "planet").toString
22
23
 
23
- def fromLabeledTest(argNames: String*): ToTestCaseData =
24
+ def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
24
25
  withLabeledTest { sut =>
25
26
  labeledTest =>
26
- val args = sutArgs(labeledTest.result, argNames: _*)
27
- val property = labeledTest.property
27
+ val args = sutArgsFromInput(labeledTest.result, argNames: _*)
28
28
  val sutCall =
29
29
  s"""$sut.${functionName(labeledTest.result)}($args)"""
30
30
  val expected = toString(labeledTest.expected)
31
31
  TestCaseData(labeledTest.description, sutCall, expected)
32
32
  }
33
33
 
34
- val code = TestSuiteBuilder.build(file, fromLabeledTest("seconds"))
34
+ val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("seconds"))
35
35
  println(s"-------------")
36
36
  println(code)
37
37
  println(s"-------------")
38
38
  }
39
+
39
40
  }
@@ -1,17 +1,15 @@
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 SpiralMatrixGenerator {
7
7
  def main(args: Array[String]): Unit = {
8
8
  val file = new File("src/main/resources/spiral-matrix.json")
9
9
 
10
- val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
10
+ val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("size"))
11
11
  println(s"-------------")
12
12
  println(code)
13
13
  println(s"-------------")
14
-
15
- TestSuiteBuilder.writeToFile(code, new File("SpiralMatrixTest.scala"))
16
14
  }
17
15
  }
@@ -17,10 +17,10 @@ object SublistTestGenerator {
17
17
  }
18
18
  }
19
19
 
20
- def fromLabeledTest(argNames: String*): ToTestCaseData =
20
+ def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
21
21
  withLabeledTest { sut =>
22
22
  labeledTest =>
23
- val args = sutArgs(labeledTest.result, argNames: _*)
23
+ val args = sutArgsFromInput(labeledTest.result, argNames: _*)
24
24
  val property = labeledTest.property
25
25
  val sutCall =
26
26
  s"$sut.$property($args)"
@@ -29,7 +29,7 @@ object SublistTestGenerator {
29
29
  }
30
30
 
31
31
  val code =
32
- TestSuiteBuilder.build(file, fromLabeledTest("listOne", "listTwo"))
32
+ TestSuiteBuilder.build(file, fromLabeledTestFromInput("listOne", "listTwo"))
33
33
 
34
34
  println(s"-------------")
35
35
  println(code)
@@ -1,5 +1,5 @@
1
1
  import testgen._
2
- import TestSuiteBuilder._
2
+ import TestSuiteBuilder.{toString, _}
3
3
  import java.io.File
4
4
 
5
5
  object SumOfMultiplesTestGenerator {
@@ -14,8 +14,8 @@ object SumOfMultiplesTestGenerator {
14
14
  }
15
15
  }
16
16
 
17
- def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
18
- argNames map (name => toArgString(parseResult(name))) mkString ", "
17
+ def sutArgsFromInput(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
18
+ argNames map (name => toArgString(parseResult("input").asInstanceOf[Map[String, Any]](name))) mkString ", "
19
19
 
20
20
  def toString(expected: CanonicalDataParser.Expected): String = {
21
21
  expected match {
@@ -24,10 +24,10 @@ object SumOfMultiplesTestGenerator {
24
24
  }
25
25
  }
26
26
 
27
- def fromLabeledTest(argNames: String*): ToTestCaseData =
27
+ def fromLabeledTestFromInput(argNames: String*): ToTestCaseData =
28
28
  withLabeledTest { sut =>
29
29
  labeledTest =>
30
- val args = sutArgs(labeledTest.result, argNames: _*)
30
+ val args = sutArgsFromInput(labeledTest.result, argNames: _*)
31
31
  val property = labeledTest.property
32
32
  val sutCall =
33
33
  s"$sut.$property($args)"
@@ -38,7 +38,7 @@ object SumOfMultiplesTestGenerator {
38
38
  def main(args: Array[String]): Unit = {
39
39
  val file = new File("src/main/resources/sum-of-multiples.json")
40
40
 
41
- val code = TestSuiteBuilder.build(file, fromLabeledTest("factors", "limit"))
41
+ val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("factors", "limit"))
42
42
  println(s"-------------")
43
43
  println(code)
44
44
  println(s"-------------")
@@ -2,9 +2,11 @@ package testgen
2
2
 
3
3
  import java.io.FileWriter
4
4
  import java.io.File
5
+
5
6
  import play.twirl.api.Txt
6
7
  import play.twirl.api.Template1
7
8
  import TestSuiteBuilder._
9
+ import testgen.CanonicalDataParser.ParseResult
8
10
 
9
11
  object TestSuiteBuilder {
10
12
 
@@ -182,6 +184,12 @@ object TestSuiteBuilder {
182
184
  }
183
185
  }
184
186
 
187
+ /**
188
+ * Get value from "input" map
189
+ */
190
+ def fromInputMap(parseResult: ParseResult, name: String) =
191
+ parseResult("input").asInstanceOf[Map[String, Any]](name)
192
+
185
193
  def writeToFile(text: String, dest: File): Unit = {
186
194
  val fileWriter = new FileWriter(dest)
187
195
  try { fileWriter.write(text) } finally fileWriter.close
@@ -328,6 +328,18 @@
328
328
  ],
329
329
  "uuid": "7d42dd76-a6cf-11e7-abc4-cec278b6b50a"
330
330
  },
331
+ {
332
+ "core": false,
333
+ "difficulty": 5,
334
+ "slug": "bracket-push",
335
+ "topics": [
336
+ "parsing",
337
+ "stacks",
338
+ "strings"
339
+ ],
340
+ "unlocked_by": null,
341
+ "uuid": "b455f96b-329d-4dec-ac31-599b02c0b2e5"
342
+ },
331
343
  {
332
344
  "core": true,
333
345
  "difficulty": 6,
@@ -762,20 +774,38 @@
762
774
  ]
763
775
  },
764
776
  {
765
- "uuid": "7dd29a19-08f6-8480-2e01-1f7262d8860a",
766
- "slug": "two-bucket",
767
- "core": false,
768
- "unlocked_by": "pangram",
769
- "difficulty": 6,
770
- "topics": [
771
- "algorithms",
772
- "arrays",
773
- "control-flow-(conditionals)",
774
- "control-flow-(loops)",
775
- "exception-handling",
776
- "games",
777
- "parsing"
778
- ]
777
+ "uuid": "7dd29a19-08f6-8480-2e01-1f7262d8860a",
778
+ "slug": "two-bucket",
779
+ "core": false,
780
+ "unlocked_by": "pangram",
781
+ "difficulty": 6,
782
+ "topics": [
783
+ "algorithms",
784
+ "arrays",
785
+ "control-flow-(conditionals)",
786
+ "control-flow-(loops)",
787
+ "exception-handling",
788
+ "games",
789
+ "parsing"
790
+ ]
791
+ },
792
+ {
793
+ "core": false,
794
+ "difficulty": 6,
795
+ "slug": "variable-length-quantity",
796
+ "topics": [
797
+ "algorithms",
798
+ "arrays",
799
+ "bitwise_operations",
800
+ "control_flow_conditionals",
801
+ "control_flow_loops",
802
+ "exception_handling",
803
+ "lists",
804
+ "loops",
805
+ "transforming"
806
+ ],
807
+ "unlocked_by": "two-bucket",
808
+ "uuid": "50050198-b5a3-4ab1-8b4b-0eadc8007ebb"
779
809
  },
780
810
  {
781
811
  "uuid": "04de61fb-9fde-461c-b306-0b4ce52e2169",
@@ -794,4 +824,4 @@
794
824
  "foregone": [],
795
825
  "language": "TypeScript",
796
826
  "test_pattern": ".*[.]test[.]ts$"
797
- }
827
+ }
@@ -0,0 +1,36 @@
1
+ # Bracket Push
2
+
3
+ Given a string containing brackets `[]`, braces `{}` and parentheses `()`,
4
+ verify that all the pairs are matched and nested correctly.
5
+
6
+ ## Setup
7
+
8
+ Go through the setup instructions for TypeScript to
9
+ install the necessary dependencies:
10
+
11
+ http://exercism.io/languages/typescript
12
+
13
+ ## Requirements
14
+
15
+ Install assignment dependencies:
16
+
17
+ ```bash
18
+ $ yarn install
19
+ ```
20
+
21
+ ## Making the test suite pass
22
+
23
+ Execute the tests with:
24
+
25
+ ```bash
26
+ $ yarn test
27
+ ```
28
+
29
+
30
+
31
+ ## Source
32
+
33
+ Ginna Baker
34
+
35
+ ## Submitting Incomplete Solutions
36
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,50 @@
1
+ class BracketPush {
2
+ bracketPairs: Map<string, string>
3
+ expression: string
4
+
5
+ constructor(expression: string) {
6
+ this.bracketPairs = new Map<string, string>()
7
+ this.bracketPairs.set('{', '}')
8
+ this.bracketPairs.set('[', ']')
9
+ this.bracketPairs.set('(', ')')
10
+
11
+ this.expression = expression
12
+ }
13
+
14
+ isPaired(): boolean {
15
+ const bracketStack: string[] = []
16
+ const expressionSplitted = this.expression.split('')
17
+
18
+ for (let i = 0; i <= expressionSplitted.length - 1; i++) {
19
+ const element = expressionSplitted[i]
20
+
21
+ if (this.isOpeningBracket(element)) {
22
+ bracketStack.push(element)
23
+ } else if (this.isClosingBracket(element)) {
24
+ if (bracketStack === []) {
25
+ return false
26
+ }
27
+
28
+ if (this.bracketPairs.get(String(bracketStack.pop())) !== element) {
29
+ return false
30
+ }
31
+ }
32
+ }
33
+
34
+ return bracketStack.length === 0
35
+ }
36
+
37
+ private isOpeningBracket(bracket: string): boolean {
38
+ return this.bracketPairs.has(bracket)
39
+ }
40
+
41
+ private isClosingBracket(bracket: string): boolean {
42
+ if (bracket === '}' || bracket === ']' || bracket === ')') {
43
+ return true
44
+ } else {
45
+ return false
46
+ }
47
+ }
48
+ }
49
+
50
+ export default BracketPush
@@ -0,0 +1,73 @@
1
+ import BracketPush from './bracket-push'
2
+
3
+ describe('Bracket Push', () => {
4
+ it('paired square brackets', () => {
5
+ const bracketPush = new BracketPush('[]')
6
+ expect(bracketPush.isPaired()).toBeTruthy()
7
+ })
8
+
9
+ xit('empty string', () => {
10
+ const bracketPush = new BracketPush('')
11
+ expect(bracketPush.isPaired()).toBeTruthy()
12
+ })
13
+
14
+ xit('unpaired brackets', () => {
15
+ const bracketPush = new BracketPush('[[')
16
+ expect(bracketPush.isPaired()).toBeFalsy()
17
+ })
18
+
19
+ xit('wrong ordered brackets', () => {
20
+ const bracketPush = new BracketPush('}{')
21
+ expect(bracketPush.isPaired()).toBeFalsy()
22
+ })
23
+
24
+ xit('wrong closing bracket', () => {
25
+ const bracketPush = new BracketPush('{]')
26
+ expect(bracketPush.isPaired()).toBeFalsy()
27
+ })
28
+
29
+ xit('paired with whitespace', () => {
30
+ const bracketPush = new BracketPush('{ }')
31
+ expect(bracketPush.isPaired()).toBeTruthy()
32
+ })
33
+
34
+ xit('simple nested brackets', () => {
35
+ const bracketPush = new BracketPush('{[]}')
36
+ expect(bracketPush.isPaired()).toBeTruthy()
37
+ })
38
+
39
+ xit('several paired brackets', () => {
40
+ const bracketPush = new BracketPush('{}[]')
41
+ expect(bracketPush.isPaired()).toBeTruthy()
42
+ })
43
+
44
+ xit('paired and nested brackets', () => {
45
+ const bracketPush = new BracketPush('([{}({}[])])')
46
+ expect(bracketPush.isPaired()).toBeTruthy()
47
+ })
48
+
49
+ xit('unopened closing brackets', () => {
50
+ const bracketPush = new BracketPush('{[)][]}')
51
+ expect(bracketPush.isPaired()).toBeFalsy()
52
+ })
53
+
54
+ xit('unpaired and nested brackets', () => {
55
+ const bracketPush = new BracketPush('([{])')
56
+ expect(bracketPush.isPaired()).toBeFalsy()
57
+ })
58
+
59
+ xit('paired and wrong nested brackets', () => {
60
+ const bracketPush = new BracketPush('[({]})')
61
+ expect(bracketPush.isPaired()).toBeFalsy()
62
+ })
63
+
64
+ xit('math expression', () => {
65
+ const bracketPush = new BracketPush('(((185 + 223.85) * 15) - 543)/2')
66
+ expect(bracketPush.isPaired()).toBeTruthy()
67
+ })
68
+
69
+ xit('complex latex expression', () => {
70
+ const bracketPush = new BracketPush('\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)')
71
+ expect(bracketPush.isPaired()).toBeTruthy()
72
+ })
73
+ })
@@ -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,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
+ }