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
### Keybase proof | |
I hereby claim: | |
* I am theqabalist on github. | |
* I am lambdajoshu (https://keybase.io/lambdajoshu) on keybase. | |
* I have a public key ASCr5JIspD70Y_esZTPoG1f_JE8Ccfv6ukGjlWC8hGiLCgo | |
To claim this, I am signing this object: |
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
/*eslint no-confusing-arrow: off*/ | |
const scaffold = require('./scaffold'); | |
const {pipe, set, curry, over, lensProp, inc, repeat, dec, head, tail} = require('ramda'); | |
const {inspect} = require('util'); | |
const {usleep} = require('sleep'); | |
const initMachine = curry((a, instructions) => ({ | |
pc: 8, | |
registers: { | |
a, |
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
/*eslint no-confusing-arrow: off, no-unused-vars: off*/ | |
const {Set, Map, Record} = require('immutable'); | |
const {pipe, range, xprod, head, isEmpty, over, lensProp, aperture, memoize, concat, splitEvery, sortBy, zipWith, add, equals, chain, __, prop, tail, curry, flip, curryN, filter, map, invoker, addIndex, reduce} = require('ramda'); | |
const reduceIndexed = addIndex(reduce); | |
const toInt = flip(curryN(2, parseInt))(10); | |
const pairs = pipe( | |
range(0), | |
r => xprod(r, r), | |
filter(([x, y]) => x !== y), |
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
/*eslint no-confusing-arrow: off*/ | |
const scaffold = require('./scaffold'); | |
const {pipe, set, curry, join, reduce, and, prop, map, split, lensIndex, __, over, lensProp, inc, dec, head, tail} = require('ramda'); | |
const {sleep} = require('sleep'); | |
const initMachine = curry((a, instructions) => ({ | |
pc: 0, | |
registers: { | |
a, | |
b: 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
const scaffold = require('./scaffold'); | |
const {pipe, tail, range, reduce, find, map, curry, assoc, filter, prop, tap, lte, chain, length} = require('ramda'); | |
const {inspect} = require('util'); | |
const parseLine = line => map(x => parseInt(x, 10), tail(line.match(/\/dev\/grid\/node-x(\d+)-y(\d+)\s+(\d+)T\s+(\d+)T\s+(\d+)T\s+(\d+)%/))); | |
const astify = ([x, y, size, used, avail, perc]) => ({x, y, size, used, avail, perc}); | |
const adjacency = curry((nodes, node) => assoc('adj', node.used === 0 ? [] : filter(n2 => n2.avail >= node.used, nodes), node)); | |
const classifyNode = ([width, column], [height, row], node) => | |
row === 0 && column === width - 1 ? 'G' : |
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 scaffold = require('./scaffold'); | |
const {curry, indexOf, map, min, prop, last, join, equals, max, head, isEmpty, flatten, range, tail, pipe, filter, identity, reduce} = require('ramda'); | |
const assert = require('assert'); | |
const sliceAround = (i, arr) => arr.slice(0, i).concat(arr.slice(i + 1)); | |
//eslint-disable-next-line | |
const perms = arr => arr.length === 1 ? arr : map(flatten, reduce((ps, i) => { | |
const branch = arr[i]; | |
const smaller = sliceAround(i, arr); | |
const subs = map(x => [branch, x], perms(smaller)); |
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 scaffold = require('./scaffold'); | |
const {map, last, curry, head, all, inc, isEmpty, pipe, sortBy, prop, reduce, partition} = require('ramda'); | |
const parseLine = line => { | |
const [match, min, max] = line.match(/(\d+)-(\d+)/).map(x => parseInt(x, 10)); | |
return {min, max}; | |
}; | |
const deepenConsolidation = curry((consolidated, ranges) => { | |
if (all(min => min > consolidated.max + 1, map(prop('min'), ranges))) { |
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 scaffold = require('./scaffold'); | |
const {subtract} = require('ramda'); | |
const {Range: infRange, Repeat: repeater} = require('immutable'); | |
/* canonical, semantic solution */ | |
// const filterIndexed = addIndex(filter); | |
// const removeVictim = curry(([id], l) => filter(([xid]) => xid !== id, l)); | |
// const steal = ([x, xn], [y, yn]) => [x, xn + yn]; | |
// | |
// const rotationReduction = curry((targeter, list) => { |
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
/*eslint no-confusing-arrow: off*/ | |
module.exports = (function ({curry, call, complement, identity, tap, invoker, pipe, init, map, filter, reduce, is, not, compose, lte, equals, head, last, fromPairs}) { | |
const iterate = curry((f, base) => () => [base, iterate(f, f(base))]); | |
const coreq = { | |
head: pipe(call, head), | |
tail: pipe(call, last), | |
map: curry((f, iter) => () => [f(coreq.head(iter)), coreq.map(f, coreq.tail(iter))]), | |
filter: curry((pred, iter) => { | |
const h = coreq.head(iter); | |
return pred(h) ? |
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 scaffold = require('./scaffold'); | |
const md5 = require('md5'); | |
const {pipe, map, head, filter, prop, toPairs, curry, find, concat, equals, complement, chain, take, reduce, zipWith, add, all} = require('ramda'); | |
const moves = {U: [0, 1], D: [0, -1], L: [1, 0], R: [-1, 0]}; | |
const actualPosition = pipe( | |
map(x => moves[x]), | |
reduce(zipWith(add), [3, 3]) | |
); | |
const inBounds = dim => dim >= 0 && dim <= 3; |
NewerOlder