trackler 2.0.8.46 → 2.0.8.47

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 (156) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/ecmascript/.travis.yml +1 -1
  4. data/tracks/ecmascript/README.md +9 -4
  5. data/tracks/ecmascript/exercises/accumulate/gulpfile.js +41 -38
  6. data/tracks/ecmascript/exercises/accumulate/package.json +7 -2
  7. data/tracks/ecmascript/exercises/acronym/gulpfile.js +41 -38
  8. data/tracks/ecmascript/exercises/acronym/package.json +7 -2
  9. data/tracks/ecmascript/exercises/all-your-base/gulpfile.js +41 -38
  10. data/tracks/ecmascript/exercises/all-your-base/package.json +7 -2
  11. data/tracks/ecmascript/exercises/allergies/allergies.spec.js +1 -1
  12. data/tracks/ecmascript/exercises/allergies/gulpfile.js +41 -38
  13. data/tracks/ecmascript/exercises/allergies/package.json +7 -2
  14. data/tracks/ecmascript/exercises/anagram/gulpfile.js +41 -38
  15. data/tracks/ecmascript/exercises/anagram/package.json +7 -2
  16. data/tracks/ecmascript/exercises/atbash-cipher/gulpfile.js +41 -38
  17. data/tracks/ecmascript/exercises/atbash-cipher/package.json +7 -2
  18. data/tracks/ecmascript/exercises/beer-song/gulpfile.js +41 -38
  19. data/tracks/ecmascript/exercises/beer-song/package.json +7 -2
  20. data/tracks/ecmascript/exercises/binary-search-tree/gulpfile.js +41 -38
  21. data/tracks/ecmascript/exercises/binary-search-tree/package.json +7 -2
  22. data/tracks/ecmascript/exercises/binary-search/gulpfile.js +41 -38
  23. data/tracks/ecmascript/exercises/binary-search/package.json +7 -2
  24. data/tracks/ecmascript/exercises/binary/gulpfile.js +41 -38
  25. data/tracks/ecmascript/exercises/binary/package.json +7 -2
  26. data/tracks/ecmascript/exercises/bob/gulpfile.js +41 -38
  27. data/tracks/ecmascript/exercises/bob/package.json +7 -2
  28. data/tracks/ecmascript/exercises/bracket-push/gulpfile.js +41 -38
  29. data/tracks/ecmascript/exercises/bracket-push/package.json +7 -2
  30. data/tracks/ecmascript/exercises/circular-buffer/gulpfile.js +41 -38
  31. data/tracks/ecmascript/exercises/circular-buffer/package.json +7 -2
  32. data/tracks/ecmascript/exercises/clock/gulpfile.js +41 -38
  33. data/tracks/ecmascript/exercises/clock/package.json +7 -2
  34. data/tracks/ecmascript/exercises/crypto-square/gulpfile.js +41 -38
  35. data/tracks/ecmascript/exercises/crypto-square/package.json +7 -2
  36. data/tracks/ecmascript/exercises/custom-set/gulpfile.js +41 -38
  37. data/tracks/ecmascript/exercises/custom-set/package.json +7 -2
  38. data/tracks/ecmascript/exercises/diamond/gulpfile.js +41 -38
  39. data/tracks/ecmascript/exercises/diamond/package.json +7 -2
  40. data/tracks/ecmascript/exercises/difference-of-squares/gulpfile.js +41 -38
  41. data/tracks/ecmascript/exercises/difference-of-squares/package.json +7 -2
  42. data/tracks/ecmascript/exercises/etl/gulpfile.js +41 -38
  43. data/tracks/ecmascript/exercises/etl/package.json +7 -2
  44. data/tracks/ecmascript/exercises/food-chain/gulpfile.js +41 -38
  45. data/tracks/ecmascript/exercises/food-chain/package.json +7 -2
  46. data/tracks/ecmascript/exercises/gigasecond/gulpfile.js +41 -38
  47. data/tracks/ecmascript/exercises/gigasecond/package.json +7 -2
  48. data/tracks/ecmascript/exercises/grade-school/gulpfile.js +41 -38
  49. data/tracks/ecmascript/exercises/grade-school/package.json +7 -2
  50. data/tracks/ecmascript/exercises/grains/gulpfile.js +41 -38
  51. data/tracks/ecmascript/exercises/grains/package.json +7 -2
  52. data/tracks/ecmascript/exercises/gulpfile.js +89 -0
  53. data/tracks/ecmascript/exercises/hamming/gulpfile.js +41 -38
  54. data/tracks/ecmascript/exercises/hamming/package.json +7 -2
  55. data/tracks/ecmascript/exercises/hello-world/gulpfile.js +41 -38
  56. data/tracks/ecmascript/exercises/hello-world/package.json +7 -2
  57. data/tracks/ecmascript/exercises/hexadecimal/gulpfile.js +41 -38
  58. data/tracks/ecmascript/exercises/hexadecimal/package.json +7 -2
  59. data/tracks/ecmascript/exercises/isogram/gulpfile.js +41 -38
  60. data/tracks/ecmascript/exercises/isogram/package.json +7 -2
  61. data/tracks/ecmascript/exercises/kindergarten-garden/gulpfile.js +41 -38
  62. data/tracks/ecmascript/exercises/kindergarten-garden/package.json +7 -2
  63. data/tracks/ecmascript/exercises/largest-series-product/gulpfile.js +41 -38
  64. data/tracks/ecmascript/exercises/largest-series-product/package.json +7 -2
  65. data/tracks/ecmascript/exercises/leap/gulpfile.js +41 -38
  66. data/tracks/ecmascript/exercises/leap/package.json +7 -2
  67. data/tracks/ecmascript/exercises/linked-list/gulpfile.js +41 -38
  68. data/tracks/ecmascript/exercises/linked-list/package.json +7 -2
  69. data/tracks/ecmascript/exercises/luhn/gulpfile.js +41 -38
  70. data/tracks/ecmascript/exercises/luhn/package.json +7 -2
  71. data/tracks/ecmascript/exercises/matrix/gulpfile.js +41 -38
  72. data/tracks/ecmascript/exercises/matrix/package.json +7 -2
  73. data/tracks/ecmascript/exercises/meetup/gulpfile.js +41 -38
  74. data/tracks/ecmascript/exercises/meetup/package.json +7 -2
  75. data/tracks/ecmascript/exercises/nth-prime/gulpfile.js +41 -38
  76. data/tracks/ecmascript/exercises/nth-prime/package.json +7 -2
  77. data/tracks/ecmascript/exercises/ocr-numbers/gulpfile.js +41 -38
  78. data/tracks/ecmascript/exercises/ocr-numbers/package.json +7 -2
  79. data/tracks/ecmascript/exercises/octal/gulpfile.js +41 -38
  80. data/tracks/ecmascript/exercises/octal/package.json +7 -2
  81. data/tracks/ecmascript/exercises/package.json +28 -0
  82. data/tracks/ecmascript/exercises/palindrome-products/gulpfile.js +41 -38
  83. data/tracks/ecmascript/exercises/palindrome-products/package.json +7 -2
  84. data/tracks/ecmascript/exercises/pangram/gulpfile.js +41 -38
  85. data/tracks/ecmascript/exercises/pangram/package.json +7 -2
  86. data/tracks/ecmascript/exercises/pascals-triangle/gulpfile.js +41 -38
  87. data/tracks/ecmascript/exercises/pascals-triangle/package.json +7 -2
  88. data/tracks/ecmascript/exercises/perfect-numbers/gulpfile.js +41 -38
  89. data/tracks/ecmascript/exercises/perfect-numbers/package.json +7 -2
  90. data/tracks/ecmascript/exercises/phone-number/gulpfile.js +41 -38
  91. data/tracks/ecmascript/exercises/phone-number/package.json +7 -2
  92. data/tracks/ecmascript/exercises/pig-latin/gulpfile.js +41 -38
  93. data/tracks/ecmascript/exercises/pig-latin/package.json +7 -2
  94. data/tracks/ecmascript/exercises/prime-factors/gulpfile.js +41 -38
  95. data/tracks/ecmascript/exercises/prime-factors/package.json +7 -2
  96. data/tracks/ecmascript/exercises/pythagorean-triplet/gulpfile.js +41 -38
  97. data/tracks/ecmascript/exercises/pythagorean-triplet/package.json +7 -2
  98. data/tracks/ecmascript/exercises/queen-attack/gulpfile.js +41 -38
  99. data/tracks/ecmascript/exercises/queen-attack/package.json +7 -2
  100. data/tracks/ecmascript/exercises/raindrops/gulpfile.js +41 -38
  101. data/tracks/ecmascript/exercises/raindrops/package.json +7 -2
  102. data/tracks/ecmascript/exercises/rna-transcription/gulpfile.js +41 -38
  103. data/tracks/ecmascript/exercises/rna-transcription/package.json +7 -2
  104. data/tracks/ecmascript/exercises/robot-name/gulpfile.js +41 -38
  105. data/tracks/ecmascript/exercises/robot-name/package.json +7 -2
  106. data/tracks/ecmascript/exercises/robot-simulator/gulpfile.js +41 -38
  107. data/tracks/ecmascript/exercises/robot-simulator/package.json +7 -2
  108. data/tracks/ecmascript/exercises/roman-numerals/gulpfile.js +41 -38
  109. data/tracks/ecmascript/exercises/roman-numerals/package.json +7 -2
  110. data/tracks/ecmascript/exercises/saddle-points/gulpfile.js +41 -38
  111. data/tracks/ecmascript/exercises/saddle-points/package.json +7 -2
  112. data/tracks/ecmascript/exercises/say/gulpfile.js +41 -38
  113. data/tracks/ecmascript/exercises/say/package.json +7 -2
  114. data/tracks/ecmascript/exercises/scrabble-score/gulpfile.js +41 -38
  115. data/tracks/ecmascript/exercises/scrabble-score/package.json +7 -2
  116. data/tracks/ecmascript/exercises/secret-handshake/gulpfile.js +41 -38
  117. data/tracks/ecmascript/exercises/secret-handshake/package.json +7 -2
  118. data/tracks/ecmascript/exercises/series/gulpfile.js +41 -38
  119. data/tracks/ecmascript/exercises/series/package.json +7 -2
  120. data/tracks/ecmascript/exercises/sieve/gulpfile.js +41 -38
  121. data/tracks/ecmascript/exercises/sieve/package.json +7 -2
  122. data/tracks/ecmascript/exercises/simple-cipher/gulpfile.js +41 -38
  123. data/tracks/ecmascript/exercises/simple-cipher/package.json +7 -2
  124. data/tracks/ecmascript/exercises/space-age/gulpfile.js +41 -38
  125. data/tracks/ecmascript/exercises/space-age/package.json +7 -2
  126. data/tracks/ecmascript/exercises/strain/gulpfile.js +41 -38
  127. data/tracks/ecmascript/exercises/strain/package.json +7 -2
  128. data/tracks/ecmascript/exercises/sum-of-multiples/gulpfile.js +41 -38
  129. data/tracks/ecmascript/exercises/sum-of-multiples/package.json +7 -2
  130. data/tracks/ecmascript/exercises/triangle/gulpfile.js +41 -38
  131. data/tracks/ecmascript/exercises/triangle/package.json +7 -2
  132. data/tracks/ecmascript/exercises/triangle/triangle.spec.js +1 -1
  133. data/tracks/ecmascript/exercises/trinary/gulpfile.js +41 -38
  134. data/tracks/ecmascript/exercises/trinary/package.json +7 -2
  135. data/tracks/ecmascript/exercises/two-bucket/gulpfile.js +41 -38
  136. data/tracks/ecmascript/exercises/two-bucket/package.json +7 -2
  137. data/tracks/ecmascript/exercises/word-count/gulpfile.js +41 -38
  138. data/tracks/ecmascript/exercises/word-count/package.json +7 -2
  139. data/tracks/ecmascript/exercises/wordy/gulpfile.js +41 -38
  140. data/tracks/ecmascript/exercises/wordy/package.json +7 -2
  141. data/tracks/ecmascript/gulpfile.js +41 -38
  142. data/tracks/ecmascript/package.json +7 -2
  143. data/tracks/julia/exercises/difference-of-squares/difference-of-squares.jl +4 -4
  144. data/tracks/lfe/docs/INSTALLATION.md +10 -2
  145. data/tracks/objective-c/config.json +9 -0
  146. data/tracks/objective-c/exercises/pascals-triangle/PascalsTriangleExample.h +9 -0
  147. data/tracks/objective-c/exercises/pascals-triangle/PascalsTriangleExample.m +54 -0
  148. data/tracks/objective-c/exercises/pascals-triangle/PascalsTriangleTest.m +53 -0
  149. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  150. data/tracks/python/exercises/grains/example.py +13 -2
  151. data/tracks/python/exercises/grains/grains_test.py +22 -1
  152. data/tracks/swift/.travis.yml +9 -2
  153. data/tracks/swift/exercises/binary-search-tree/Sources/BinarySearchTreeExample.swift +1 -1
  154. data/tracks/swift/exercises/minesweeper/Sources/MinesweeperExample.swift +4 -0
  155. data/tracks/swift/exercises/robot-name/Tests/RobotNameTests/RobotNameTests.swift +5 -1
  156. metadata +7 -2
@@ -9,10 +9,15 @@
9
9
  "url": "https://github.com/exercism/xecmascript"
10
10
  },
11
11
  "devDependencies": {
12
- "babel": "~5.8.29",
12
+ "babel-cli": "^6.24.1",
13
+ "babel-core": "^6.24.1",
14
+ "babel-plugin-transform-object-rest-spread": "^6.23.0",
15
+ "babel-polyfill": "^6.23.0",
16
+ "babel-preset-env": "^1.3.3",
17
+ "babel-preset-es2015": "^6.24.1",
13
18
  "del": "~2.0.2",
14
19
  "gulp": "~3.9.0",
15
- "gulp-babel": "~5.3.0",
20
+ "gulp-babel": "^6.1.2",
16
21
  "gulp-eslint": "^1.1.0",
17
22
  "gulp-jasmine": "~2.4.2",
18
23
  "yargs": "~3.27.0"
@@ -16,65 +16,68 @@ const gulp = require('gulp'),
16
16
  eslint = require('gulp-eslint'),
17
17
  jasmine = require('gulp-jasmine'),
18
18
  babel = require('gulp-babel'),
19
- polyfill = require('babel/polyfill'),
19
+ polyfill = require('babel-polyfill'),
20
20
  del = require('del'),
21
- argv = require('yargs').argv,
21
+ argv = require('yargs').argv,
22
22
  inputDir = getInputDirectory(argv),
23
23
  outputDir = getOutputDirectory(argv);
24
24
 
25
25
  // Gulp tasks definition
26
26
 
27
- gulp.task('default', [ 'test' ]);
27
+ gulp.task('default', ['test']);
28
28
 
29
- gulp.task('test', [ 'babel' ], function () {
30
- return gulp.src([ outputDir + '/*.spec.js' ])
29
+ gulp.task('test', ['babel'], function () {
30
+ return gulp.src([outputDir + '/*.spec.js'])
31
31
  .pipe(jasmine());
32
32
  });
33
33
 
34
34
  gulp.task('babel', function () {
35
- return gulp.src([ inputDir + '/*.js', inputDir + '/lib/*.js' ])
36
- .pipe(babel())
35
+ return gulp.src([inputDir + '/*.js', inputDir + '/lib/*.js'])
36
+ .pipe(babel({
37
+ plugins: ["babel-plugin-transform-object-rest-spread"].map(require.resolve),
38
+ presets: ['babel-preset-env'].map(require.resolve)
39
+ }))
37
40
  .pipe(gulp.dest(outputDir));
38
41
  });
39
42
 
40
43
  gulp.task('lint', function () {
41
- return gulp.src([ inputDir + '/*.js' ])
44
+ return gulp.src([inputDir + '/*.js'])
42
45
  .pipe(eslint({
43
- envs: [
46
+ envs: [
44
47
  'es6' //turns on all es6 features except modules
45
48
  ],
46
- rules: {
49
+ rules: {
47
50
  // full documentation here : http://eslint.org/docs/rules
48
51
 
49
52
  // Possible errors
50
- 'comma-dangle': [2, 'never'], // don't let a comma at the end of object properties or array element
51
- 'no-cond-assign': [2, 'always'], // no assignments in conditional statements
52
- 'no-console': 2, // no console.log() statements in production code
53
- 'no-constant-condition': 2, // no constants in conditional statements
54
- 'no-control-regex': 2, // no control characters in regex's
55
- 'no-debugger': 2, // no debugger in productin code
56
- 'no-dupe-args': 2, // no duplicated arguments in functions
57
- 'no-dupe-keys': 2, // no duplicated keys when creating object literals
58
- 'no-duplicate-case': 2, // no duplicated `case` in `switch` statements
53
+ 'comma-dangle': [2, 'never'], // don't let a comma at the end of object properties or array element
54
+ 'no-cond-assign': [2, 'always'], // no assignments in conditional statements
55
+ 'no-console': 2, // no console.log() statements in production code
56
+ 'no-constant-condition': 2, // no constants in conditional statements
57
+ 'no-control-regex': 2, // no control characters in regex's
58
+ 'no-debugger': 2, // no debugger in productin code
59
+ 'no-dupe-args': 2, // no duplicated arguments in functions
60
+ 'no-dupe-keys': 2, // no duplicated keys when creating object literals
61
+ 'no-duplicate-case': 2, // no duplicated `case` in `switch` statements
59
62
  'no-empty-character-class': 2, // disallow the use of empty character classes in regular expressions
60
- 'no-empty': 2, // no empty blocks
61
- 'no-ex-assign': 2, // do not assign any value to an Exception raised
62
- 'no-extra-boolean-cast': 2, // do not use !!falseExpression to cast to boolean
63
- 'no-extra-parens': 2, // do not use extra parenthesis
64
- 'no-extra-semi': 2, // do not use extra semicolons
65
- 'no-func-assign': 2, // do not overwrite variables declared as functions
66
- 'no-inner-declarations': [2, 'both'], // only declare var's and funct's on function scope
67
- 'no-invalid-regexp': 2, // validates string arguments passed to RegExp constructor
68
- 'no-irregular-whitespace': 2, // detects special characters used as spaces
69
- 'no-negated-in-lhs': 2, // do not use negation in the left operand in an `in` expression
70
- 'no-obj-calls': 2, // prevent calling global objects as if they were functions
71
- 'no-regex-spaces': 2, // do not use multiple spaces in regex's
72
- 'no-sparse-arrays': 2, // do not use sparse arrays (empty elements)
73
- 'no-unexpected-multiline': 2, // Avoid code that looks like two expressions but is actually one
74
- 'no-unreachable': 2, // detects unreachable statements (after return, throw,...)
75
- 'use-isnan': 2, // do not compare with `NaN` value, use isNan() instead
76
- 'valid-jsdoc': 2, // ensure JSDoc comments are valid
77
- 'valid-typeof': 2 // ensure that the results of typeof are compared against a valid string
63
+ 'no-empty': 2, // no empty blocks
64
+ 'no-ex-assign': 2, // do not assign any value to an Exception raised
65
+ 'no-extra-boolean-cast': 2, // do not use !!falseExpression to cast to boolean
66
+ 'no-extra-parens': 2, // do not use extra parenthesis
67
+ 'no-extra-semi': 2, // do not use extra semicolons
68
+ 'no-func-assign': 2, // do not overwrite variables declared as functions
69
+ 'no-inner-declarations': [2, 'both'], // only declare var's and funct's on function scope
70
+ 'no-invalid-regexp': 2, // validates string arguments passed to RegExp constructor
71
+ 'no-irregular-whitespace': 2, // detects special characters used as spaces
72
+ 'no-negated-in-lhs': 2, // do not use negation in the left operand in an `in` expression
73
+ 'no-obj-calls': 2, // prevent calling global objects as if they were functions
74
+ 'no-regex-spaces': 2, // do not use multiple spaces in regex's
75
+ 'no-sparse-arrays': 2, // do not use sparse arrays (empty elements)
76
+ 'no-unexpected-multiline': 2, // Avoid code that looks like two expressions but is actually one
77
+ 'no-unreachable': 2, // detects unreachable statements (after return, throw,...)
78
+ 'use-isnan': 2, // do not compare with `NaN` value, use isNan() instead
79
+ 'valid-jsdoc': 2, // ensure JSDoc comments are valid
80
+ 'valid-typeof': 2 // ensure that the results of typeof are compared against a valid string
78
81
  },
79
82
  ecmaFeatures: {
80
83
  'modules': true //this gives us modules :)
@@ -85,5 +88,5 @@ gulp.task('lint', function () {
85
88
  });
86
89
 
87
90
  gulp.task('clean', function (cb) {
88
- del([ outputDir ], cb);
91
+ del([outputDir], cb);
89
92
  });
@@ -9,10 +9,15 @@
9
9
  "url": "https://github.com/exercism/xecmascript"
10
10
  },
11
11
  "devDependencies": {
12
- "babel": "~5.8.29",
12
+ "babel-cli": "^6.24.1",
13
+ "babel-core": "^6.24.1",
14
+ "babel-plugin-transform-object-rest-spread": "^6.23.0",
15
+ "babel-polyfill": "^6.23.0",
16
+ "babel-preset-env": "^1.3.3",
17
+ "babel-preset-es2015": "^6.24.1",
13
18
  "del": "~2.0.2",
14
19
  "gulp": "~3.9.0",
15
- "gulp-babel": "~5.3.0",
20
+ "gulp-babel": "^6.1.2",
16
21
  "gulp-eslint": "^1.1.0",
17
22
  "gulp-jasmine": "~2.4.2",
18
23
  "yargs": "~3.27.0"
@@ -1,10 +1,10 @@
1
- "Square the sum of the numbers up to the given number"
2
- function sum_of_squares(n::Int)
1
+ "Sum the squares of the numbers up to the given number"
2
+ function square_of_sum(n::Int)
3
3
 
4
4
  end
5
5
 
6
- "Sum the squares of the numbers up to the given number"
7
- function square_of_sum(n::Int)
6
+ "Square the sum of the numbers up to the given number"
7
+ function sum_of_squares(n::Int)
8
8
 
9
9
  end
10
10
 
@@ -17,8 +17,16 @@ $ brew install lfe
17
17
  ```
18
18
 
19
19
  ### Installing from Source
20
- With your system's "developer tools" or "essential build packages", `git`
21
- and Erlang's `erl` installed, you can download and build LFE with the following:
20
+ Install your system's "developer tools" or "essential build packages", `git`
21
+ and Erlang's `erl`.
22
+
23
+ For example, on Ubuntu 14.04:
24
+
25
+ ```bash
26
+ $ sudo apt-get install build-essentials git erlang erlang-base-hipe
27
+ ```.
28
+
29
+ Afterwards you can download and build LFE with the following:
22
30
 
23
31
  ```bash
24
32
  $ git clone https://github.com/rvirding/lfe
@@ -289,6 +289,15 @@
289
289
  "Strings"
290
290
  ]
291
291
  },
292
+ {
293
+ "difficulty": 4,
294
+ "slug": "pascals-triangle",
295
+ "topics": [
296
+ "Recursion",
297
+ "Lists",
298
+ "Mathematics"
299
+ ]
300
+ },
292
301
  {
293
302
  "difficulty": 5,
294
303
  "slug": "bracket-push",
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+
3
+ @interface PascalsTriangle : NSObject
4
+
5
+ @property (nonatomic, strong) NSArray<NSArray <NSNumber *> *> *rows;
6
+
7
+ - (instancetype)initWithNumberOfRows:(int)numberOfRows;
8
+
9
+ @end
@@ -0,0 +1,54 @@
1
+ #import "PascalsTriangleExample.h"
2
+
3
+ @implementation PascalsTriangle
4
+
5
+ - (instancetype)initWithNumberOfRows:(int)numberOfRows {
6
+ self = [super init];
7
+
8
+ if (self) {
9
+ self.rows = [PascalsTriangle triangleForNumberOfRows:numberOfRows];
10
+ }
11
+
12
+ return self;
13
+ }
14
+
15
+ + (NSMutableArray<NSArray<NSNumber *> *> *)triangleForNumberOfRows:(int)numberOfRows {
16
+ NSMutableArray<NSArray<NSNumber *> *> *triangle = [[NSMutableArray alloc] init];
17
+
18
+ for (int i = 0; i < numberOfRows; i++) {
19
+ NSMutableArray *values = [[NSMutableArray alloc] init];
20
+
21
+ if (i == 0) {
22
+ [values addObject:@1];
23
+ } else {
24
+ NSArray<NSNumber *> *lastRow = triangle[i - 1];
25
+ NSUInteger length = lastRow.count;
26
+
27
+ for (int j = 0; j <= length; j++) {
28
+ int left;
29
+
30
+ if (j == 0) {
31
+ left = 0;
32
+ } else {
33
+ left = [lastRow[j - 1] intValue];
34
+ }
35
+
36
+ int right;
37
+
38
+ if (j < length) {
39
+ right = [lastRow[j] intValue];
40
+ } else {
41
+ right = 0;
42
+ }
43
+
44
+ [values addObject:@(left + right)];
45
+ }
46
+ }
47
+
48
+ [triangle addObject:values];
49
+ }
50
+
51
+ return triangle;
52
+ }
53
+
54
+ @end
@@ -0,0 +1,53 @@
1
+ #import <XCTest/XCTest.h>
2
+
3
+ #if __has_include("PascalsTriangleExample.h")
4
+ # import "PascalsTriangleExample.h"
5
+ # else
6
+ # import "PascalsTriangle.h"
7
+ #endif
8
+
9
+ @interface PascalsTriangleTest : XCTestCase
10
+
11
+ @end
12
+
13
+ @implementation PascalsTriangleTest
14
+
15
+ - (void)testOneRow {
16
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:1];
17
+ XCTAssertEqualObjects(@[@[@1]], triangle.rows);
18
+ }
19
+
20
+ - (void)testTwoRows {
21
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:2];
22
+ NSArray *expected = @[@[@1], @[@1, @1]];
23
+ XCTAssertEqualObjects(expected, triangle.rows);
24
+ }
25
+
26
+ - (void)testThreeRows {
27
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:3];
28
+ NSArray *expected = @[@[@1], @[@1, @1], @[@1, @2, @1]];
29
+ XCTAssertEqualObjects(expected, triangle.rows);
30
+ }
31
+
32
+ - (void)testFourthRow {
33
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:4];
34
+ NSArray *expected = @[@1, @3, @3, @1];
35
+ XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
36
+ }
37
+
38
+ - (void)testFifthRow {
39
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:5];
40
+ NSArray *expected = @[@1, @4, @6, @4, @1];
41
+ XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
42
+ }
43
+
44
+ - (void)testTwentiethRow {
45
+ PascalsTriangle *triangle = [[PascalsTriangle alloc] initWithNumberOfRows:20];
46
+ NSArray *expected = @[
47
+ @1, @19, @171, @969, @3876, @11628, @27132, @50388, @75582, @92378, @92378,
48
+ @75582, @50388, @27132, @11628, @3876, @969, @171, @19, @1
49
+ ];
50
+ XCTAssertEqualObjects(expected, [triangle.rows lastObject]);
51
+ }
52
+
53
+ @end
@@ -95,6 +95,8 @@
95
95
  E9C1C0311D9EC1270015E86E /* RunLengthEncodingTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E9C1C0301D9EC1270015E86E /* RunLengthEncodingTest.m */; };
96
96
  E9F390071DFCA337005C5F46 /* IsogramExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E9F390061DFCA337005C5F46 /* IsogramExample.m */; };
97
97
  E9F390091DFCA350005C5F46 /* IsogramTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E9F390081DFCA350005C5F46 /* IsogramTest.m */; };
98
+ E9FCFED31E98333D003080C0 /* PascalsTriangleExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E9FCFED21E98333D003080C0 /* PascalsTriangleExample.m */; };
99
+ E9FCFED51E983361003080C0 /* PascalsTriangleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E9FCFED41E983361003080C0 /* PascalsTriangleTest.m */; };
98
100
  E9FDCA191D5407D2004EE8DB /* RomanNumeralsExample.m in Sources */ = {isa = PBXBuildFile; fileRef = E9FDCA181D5407D2004EE8DB /* RomanNumeralsExample.m */; };
99
101
  E9FDCA1B1D540801004EE8DB /* RomanNumeralsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E9FDCA1A1D540801004EE8DB /* RomanNumeralsTest.m */; };
100
102
  /* End PBXBuildFile section */
@@ -213,6 +215,9 @@
213
215
  E9F390051DFCA337005C5F46 /* IsogramExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IsogramExample.h; path = ../../exercises/isogram/IsogramExample.h; sourceTree = "<group>"; };
214
216
  E9F390061DFCA337005C5F46 /* IsogramExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IsogramExample.m; path = ../../exercises/isogram/IsogramExample.m; sourceTree = "<group>"; };
215
217
  E9F390081DFCA350005C5F46 /* IsogramTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = IsogramTest.m; path = ../../exercises/isogram/IsogramTest.m; sourceTree = "<group>"; };
218
+ E9FCFED11E98333D003080C0 /* PascalsTriangleExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PascalsTriangleExample.h; path = "../../exercises/pascals-triangle/PascalsTriangleExample.h"; sourceTree = "<group>"; };
219
+ E9FCFED21E98333D003080C0 /* PascalsTriangleExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PascalsTriangleExample.m; path = "../../exercises/pascals-triangle/PascalsTriangleExample.m"; sourceTree = "<group>"; };
220
+ E9FCFED41E983361003080C0 /* PascalsTriangleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PascalsTriangleTest.m; path = "../../exercises/pascals-triangle/PascalsTriangleTest.m"; sourceTree = "<group>"; };
216
221
  E9FDCA171D5407D2004EE8DB /* RomanNumeralsExample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RomanNumeralsExample.h; path = "../../exercises/roman-numerals/RomanNumeralsExample.h"; sourceTree = "<group>"; };
217
222
  E9FDCA181D5407D2004EE8DB /* RomanNumeralsExample.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RomanNumeralsExample.m; path = "../../exercises/roman-numerals/RomanNumeralsExample.m"; sourceTree = "<group>"; };
218
223
  E9FDCA1A1D540801004EE8DB /* RomanNumeralsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RomanNumeralsTest.m; path = "../../exercises/roman-numerals/RomanNumeralsTest.m"; sourceTree = "<group>"; };
@@ -256,6 +261,7 @@
256
261
  E92FCC0A1D78F2AA00061017 /* Meetup */,
257
262
  E9E8B6F21D519E180012F12C /* NucleotideCount */,
258
263
  E9B345F51DB937E5006EFBE2 /* Pangram */,
264
+ E9FCFED01E9832B2003080C0 /* PascalsTriangle */,
259
265
  E9E8B6F31D519E200012F12C /* PerfectNumbers */,
260
266
  E9E8B6F41D519E270012F12C /* PhoneNumber */,
261
267
  E9381D491D8F293C003F22A1 /* Raindrops */,
@@ -661,6 +667,16 @@
661
667
  name = Isogram;
662
668
  sourceTree = "<group>";
663
669
  };
670
+ E9FCFED01E9832B2003080C0 /* PascalsTriangle */ = {
671
+ isa = PBXGroup;
672
+ children = (
673
+ E9FCFED11E98333D003080C0 /* PascalsTriangleExample.h */,
674
+ E9FCFED21E98333D003080C0 /* PascalsTriangleExample.m */,
675
+ E9FCFED41E983361003080C0 /* PascalsTriangleTest.m */,
676
+ );
677
+ name = PascalsTriangle;
678
+ sourceTree = "<group>";
679
+ };
664
680
  E9FDCA161D540793004EE8DB /* RomanNumerals */ = {
665
681
  isa = PBXGroup;
666
682
  children = (
@@ -762,6 +778,7 @@
762
778
  E94ACA131D41760300D56CC2 /* AllYourBaseExample.m in Sources */,
763
779
  E94ACA151D41763800D56CC2 /* AllYourBaseTest.m in Sources */,
764
780
  E96993981DF60E1E009EA223 /* TransposeExample.m in Sources */,
781
+ E9FCFED51E983361003080C0 /* PascalsTriangleTest.m in Sources */,
765
782
  E9C1C0291D9DB16B0015E86E /* AcronymExample.m in Sources */,
766
783
  1EFACAA41CCCAF3D006F2E69 /* AnagramTest.m in Sources */,
767
784
  E907FE921D87547D00B93DA9 /* ScrabbleScoreExample.m in Sources */,
@@ -808,6 +825,7 @@
808
825
  E9FDCA1B1D540801004EE8DB /* RomanNumeralsTest.m in Sources */,
809
826
  E9C1C0231D9D993E0015E86E /* SecretHandshakeExample.m in Sources */,
810
827
  1EFACAB71CCCAF3D006F2E69 /* RobotNameExample.m in Sources */,
828
+ E9FCFED31E98333D003080C0 /* PascalsTriangleExample.m in Sources */,
811
829
  1EFACAA51CCCAF3D006F2E69 /* BobExample.m in Sources */,
812
830
  1EFACABB1CCCAF3D006F2E69 /* WordCountExample.m in Sources */,
813
831
  1EFACAB01CCCAF3D006F2E69 /* LeapTest.m in Sources */,
@@ -1,9 +1,20 @@
1
- def on_square(number):
2
- return 2 ** (number - 1)
1
+ def on_square(square):
2
+ check_square_input(square)
3
+ return 2 ** (square - 1)
3
4
 
4
5
 
5
6
  def total_after(square):
7
+ check_square_input(square)
6
8
  return sum(
7
9
  on_square(n + 1) for n
8
10
  in range(square)
9
11
  )
12
+
13
+
14
+ def check_square_input(square):
15
+ if square == 0:
16
+ raise ValueError("Square input of zero is invalid.")
17
+ elif square < 0:
18
+ raise ValueError("Negative square input is invalid.")
19
+ elif square > 64:
20
+ raise ValueError("Square input greater than 64 is invalid.")
@@ -1,6 +1,9 @@
1
1
  import unittest
2
2
 
3
- from grains import on_square, total_after
3
+ from grains import (
4
+ on_square,
5
+ total_after,
6
+ )
4
7
 
5
8
 
6
9
  class GrainsTest(unittest.TestCase):
@@ -32,6 +35,24 @@ class GrainsTest(unittest.TestCase):
32
35
  self.assertEqual(on_square(64), 9223372036854775808)
33
36
  self.assertEqual(total_after(64), 18446744073709551615)
34
37
 
38
+ def test_square_0_raises_exception(self):
39
+ with self.assertRaises(ValueError):
40
+ on_square(0)
41
+ with self.assertRaises(ValueError):
42
+ total_after(0)
43
+
44
+ def test_square_negative_raises_exception(self):
45
+ with self.assertRaises(ValueError):
46
+ on_square(-1)
47
+ with self.assertRaises(ValueError):
48
+ total_after(-1)
49
+
50
+ def test_square_gt_64_raises_exception(self):
51
+ with self.assertRaises(ValueError):
52
+ on_square(65)
53
+ with self.assertRaises(ValueError):
54
+ total_after(65)
55
+
35
56
 
36
57
  if __name__ == '__main__':
37
58
  unittest.main()
@@ -14,12 +14,19 @@ matrix:
14
14
  - ./xswift-test-spm
15
15
  env: JOB=SPM
16
16
  os: osx
17
- osx_image: xcode8.2
17
+ osx_image: xcode8.3
18
18
  - script:
19
19
  - bin/fetch-configlet
20
20
  - bin/configlet .
21
21
  - docker run -v `pwd`:/xswift norionomura/sourcekit:302 bash -c "cd /xswift && ./xswift-test-spm"
22
- env: JOB=Linux
22
+ env: JOB=Linux302
23
+ sudo: required
24
+ services: docker
25
+ - script:
26
+ - bin/fetch-configlet
27
+ - bin/configlet .
28
+ - docker run -v `pwd`:/xswift norionomura/sourcekit:31 bash -c "cd /xswift && ./xswift-test-spm"
29
+ env: JOB=Linux310
23
30
  sudo: required
24
31
  services: docker
25
32