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/*"
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
8 changes: 5 additions & 3 deletions src/dragon-curve/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const dragonCurve = n => {
// logic...
};
const invert = st => [...st].map(i => i === '0' ? 1 : 0).reverse().join('');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!


export const dragonCurve = n => n > 1
? dragonCurve(n - 1) + '1' + invert(dragonCurve(n - 1))
: '1';
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 a dragonCurve number', () => {
expect(dragonCurve(1)).toEqual('1');
expect(dragonCurve(2)).toEqual('110');
expect(dragonCurve(3)).toEqual('1101100');
expect(dragonCurve(4)).toEqual('110110011100100');
});
});
4 changes: 3 additions & 1 deletion src/rotate-matrix/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const rotateMatrix = arr => {
// logic...
return arr.length !== 0 && arr.length === arr[0].length
? arr[0].map((elem, i) => arr.map( elem => elem[i]))
: new Error('this is not a square matrix');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const rotateMatrix = arr => {
	return arr.map((_, i) => arr.map(elem => elem[i]))
};

};

14 changes: 12 additions & 2 deletions src/rotate-matrix/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import {rotateMatrix} from './index'
import {rotateMatrix} from './index';

describe('rotateMatrix::', () => {
// need to implement
it('should return a rotated matrix', () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

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]]);
});

it('should throw error if passed not a square or empty matrix', () => {
expect(rotateMatrix([[],[]])).toEqual(new Error('this is not a square matrix'));
expect(rotateMatrix([[1, 2, 3],[1, 2, 3]])).toEqual(new Error('this is not a square matrix'));
});
});