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 { readFileSync, writeFileSync } = require('fs'); | |
const input = readFileSync('./input.txt').toString(); | |
function d23b() { | |
let inp = input.split('\n') | |
.map(line => line.trim()) | |
.filter(line => line.length > 0) | |
let isValid = (y,x)=>!(y<0 || y>=inp.length || x<0 || x>=inp[0].length || inp[y][x] === '#'); |
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 leastFactor(n) returns: | |
// * the smallest prime that divides n | |
// * NaN if n is NaN or Infinity | |
// * 0 if n is 0 | |
// * 1 if n=1, n=-1, or n is not an integer | |
leastFactor = function(n) { | |
if (isNaN(n) || !isFinite(n)) return NaN; | |
if (n==0) return 0; | |
if (n%1 || n*n<2) return 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
const executeOperations = (operations, args) => { | |
return operations.reduce((args, method) => { | |
return [method(...args)]; | |
}, args); | |
}; | |
const $ = Symbol('RESULT_ARGUMENT'); | |
function lazify(instance) { | |
const operations = []; |
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 watchProperty(object, key) { | |
let propDescriptor = Object.getOwnPropertyDescriptor(object, key) || { | |
value: undefined, | |
configurable: true, | |
enumerable: true, | |
writable: true | |
}; | |
let value = object[key]; |
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
/** | |
* Focused on the element if condition is True, and blur the focus if condition is False | |
* | |
* Searching focusable element by allowing conditions: | |
* 1. Searching the element by selector from "focusOn" attribute | |
* 2. Searching the element with "autofocus" attribute | |
* 3. Searching the first element who can get cursor | |
* 4. Otherwise set yourself as focusable element | |
*/ |