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
/** | |
* production code | |
*/ | |
const flatten = arr => safeArray(arr).reduce(flatReducer, []); | |
const safeArray = arr => Array.isArray(arr) ? arr : []; | |
const flatReducer = (res, elem) => { | |
if (Array.isArray(elem)) { |
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
/** | |
* production code | |
*/ | |
const _countOccurrences = charMap => { | |
let occ = 0; | |
for (let char in charMap) { | |
if (charMap[char] >= 2) { | |
occ++; | |
} |
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
/** | |
* production code | |
*/ | |
const backFromWalkInTime = (steps) => { | |
const stepsUp = steps.filter((step) => step === "n").length; | |
const stepsDown = steps.filter((step) => step === "s").length; | |
const stepsLeft = steps.filter((step) => step === "e").length; | |
const stepsRight = steps.filter((step) => step === "w").length; |
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
// abstract class, not intended to be instantiated directly | |
class CalendarItem { | |
static #UNSET = Symbol("unset") | |
static #isUnset(v) { | |
return v === this.#UNSET; | |
} | |
static { | |
for (let [idx,msg] of [ | |
"ID is already set.", | |
"ID is unset.", |