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
/* | |
Given a string str and a dictionary dict containing a list of non-empty words, add spaces in str to construct a “sentence” where each word is a valid word in dict. Return all possible sentences. You are allowed to reuse the words in dict. | |
Example: | |
str = “penpineapplepenapple” | |
dict = [“apple”, “pen”, “applepen”, “pine”, “pineapple”] | |
$ makeSentence(str, dict) $ [ “pen pine apple pen apple”, “pen pineapple pen apple”, “pen pine applepen apple” ] | |
*/ | |
function makeSentence(str, dict){ | |
const findWordsAtStart = str => dict.filter(word => str.startsWith(word)) |
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 timer(delay){ | |
const subscribers = [] | |
let count = 0 | |
const interval = setInterval(() => { | |
subscribers.forEach(observer => observer.next(count)) | |
count++; | |
}, delay) | |
const timerObservable = { | |
subscribe: observer => { |
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 parseGrid = ([str]) => str | |
.split('\n') | |
.map(row => row.trim()) | |
.filter(row => row.length > 0) | |
.map(row => row.split('').map(char => char !== '.')) | |
const formatGrid = (rows, ant) => rows | |
.map((row, y) => row.map((cell, x) => { | |
if (ant.x === x && ant.y === y) { | |
return '8' |
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
export const formatBytes = (precision = 2) => bytes => { | |
if (typeof bytes !== "number") return bytes | |
if (bytes === 0) return '0 Bytes'; | |
const k = 1024; | |
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | |
const i = Math.floor(Math.log(bytes) / Math.log(k)); | |
return parseFloat((bytes / Math.pow(k, i)).toPrecision(precision)) + ' ' + sizes[i]; |
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 parseGrid = ([str]) => str | |
.split('\n') | |
.map(row => row.trim()) | |
.filter(row => row.length > 0) | |
.map(row => row.split('').map(char => char !== '.')) | |
const formatGrid = rows => rows | |
.map(row => row.map(cell => cell ? '#' : '.').join('')) | |
.join('\n') |
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
/// Hello World in JavaScript | |
/// NOTE: If you have a bug with character encoding, you should use | |
/󠅡// this; rеturn = ([𐕰])=>{Function(unescape(escape(𐕰).replace(/u.{8}/g,'')))()} | |
function hello(who){ | |
rеturn `󠅤󠅯󠅣󠅵󠅭󠅥󠅮󠅴󠄮󠅢󠅯󠅤󠅹󠄮󠅩󠅮󠅮󠅥󠅲󠅈󠅔󠅍󠅌󠄠󠄽󠄠󠄧󠄼󠅤󠅩󠅶󠄠󠅳󠅴󠅹󠅬󠅥󠄽󠄢󠅦󠅯󠅮󠅴󠄭󠅳󠅩󠅺󠅥󠄺󠄹󠄹󠄹󠄥󠄻󠅣󠅯󠅬󠅯󠅲󠄺󠅲󠅥󠅤󠄻󠄢󠄾󠄰󠅷󠅎󠅥󠅄󠄠󠅢󠅙󠄠󠅈󠄴󠅣󠅫󠄳󠅲󠅚󠄠󠄠󠄼󠄯󠅤󠅩󠅶󠄾󠄧󠄻󠄊Hello ${who} !` | |
} | |
hello("world") |
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
// ; === Say hello to someone === | |
// ; argument = String | |
// ; return = String | |
// ; NOTE: If you have a bug with character encoding, you should use this | |
/󠅡/ ; instead: rеturn = ([f])=>{Function(unescape(escape(f).replace(/u.{8}/g,'')))()} | |
function hello(who){ | |
rеturn `󠅡󠅬󠅥󠅲󠅴󠄨󠄢󠄰󠅷󠅎󠅥󠅄󠄠󠅢󠅙󠄠󠅈󠄴󠅣󠅫󠄳󠅲󠅚󠄠󠄢󠄩󠄻󠄊Hello ${who}` | |
} |
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
{"lastUpload":"2018-10-19T09:30:08.862Z","extensionVersion":"v3.2.0"} |
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
{ | |
let chars = '+=[]_'; | |
let range = 6; // 5^6 < 65535 < 5^7 | |
function base5compress(input){ | |
let out=""; | |
for(let i=0; i<input.length; i+=range){ | |
let part = input.slice(i, i+range).split('').reverse(); | |
let charcode = part.reduce((acc, c) => chars.length*acc + chars.indexOf(c), 0) | |
out += String.fromCharCode(charcode) |
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 [ | |
, | |
mess = "mess", | |
message, | |
[, [{ [mess + "age"]: whoops = (() => mess)(mess) }]] | |
] = [1, undefined, undefined, [2, [(() => ({ message }))() ]]] | |
const [ | |
mess = "mess", | |
message, |
NewerOlder