Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "lts/*"
13,645 changes: 13,645 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
},
"homepage": "https://github.com/front-camp-2018/project-scaffoldings#readme",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^23.6.0",
"babel-preset-env": "^1.7.0",
"css-loader": "^1.0.0",
"eslint": "^5.6.1",
"eslint-plugin-jest": "^21.25.1",
Expand Down
17 changes: 16 additions & 1 deletion src/dragon-curve/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
export const dragonCurve = n => {
// logic...
let initialCode = '1';

if (n > 0) {
for (let i = 1; i < n; i++) {
const changedCode = [...initialCode]
.reverse()
.map(value => value === '1' ? '0' : '1')
.join('');

initialCode = `${initialCode}1${changedCode}`;
}
return parseInt(initialCode, 10);
}
throw new Error('Only positive values allowed');
};


9 changes: 7 additions & 2 deletions src/dragon-curve/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import {dragonCurve} from './index'
import {dragonCurve} from './index';

describe('dragonCurve::', () => {
// need to implement
it('Should return code as "prev code | 1 | reversed prev code with 0 as 1 and 1 as 0"', () => {
expect(dragonCurve(1)).toEqual(1);
expect(dragonCurve(2)).toEqual(110);
expect(dragonCurve(3)).toEqual(1101100);
expect(dragonCurve(4)).toEqual(110110011100100);
});
});
10 changes: 9 additions & 1 deletion src/rotate-matrix/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
export const rotateMatrix = arr => {
// logic...
if (checkMatrix(arr)){
return arr.map((row, i) => row.map((column, j) => arr[j][i]));
}
throw new Error('Not a square matrix');
};

const checkMatrix = arr => {
const firstRow = arr[0];

return arr.every(value => value.length === firstRow.length) && firstRow.length === arr.length;
};
35 changes: 33 additions & 2 deletions src/rotate-matrix/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
import {rotateMatrix} from './index'
import {rotateMatrix} from './index';

describe('rotateMatrix::', () => {
// need to implement
it('Should return new matrix, where column = row', () => {
expect(rotateMatrix([
[1, 2],
[3, 4],
])).toEqual([
[1, 3],
[2, 4],
]);
expect(rotateMatrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
])).toEqual([
[1, 4, 7],
[2, 5, 8],
[3, 6, 9]
]);
expect(rotateMatrix([
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20],
[21, 22, 23, 24, 25],
[26, 27, 28, 29, 30],
[31, 32, 33, 34, 35]
])).toEqual([
[11, 16, 21, 26, 31],
[12, 17, 22, 27, 32],
[13, 18, 23, 28, 33],
[14, 19, 24, 29, 34],
[15, 20, 25, 30, 35]
]);
});
});