Skip to content

Commit ef445fb

Browse files
committed
added solutions
1 parent 69f0404 commit ef445fb

File tree

360 files changed

+9396
-3961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+9396
-3961
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
#Jupyter Notebook checkpoints
88
.ipynb_checkpoints
99
package-lock.json
10+
node_modules

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"arrowParens": "avoid",
3+
"singleQuote": false,
4+
"semi": true,
5+
"printWidth": 120,
6+
"useTabs": false,
7+
"tabWidth": 4
8+
}
Lines changed: 1 addition & 1 deletion

BFE.dev/1. implement curry().js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param { (...args: any[]) => any } fn
3+
* @returns { (...args: any[]) => any }
4+
*/
5+
function curry(fn) {
6+
return function curried(...args) {
7+
if (args.length >= fn.length) {
8+
return fn(...args);
9+
}
10+
11+
return (...rest) => curried(...args, ...rest);
12+
};
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param { (...args: any[]) => any } fn
3+
* @returns { (...args: any[]) => any }
4+
*/
5+
function curry(fn) {
6+
return function curried(...args) {
7+
const filteredArgs = args.slice(0, fn.length).filter(item => item !== curry.placeholder);
8+
if (filteredArgs.length >= fn.length) {
9+
return fn(...filteredArgs);
10+
}
11+
12+
return (...rest) => {
13+
const updatedArgs = args.map(item => (item === curry.placeholder && rest.length ? rest.shift() : item));
14+
return curried(...updatedArgs, ...rest);
15+
};
16+
};
17+
}
18+
19+
curry.placeholder = Symbol();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param { Array } arr
3+
* @param { number } depth
4+
* @returns { Array }
5+
*/
6+
function flat(arr, depth = 1) {
7+
return arr.reduce((acc, item) => {
8+
if (depth && Array.isArray(item)) {
9+
return [...acc, ...flat(item, depth - 1)];
10+
}
11+
return [...acc, item];
12+
}, []);
13+
}

Codeforces/Codeforces Global Round 7/A Bad Ugly Numbers.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ const rl = readline.createInterface(process.stdin, process.stdout);
44
let lineNo = 0;
55
let testCases;
66

7-
const parseProblem = (line) => {
8-
if (lineNo === 0 ) {
9-
testCases = parseInt(line)
7+
const parseProblem = line => {
8+
if (lineNo === 0) {
9+
testCases = parseInt(line);
1010
}
1111
lineNo++;
1212
};
1313

14-
rl.on('line', function (line) {
14+
rl.on("line", function (line) {
1515
// console.log('Line number: ' + line);
1616
if (lineNo === 0) {
17-
1817
}
19-
});
18+
});

Daily Coding Problem/00001/README.md

Lines changed: 1 addition & 1 deletion
Lines changed: 1 addition & 0 deletions

Daily Coding Problem/00005/README.md

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)