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"]
}
13,417 changes: 13,417 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@
"bugs": {
"url": "https://github.com/front-camp-2018/project-scaffoldings/issues"
},
"jest": {
"transform": {
"^.+\\.js$": "babel-jest"
}
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!@myorg/.*)",
"<rootDir>\\node_modules\\(?!@myorg\\.*)"
],
"homepage": "https://github.com/front-camp-2018/project-scaffoldings#readme",
"devDependencies": {
"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 All @@ -38,5 +49,8 @@
"webpack": "^4.22.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9"
},
"dependencies": {
"jest-transform-stub": "^1.0.0"
}
}
47 changes: 46 additions & 1 deletion src/dragon-curve/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
/* eslint-disable-next-line */
export const dragonCurve = n => {
// logic...
const turnRight = 0;
const turnLeft = 1;
let dragon = [];

if (n === 1) {
dragon.push(turnLeft);
}

if (n === 2) {
dragon.push(turnLeft);

dragon.push(turnLeft);
if ( dragon[0] === turnLeft ) {
dragon.push(turnRight);
}
}

if (n > 2) {
dragon.push(turnLeft);

dragon.push(turnLeft);
if ( dragon[0] === turnLeft ) {
dragon.push(turnRight);
}

for ( let j = 3; j < n + 1; j++ ) {
const tempDragon = reverseDrag(dragon);
dragon.push(turnLeft);
dragon = [...dragon, ...tempDragon];
}
}

return dragon;
};

const reverseDrag = arr => {
const tempArr = arr.slice(0);

tempArr.reverse();
tempArr.forEach((el,i) => {
tempArr[i] = 1 - tempArr[i];
});

return tempArr;
};

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

describe('dragonCurve::', () => {
// need to implement
it('Should convert normal number into dragon-number', () => {
expect(dragonCurve(1)).toEqual([1]);
expect(dragonCurve(2)).toEqual([1,1,0]);
expect(dragonCurve(3)).toEqual([1,1,0,1,1,0,0]);
});
});
10 changes: 8 additions & 2 deletions src/rotate-matrix/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint-disable-next-line */
export const rotateMatrix = arr => {
// logic...
};
const firstRowKeys = Object.keys(arr[0]);

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.

ця дія непотрібна!


return firstRowKeys.map( colEl => {

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!

return arr.map( rowEl => {
return rowEl[colEl];
});
});
};
28 changes: 26 additions & 2 deletions src/rotate-matrix/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
import {rotateMatrix} from './index'
import {rotateMatrix} from './index';

describe('rotateMatrix::', () => {
// need to implement
it('Should rearrange rows and columns', () => {
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]
]);
});
});
2 changes: 1 addition & 1 deletion webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
{
loader: 'css-loader', // translates CSS into CommonJS
query: {
modules: false,
modules: true,
camelCase: true,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
Expand Down