create 1000 txt file.
calc 10 times runtime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const crypto = require('crypto'); | |
function createMD5(filePath) { | |
return new Promise((res, rej) => { | |
const hash = crypto.createHash('md5'); | |
const rStream = fs.createReadStream(filePath); | |
rStream.on('data', (data) => { | |
hash.update(data); | |
}); |
Stack I used https://github.com/bishil06/data_structure/blob/main/src/stack/Stack.js
- convert infix notation to postfix notation
- operator push stack
- calculate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *zip(iter1, iter2) { | |
const a = iter1[Symbol.iterator](); | |
const b = iter2[Symbol.iterator](); | |
let va = null; | |
let vb = null; | |
while (!((va = a.next()).done) && !((vb = b.next()).done)) { | |
yield [va.value, vb.value]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *enumerate(init=0, iter) { | |
if (init[Symbol.iterator]) { | |
iter = init[Symbol.iterator](); | |
init = 0; | |
} | |
let count = init; | |
for(const a of iter) { | |
yield [count, a]; | |
count += 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function *range(start=0, stop, step=1) { | |
while(start < stop) { | |
yield start; | |
start+=step; | |
} | |
} | |
console.log(...range(0, 5)); // 0 1 2 3 4 | |
console.log(...range(0, 10, 2)); // 0 2 4 6 8 | |
console.log(...range(1, 20, 3)); // 1 4 7 10 13 16 19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack{ | |
constructor() { | |
this.list = []; | |
this.top = null; | |
} | |
push(v) { | |
this.list.push(v); | |
this.top = v; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Queue { | |
constructor() { | |
this.list = []; | |
this.first = null; | |
} | |
enqueue(v) { | |
if (this.first === null) { | |
this.first = v; | |
} |
OlderNewer