trackler 2.1.0.14 → 2.1.0.15
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/tracks/csharp/exercises/acronym/AcronymTest.cs +2 -2
- data/tracks/ecmascript/config.json +8 -1
- data/tracks/ecmascript/exercises/connect/connect.spec.js +110 -0
- data/tracks/ecmascript/exercises/connect/example.js +68 -0
- data/tracks/ecmascript/exercises/connect/package.json +82 -0
- data/tracks/haskell/exercises/difference-of-squares/package.yaml +1 -1
- data/tracks/haskell/exercises/difference-of-squares/test/Tests.hs +3 -4
- data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +1 -1
- data/tracks/java/exercises/bracket-push/src/test/java/BracketCheckerTest.java +1 -1
- data/tracks/java/exercises/wordy/src/test/java/WordProblemSolverTest.java +1 -1
- data/tracks/lisp/.travis.yml +12 -14
- data/tracks/lisp/README.md +16 -48
- data/tracks/objective-c/config.json +9 -0
- data/tracks/objective-c/exercises/luhn/LuhnExample.h +9 -0
- data/tracks/objective-c/exercises/luhn/LuhnExample.m +50 -0
- data/tracks/objective-c/exercises/luhn/LuhnTest.m +80 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
- data/tracks/php/config.json +397 -382
- data/tracks/php/exercises/binary-search/binary-search_test.php +58 -0
- data/tracks/php/exercises/binary-search/example.php +21 -0
- data/tracks/php/exercises/nth-prime/example.php +19 -0
- data/tracks/php/exercises/nth-prime/nth-prime_test.php +31 -0
- data/tracks/php/exercises/pascals-triangle/example.php +28 -0
- data/tracks/php/exercises/pascals-triangle/pascals-triangle_test.php +42 -0
- data/tracks/python/exercises/difference-of-squares/difference_of_squares_test.py +9 -12
- data/tracks/r/docs/INSTALLATION.md +2 -6
- data/tracks/rust/exercises/difference-of-squares/Cargo.toml +1 -1
- data/tracks/rust/exercises/difference-of-squares/tests/difference-of-square.rs +24 -6
- data/tracks/typescript/config.json +6 -0
- data/tracks/typescript/exercises/raindrops/package.json +36 -0
- data/tracks/typescript/exercises/raindrops/raindrops.example.ts +17 -0
- data/tracks/typescript/exercises/raindrops/raindrops.test.ts +38 -0
- data/tracks/typescript/exercises/raindrops/tsconfig.json +21 -0
- data/tracks/typescript/exercises/raindrops/tslint.json +127 -0
- data/tracks/typescript/exercises/raindrops/yarn.lock +2739 -0
- metadata +20 -3
- data/tracks/lisp/bin/cl-travis-install.sh +0 -325
@@ -0,0 +1,58 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
require_once 'binary-search.php';
|
4
|
+
|
5
|
+
class BinarySearchTest extends PHPUnit\Framework\TestCase
|
6
|
+
{
|
7
|
+
public function testItWorksWithOneElement()
|
8
|
+
{
|
9
|
+
$this->assertEquals(0, find(6, [6]));
|
10
|
+
}
|
11
|
+
|
12
|
+
public function testItFindsValueInMiddle()
|
13
|
+
{
|
14
|
+
$this->markTestSkipped();
|
15
|
+
$this->assertEquals(3, find(6, [1, 3, 4, 6, 8, 9, 11]));
|
16
|
+
}
|
17
|
+
|
18
|
+
public function testItFindsValueInBeginning()
|
19
|
+
{
|
20
|
+
$this->markTestSkipped();
|
21
|
+
$this->assertEquals(0, find(1, [1, 3, 4, 6, 8, 9, 11]));
|
22
|
+
}
|
23
|
+
|
24
|
+
public function testItFindsValueAtEnd()
|
25
|
+
{
|
26
|
+
$this->markTestSkipped();
|
27
|
+
$this->assertEquals(6, find(11, [1, 3, 4, 6, 8, 9, 11]));
|
28
|
+
}
|
29
|
+
|
30
|
+
public function testItFindsValueInOddLengthArray()
|
31
|
+
{
|
32
|
+
$this->markTestSkipped();
|
33
|
+
$this->assertEquals(9, find(144, [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 634]));
|
34
|
+
}
|
35
|
+
|
36
|
+
public function testItFindsValueInEvenLengthArray()
|
37
|
+
{
|
38
|
+
$this->markTestSkipped();
|
39
|
+
$this->assertEquals(5, find(21, [1, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]));
|
40
|
+
}
|
41
|
+
public function testLowerThanLowestValueNotIn()
|
42
|
+
{
|
43
|
+
$this->markTestSkipped();
|
44
|
+
$this->assertEquals(-1, find(0, [1, 3, 4, 6, 8, 9, 11]));
|
45
|
+
}
|
46
|
+
|
47
|
+
public function testLargerThanLargestValueNotIn()
|
48
|
+
{
|
49
|
+
$this->markTestSkipped();
|
50
|
+
$this->assertEquals(-1, find(13, [1, 3, 4, 6, 8, 9, 11]));
|
51
|
+
}
|
52
|
+
|
53
|
+
public function testNothingInEmptyArray()
|
54
|
+
{
|
55
|
+
$this->markTestSkipped();
|
56
|
+
$this->assertEquals(-1, find(1, []));
|
57
|
+
}
|
58
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
function find($needle, $haystack)
|
4
|
+
{
|
5
|
+
$left = 0;
|
6
|
+
$right = count($haystack);
|
7
|
+
while ($left <= $right) {
|
8
|
+
$middle = floor(($left+$right)/2);
|
9
|
+
if (!isset($haystack[$middle])) {
|
10
|
+
return -1;
|
11
|
+
}
|
12
|
+
if ($haystack[$middle] < $needle) {
|
13
|
+
$left = $middle + 1;
|
14
|
+
} elseif ($haystack[$middle] > $needle) {
|
15
|
+
$right = $middle - 1;
|
16
|
+
} elseif ($haystack[$middle] === $needle) {
|
17
|
+
return $middle;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return -1;
|
21
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
function prime($count)
|
3
|
+
{
|
4
|
+
if ($count < 1) {
|
5
|
+
return false;
|
6
|
+
}
|
7
|
+
$primes = [];
|
8
|
+
$i = 2;
|
9
|
+
while (count($primes) < $count) {
|
10
|
+
foreach ($primes as $prime) {
|
11
|
+
if ($i % $prime == 0) {
|
12
|
+
$i++;
|
13
|
+
continue 2;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
$primes[]=$i++;
|
17
|
+
}
|
18
|
+
return end($primes);
|
19
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
require 'nth-prime.php';
|
4
|
+
|
5
|
+
class NthPrimeTest extends PHPUnit\Framework\TestCase
|
6
|
+
{
|
7
|
+
public function testFirstPrime()
|
8
|
+
{
|
9
|
+
$this->assertEquals(2, prime(1));
|
10
|
+
}
|
11
|
+
public function testSecondPrime()
|
12
|
+
{
|
13
|
+
$this->markTestSkipped();
|
14
|
+
$this->assertEquals(3, prime(2));
|
15
|
+
}
|
16
|
+
public function testSixthPrime()
|
17
|
+
{
|
18
|
+
$this->markTestSkipped();
|
19
|
+
$this->assertEquals(13, prime(6));
|
20
|
+
}
|
21
|
+
public function testBigPrime()
|
22
|
+
{
|
23
|
+
$this->markTestSkipped();
|
24
|
+
$this->assertEquals(104743, prime(10001));
|
25
|
+
}
|
26
|
+
public function testZeroPrime()
|
27
|
+
{
|
28
|
+
$this->markTestSkipped();
|
29
|
+
$this->assertEquals(false, prime(0));
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
function pascalsTriangleRows($rowCount)
|
4
|
+
{
|
5
|
+
if ($rowCount < 0 || $rowCount === null) {
|
6
|
+
return -1;
|
7
|
+
}
|
8
|
+
$output = [];
|
9
|
+
if ($rowCount === 0) {
|
10
|
+
return $output;
|
11
|
+
}
|
12
|
+
foreach (range(0, $rowCount-1) as $rowNum) {
|
13
|
+
array_push($output, pascalRow($rowNum));
|
14
|
+
}
|
15
|
+
return $output;
|
16
|
+
}
|
17
|
+
|
18
|
+
function pascalRow($n)
|
19
|
+
{
|
20
|
+
$line = [1];
|
21
|
+
if ($n === 0) {
|
22
|
+
return $line;
|
23
|
+
}
|
24
|
+
foreach (range(0, $n-1) as $k) {
|
25
|
+
array_push($line, $line[$k] * ($n-$k) / ($k+1));
|
26
|
+
}
|
27
|
+
return $line;
|
28
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
require "pascals-triangle.php";
|
4
|
+
|
5
|
+
class PascalsTriangleTest extends PHPUnit\Framework\TestCase
|
6
|
+
{
|
7
|
+
public function testZeroRows()
|
8
|
+
{
|
9
|
+
$this->assertSame([], pascalsTriangleRows(0));
|
10
|
+
}
|
11
|
+
|
12
|
+
public function testSingleRow()
|
13
|
+
{
|
14
|
+
$this->markTestSkipped();
|
15
|
+
$this->assertSame([[1]], pascalsTriangleRows(1));
|
16
|
+
}
|
17
|
+
public function testTwoRows()
|
18
|
+
{
|
19
|
+
$this->markTestSkipped();
|
20
|
+
$this->assertSame([[1], [1, 1]], pascalsTriangleRows(2));
|
21
|
+
}
|
22
|
+
public function testThreeRows()
|
23
|
+
{
|
24
|
+
$this->markTestSkipped();
|
25
|
+
$this->assertSame([[1], [1, 1], [1, 2, 1]], pascalsTriangleRows(3));
|
26
|
+
}
|
27
|
+
public function testFourRows()
|
28
|
+
{
|
29
|
+
$this->markTestSkipped();
|
30
|
+
$this->assertSame([[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]], pascalsTriangleRows(4));
|
31
|
+
}
|
32
|
+
public function testNegativeRows()
|
33
|
+
{
|
34
|
+
$this->markTestSkipped();
|
35
|
+
$this->assertEquals(-1, pascalsTriangleRows(-1));
|
36
|
+
}
|
37
|
+
public function testNullNoRows()
|
38
|
+
{
|
39
|
+
$this->markTestSkipped();
|
40
|
+
$this->assertEquals(-1, pascalsTriangleRows(null));
|
41
|
+
}
|
42
|
+
}
|
@@ -3,36 +3,33 @@ import unittest
|
|
3
3
|
from difference_of_squares import difference, square_of_sum, sum_of_squares
|
4
4
|
|
5
5
|
|
6
|
-
# test cases adapted from `x-common//canonical-data.json` @ version: 1.
|
6
|
+
# test cases adapted from `x-common//canonical-data.json` @ version: 1.1.0
|
7
7
|
|
8
8
|
class DifferenceOfSquaresTest(unittest.TestCase):
|
9
|
+
def test_square_of_sum_1(self):
|
10
|
+
self.assertEqual(square_of_sum(1), 1)
|
11
|
+
|
9
12
|
def test_square_of_sum_5(self):
|
10
13
|
self.assertEqual(square_of_sum(5), 225)
|
11
14
|
|
12
|
-
def test_square_of_sum_10(self):
|
13
|
-
self.assertEqual(square_of_sum(10), 3025)
|
14
|
-
|
15
15
|
def test_square_of_sum_100(self):
|
16
16
|
self.assertEqual(square_of_sum(100), 25502500)
|
17
17
|
|
18
|
+
def test_sum_of_squares_1(self):
|
19
|
+
self.assertEqual(sum_of_squares(1), 1)
|
20
|
+
|
18
21
|
def test_sum_of_squares_5(self):
|
19
22
|
self.assertEqual(sum_of_squares(5), 55)
|
20
23
|
|
21
|
-
def test_sum_of_squares_10(self):
|
22
|
-
self.assertEqual(sum_of_squares(10), 385)
|
23
|
-
|
24
24
|
def test_sum_of_squares_100(self):
|
25
25
|
self.assertEqual(sum_of_squares(100), 338350)
|
26
26
|
|
27
|
-
def
|
28
|
-
self.assertEqual(difference(
|
27
|
+
def test_difference_of_squares_1(self):
|
28
|
+
self.assertEqual(difference(1), 0)
|
29
29
|
|
30
30
|
def test_difference_of_squares_5(self):
|
31
31
|
self.assertEqual(difference(5), 170)
|
32
32
|
|
33
|
-
def test_difference_of_squares_10(self):
|
34
|
-
self.assertEqual(difference(10), 2640)
|
35
|
-
|
36
33
|
def test_difference_of_squares_100(self):
|
37
34
|
self.assertEqual(difference(100), 25164150)
|
38
35
|
|
@@ -1,22 +1,18 @@
|
|
1
1
|
## Install the R runtime
|
2
2
|
Visit the [CRAN homepage](https://cran.r-project.org/). There you will find download links for Linux, Mac OSX, and Windows. Download and run the installer for your operating system.
|
3
3
|
|
4
|
-
If you are using Windows, you may also need to install the [Rtools](https://cran.r-project.org/bin/windows/Rtools/) suite, as some packages may depend on it. Mac users may need to install XCode (particularly its command-line tools) for the same reason.
|
5
|
-
|
6
4
|
## Install the RStudio IDE
|
7
5
|
RStudio is a popular cross-platform integrated development environment (IDE) for programming in R (and also supports other languages like Python, JavaScript, and Markdown). Using RStudio will make writing your code solutions and running tests easier.
|
8
6
|
|
9
7
|
Download and install the [current stable version of RStudio](https://www.rstudio.com/products/rstudio/download/). Or, alternatively, get the [preview version](https://www.rstudio.com/products/rstudio/download/preview/) of an upcoming release.
|
10
8
|
|
11
9
|
## Install the R packages for running tests
|
12
|
-
The test runner for the specs is the [`testthat`](https://github.com/hadley/testthat) library from Hadley Wickham, which is a popular choice for R
|
13
|
-
|
14
|
-
To install these libraries, type the following in your RStudio console (or wherever you are using R).
|
10
|
+
The test runner for the specs is the [`testthat`](https://github.com/hadley/testthat) library from Hadley Wickham, which is a popular choice for R package authors.
|
15
11
|
|
12
|
+
To install this library, type the following in your RStudio console (or wherever you are using R).
|
16
13
|
|
17
14
|
```{R}
|
18
15
|
install.packages("testthat")
|
19
|
-
install.packages("devtools")
|
20
16
|
```
|
21
17
|
|
22
18
|
While it is unlikely that you will _need_ to install packages to solve the exercism problems, you may want to bring in a general-purpose utility packages like [`magrittr`](https://github.com/smbache/magrittr) that suit your programming style. To install and load a package like `magrittr`:
|
@@ -1,26 +1,32 @@
|
|
1
1
|
extern crate difference_of_squares as squares;
|
2
2
|
|
3
3
|
#[test]
|
4
|
+
fn test_square_of_sum_1() {
|
5
|
+
assert_eq!(1, squares::square_of_sum(1));
|
6
|
+
}
|
7
|
+
|
8
|
+
#[test]
|
9
|
+
#[ignore]
|
4
10
|
fn test_square_of_sum_5() {
|
5
11
|
assert_eq!(225, squares::square_of_sum(5));
|
6
12
|
}
|
7
13
|
|
8
14
|
#[test]
|
9
15
|
#[ignore]
|
10
|
-
fn
|
11
|
-
assert_eq!(
|
16
|
+
fn test_square_of_sum_100() {
|
17
|
+
assert_eq!(25502500, squares::square_of_sum(100));
|
12
18
|
}
|
13
19
|
|
14
20
|
#[test]
|
15
21
|
#[ignore]
|
16
|
-
fn
|
17
|
-
assert_eq!(
|
22
|
+
fn test_sum_of_squares_1() {
|
23
|
+
assert_eq!(1, squares::sum_of_squares(1));
|
18
24
|
}
|
19
25
|
|
20
26
|
#[test]
|
21
27
|
#[ignore]
|
22
|
-
fn
|
23
|
-
assert_eq!(
|
28
|
+
fn test_sum_of_squares_5() {
|
29
|
+
assert_eq!(55, squares::sum_of_squares(5));
|
24
30
|
}
|
25
31
|
|
26
32
|
#[test]
|
@@ -29,6 +35,18 @@ fn test_sum_of_squares_100() {
|
|
29
35
|
assert_eq!(338350, squares::sum_of_squares(100));
|
30
36
|
}
|
31
37
|
|
38
|
+
#[test]
|
39
|
+
#[ignore]
|
40
|
+
fn test_difference_1() {
|
41
|
+
assert_eq!(0, squares::difference(1));
|
42
|
+
}
|
43
|
+
|
44
|
+
#[test]
|
45
|
+
#[ignore]
|
46
|
+
fn test_difference_5() {
|
47
|
+
assert_eq!(170, squares::difference(5));
|
48
|
+
}
|
49
|
+
|
32
50
|
#[test]
|
33
51
|
#[ignore]
|
34
52
|
fn test_difference_100() {
|
@@ -0,0 +1,36 @@
|
|
1
|
+
{
|
2
|
+
"name": "xtypescript",
|
3
|
+
"version": "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": "jest --no-cache",
|
14
|
+
"lint": "tslint '*.ts?(x)'; exit 0"
|
15
|
+
},
|
16
|
+
"dependencies": {
|
17
|
+
"@types/jest": "^18.1.1",
|
18
|
+
"@types/node": "^7.0.5",
|
19
|
+
"jest": "^19.0.2",
|
20
|
+
"ts-jest": "^19.0.0",
|
21
|
+
"tslint": "^4.5.1",
|
22
|
+
"typescript": "^2.2.1"
|
23
|
+
},
|
24
|
+
"jest": {
|
25
|
+
"transform": {
|
26
|
+
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
|
27
|
+
},
|
28
|
+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
|
29
|
+
"testResultsProcessor": "<rootDir>/node_modules/ts-jest/coverageprocessor.js",
|
30
|
+
"moduleFileExtensions": [
|
31
|
+
"ts",
|
32
|
+
"tsx",
|
33
|
+
"js"
|
34
|
+
]
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export default class Raindrops {
|
2
|
+
convert(drops: number): string {
|
3
|
+
let converted = ''
|
4
|
+
|
5
|
+
if (drops % 3 === 0) {
|
6
|
+
converted += 'Pling'
|
7
|
+
}
|
8
|
+
if (drops % 5 === 0) {
|
9
|
+
converted += 'Plang'
|
10
|
+
}
|
11
|
+
if (drops % 7 === 0) {
|
12
|
+
converted += 'Plong'
|
13
|
+
}
|
14
|
+
|
15
|
+
return converted ? converted : drops.toString()
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import Raindrops from './raindrops'
|
2
|
+
|
3
|
+
describe('Raindrops', () => {
|
4
|
+
const drops: Raindrops = new Raindrops()
|
5
|
+
|
6
|
+
it('converts 1', () => expect(drops.convert(1)).toEqual('1'))
|
7
|
+
|
8
|
+
xit('converts 3', () => expect(drops.convert(3)).toEqual('Pling'))
|
9
|
+
|
10
|
+
xit('converts 5', () => expect(drops.convert(5)).toEqual('Plang'))
|
11
|
+
|
12
|
+
xit('converts 7', () => expect(drops.convert(7)).toEqual('Plong'))
|
13
|
+
|
14
|
+
xit('converts 6', () => expect(drops.convert(6)).toEqual('Pling'))
|
15
|
+
|
16
|
+
xit('converts 9', () => expect(drops.convert(9)).toEqual('Pling'))
|
17
|
+
|
18
|
+
xit('converts 10', () => expect(drops.convert(10)).toEqual('Plang'))
|
19
|
+
|
20
|
+
xit('converts 14', () => expect(drops.convert(14)).toEqual('Plong'))
|
21
|
+
|
22
|
+
xit('converts 15', () => expect(drops.convert(15)).toEqual('PlingPlang'))
|
23
|
+
|
24
|
+
xit('converts 21', () => expect(drops.convert(21)).toEqual('PlingPlong'))
|
25
|
+
|
26
|
+
xit('converts 25', () => expect(drops.convert(25)).toEqual('Plang'))
|
27
|
+
|
28
|
+
xit('converts 35', () => expect(drops.convert(35)).toEqual('PlangPlong'))
|
29
|
+
|
30
|
+
xit('converts 49', () => expect(drops.convert(49)).toEqual('Plong'))
|
31
|
+
|
32
|
+
xit('converts 52', () => expect(drops.convert(52)).toEqual('52'))
|
33
|
+
|
34
|
+
xit('converts 105', () => expect(drops.convert(105)).toEqual('PlingPlangPlong'))
|
35
|
+
|
36
|
+
xit('converts 12121', () => expect(drops.convert(12121)).toEqual('12121'))
|
37
|
+
|
38
|
+
})
|