Skip to content

Commit

Permalink
Merge remote-tracking branch 'AB/master'
Browse files Browse the repository at this point in the history
add A new solution for a new condition
  • Loading branch information
AV-Shell committed Nov 1, 2020
2 parents 9c49ef4 + bdd0828 commit a7bcb76
Show file tree
Hide file tree
Showing 18 changed files with 1,197 additions and 528 deletions.
537 changes: 298 additions & 239 deletions README.md

Large diffs are not rendered by default.

299 changes: 299 additions & 0 deletions README_RU.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions extensions/custom-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const CustomError = class CustomError extends Error {
constructor(message) {
super(message);
this._validationProp = 'NA';
}
};

module.exports = CustomError;
8 changes: 3 additions & 5 deletions extensions/it-optional.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// code from https://github.com/mikhama/core-js-101
// code is based on solution from https://github.com/mikhama/core-js-101
function testOptional(title, fn, isAsyncTest) {
if (isAsyncTest) {
it(title, function test(done) {
try {
fn.call(this, done);
} catch (err) {
if (err === 'Not implemented') {
console.log('NOT IMPLEMENTED' + title);
if (err._validationProp === 'NA') {
this.test.skip();
} else {
console.log('ERR UP' + title);
throw err;
}
}
Expand All @@ -19,7 +17,7 @@ function testOptional(title, fn, isAsyncTest) {
try {
fn.call(this);
} catch (err) {
if (err === 'Not implemented') {
if (err._validationProp === 'NA') {
this.test.skip();
} else {
throw err;
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/dream-team.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const CONSOLE_LOG_ENABLE = false;

module.exports = function createDreamTeam(members_array/* members */) {
if (!(Array.isArray(members_array))){
if (CONSOLE_LOG_ENABLE) console.log ((Array.isArray(members_array)));
if (!(Array.isArray(members_array))) {
if (CONSOLE_LOG_ENABLE) console.log((Array.isArray(members_array)));
return false;
}

let team = '';

for (let i = 0; i<members_array.length; i++) {
if (typeof( members_array[i] ) === "string"){
team += members_array[i].match(/\w/);
for (let i = 0; i < members_array.length; i++) {
if (typeof (members_array[i]) === "string") {
team += members_array[i].match(/\w/);
}
}

if (CONSOLE_LOG_ENABLE) console.log(team);
if (CONSOLE_LOG_ENABLE) console.log(team);
team = team.toUpperCase().split("").sort().join("");
if (CONSOLE_LOG_ENABLE) console.log(team);
if (CONSOLE_LOG_ENABLE) console.log(team);

if (team === "") {
return false;
}
return team;
// throw 'Not implemented';
// // remove line with error and write your code here
};
};
1 change: 0 additions & 1 deletion src/extended-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ module.exports = function repeater(str, options) {
outstring = outstring + str + add_str;
} while (i < repeatTimes);
return outstring;
throw 'Not implemented';
// remove line with error and write your code here
};
6 changes: 4 additions & 2 deletions src/hanoi-tower.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = function calculateHanoi( disksNumber, turnsSpeed ) {
for(let i=1; i<=disksNumber;i++){
obj.turns = obj.turns*2 +1;
}
obj.seconds = obj.turns/ (turnsSpeed/ 3600);
// console.log('myseconds',obj.turns * 3600 / turnsSpeed);
obj.seconds = Math.floor(obj.turns * 3600 / turnsSpeed);
// console.log('myseconds',obj.seconds);
return obj;
}
}
2 changes: 2 additions & 0 deletions src/recursive-depth.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const CustomError = require("../extensions/custom-error");

module.exports = class DepthCalculator {
calculateDepth(arr) {
// console.log (arr)
Expand Down
50 changes: 45 additions & 5 deletions src/transform-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function transform(inc_arr) {
}
if (SHOW_CONSOLE_LOG) console.log('start program');
if (SHOW_CONSOLE_LOG) console.log('array length', inc_arr.length, 'array:', inc_arr);

/* Я так понимаю задачу упростили, плак плак плак плак ...
for (let i = 0; i < inc_arr.length; i++) {
if (inc_arr[i] in CONTROLS) {
Expand Down Expand Up @@ -61,11 +61,51 @@ module.exports = function transform(inc_arr) {
}
}
}



if (SHOW_CONSOLE_LOG) console.log('array length', inc_arr.length, 'array:', inc_arr);
if (SHOW_CONSOLE_LOG) console.log('end program');
return inc_arr;
*/

let myArr = inc_arr.slice();
for (let i = 0; i < myArr.length; i++) {
if (myArr[i] in CONTROLS) {
switch (myArr[i]) {
case '--double-prev':
if (i > 0) {
myArr[i] = myArr[i-1];
} else {
myArr[i] = null;
}
break;
case '--double-next':
if ((i+1) < inc_arr.length) {
myArr[i] = myArr[i+1];
} else {
myArr[i] = null;
}
break;
case '--discard-prev':
if (i > 0) {
myArr[i] = null;
myArr[i-1] = null;
} else {
myArr[i] = null;
}
break;
case '--discard-next':
if (i < (inc_arr.length - 1)) {
myArr[i] = null;
myArr[i+1] = null;
} else {
myArr[i] = null;
}
i++;
break;
}
}
}
myArr = myArr.filter((el) => el !== null);
if (SHOW_CONSOLE_LOG) console.log('array length', myArr.length, 'array:', myArr);
if (SHOW_CONSOLE_LOG) console.log('end program');
return myArr;
// remove line with error and write your code here
};
Loading

0 comments on commit a7bcb76

Please sign in to comment.