This file contains 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 input1 = [1, 2, 5, 3, 4, 7, 8, 6]; | |
const input2 = [2, 5, 1, 3, 4]; | |
const chaos = (arr) => { | |
let operationCount = 0; | |
let isChaos = false; | |
arr.forEach((_, idx) => { | |
const nextReversedIdx = arr.length - idx; | |
const currentReversedIndex = nextReversedIdx - 1; |
This file contains 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 rotLeft = (a, d) => { | |
const rotArr = [...Array(d).keys()]; | |
rotArr.forEach(() => a.push(...a.splice(0, 1))); | |
return a; | |
}; | |
console.log(rotLeft([1, 2, 3, 4, 5], 4)); |
This file contains 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 arr = [ | |
[1, 1, 1, 0, 0, 0], | |
[0, 1, 0, 0, 0, 0], | |
[1, 1, 1, 0, 0, 0], | |
[0, 0, 2, 4, 4, 0], | |
[0, 0, 0, 2, 0, 0], | |
[0, 0, 1, 2, 4, 0], | |
]; | |
const SHIFT_MAX = 3; |
This file contains 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 MyPromise { | |
constructor(fn) { | |
this._promiseChain = []; | |
fn(this._onResolve, this._onReject); | |
} | |
then = (handleSuccess) => { | |
this._promiseChain.push(handleSuccess); |
This file contains 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 fs = require('fs'); | |
const path = require('path'); | |
const data = fs.readFileSync(path.join(__dirname, './input8.txt'), 'utf8'); | |
const arr = data.split('\n').map(item => item.split('')); | |
const treesBoxCount = 16; | |
const trees = [...Array.from(Array(arr.length - 1).keys()).map(() => [])]; |
This file contains 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 fs = require('fs'); | |
// const path = require('path'); | |
// const data = fs.readFileSync(path.join(__dirname, './input4.txt'), 'utf8'); | |
// const rules = fs.readFileSync(path.join(__dirname, './input4_1.txt'), 'utf8'); | |
const input = 'pnnfhnhshrhmhwwmwzmznmnwmwfmfhfjfcjjtgtbggpdgdjjbjrjsjpjrrmddmgmpmddrhddnfnfzfpfvpfpprhhlffmtffqhhdtdcdsswsdwswmmfvvpdprrnnhhhtffnfbbznbznnvdnnbffjrfrbfrbrgbrrntnggrqqwtqwwgjgsswgwqwtwwsvwvbwvwrwlrlppzfzwfzzpmzzhqqzqlzlglzzmrmwrmwwvmwvvnppjfjttlffhjjjsccbggnffqgfgjjnccmdmzmllvnlnznttlvlttvnvgnvvqvmvqqzrqqcgglzzwtztwwmjmzjjnddsffqrqlrrvsvdvldvvlgvlvccdzczcqcpphggtnthhhtbhtttcjtjcjgcjcbbrhbbfrffgjgdgzddcttczzsccbpcpddcpcggmjgjddtcccthccfrccmdmhmddnwddfldffntnptnpttcptcptpfphhmfmwfwmmlblgbgvbvlltqltldttfcfcclgcllmplmlbbjnjzjnzzttnvvgddshddsqddggsqgqddsggdhghjgjhhgchhdmdjmjddgdhghrrphrrpnnqhhjwwqrrcmmslmmszzpgzpzzrmzmznzllnjnnlnbbdvdsdffbpffcmmnznqqcbbzvvjnjvvwqwgqqpnnzwnzwnzwwwlpwpzzfqzfqqwnqnbnfnqnbqqbggqnqdndrrzzlffbbgqgfgrfrqqsddnqnqjjgssqwqwcqcpcrrqppwpjjfnfpffhphwwmcwwznw |
This file contains 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 fs = require('fs'); | |
const path = require('path'); | |
const data = fs.readFileSync(path.join(__dirname, './input4.txt'), 'utf8'); | |
const rules = fs.readFileSync(path.join(__dirname, './input4_1.txt'), 'utf8'); | |
const config = rules.split(/\r?\n/).map(item => item.split(' ')).map(item => ({ | |
from: Number(item[3]), | |
count: Number(item[1]), | |
to: Number(item[5]) | |
})); |
This file contains 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 fs = require('fs'); | |
const path = require('path'); | |
// 2-4,6-8 | |
// 2-3,4-5 | |
// 5-7,7-9 | |
// 2-8,3-7 | |
// 6-6,4-6 | |
// 2-6,4-8 |
This file contains 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 fs = require('fs'); | |
const path = require('path'); | |
// RCMRQjLLWGTjnlnZwwnZJRZH | |
// qnvfhpSbvSppNddNdSqbbmmdPrwttJVrVPDVrJtHtwPZhrPJ | |
// BFpFzSSqSFFSvQsnWgCMjTLzng | |
// DbWVcVRRdlLffvtqjTWNgQ | |
// mJJMpsmrMrJSHJpsHrFHvBvgHvqfNvzffgTvfj | |
// mMhPjmjmFPJhMSGGcDRlwRdcLGPc |
This file contains 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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Unit + UI Testing | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] |
NewerOlder