Skip to content

Instantly share code, notes, and snippets.

View codermapuche's full-sized avatar

Nehuen Prados codermapuche

View GitHub Profile
"use strict";
// ----------------------------------------------------------------------------
const fs = require('fs');
// ----------------------------------------------------------------------------
const INPUT = 'palabrasRI.txt',
CRLF = '\n';
@codermapuche
codermapuche / resolver26.js
Created July 31, 2019 19:30
Encuentra las 72 soluciones al puzzle 26 en menos de 20 segundos. (https://www.youtube.com/watch?v=GsxzGqARjtw)
function permutar(items, cb) {
var length = items.length,
c = new Array(length).fill(0),
i = 1, k, p, t = 0;
cb(items, ++t);
while (i < length) {
if (c[i] < i) {
k = i % 2 && c[i];
p = items[i];
function safe64(data) {
if ( !Buffer.isBuffer(data) ) {
if (typeof data !== 'string') {
data = Buffer.from(JSON.stringify(data)).toString('base64');
}
} else {
data = data.toString('base64');
}
return data.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');