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
| // TAKES A 2D ARRAY OF LETTERS AND COMPRESSES TO STRING | |
| // for example ... | |
| // compressGrid([ | |
| // ['A','A','A','B','B'], | |
| // ['B','A','B','B','B'], | |
| // ['B','A','B','B','B'], | |
| // ['B','A','B','B','B'], | |
| // ]) | |
| // becomes... | |
| // 'A2B1,BAB2,2' |
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 createCursor = (directions, onMove) => { | |
| const dirKeys = Object.keys(directions); | |
| const cursor = {}; | |
| let location = 0; | |
| cursor.max = 1000; | |
| cursor.get = () => location; |
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 diff = (a, b) => Math.abs(a - b); | |
| const removeSelf = (items, self) => (id) => items[id] !== items[self]; | |
| const makeComparator = (items, target) => (a, b) => | |
| diff(items[target], items[b]) - diff(items[target], items[a]); | |
| const getStableMatches = (items) => { | |
| const matches = []; | |
| const available = [...items.keys()]; | |
| const preferences = available.map(id => | |
| available.filter(removeSelf(items, id)).sort(makeComparator(items, id))); |
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
| typography.inject(typePallette) | |
| color.inject(colorPallette) | |
| <TypographyStyles/> | |
| // <Style> | |
| // .heading1 { | |
| // ... | |
| // } |
NewerOlder