Skip to content

Instantly share code, notes, and snippets.

@shu1
Last active January 24, 2021 07:15
Show Gist options
  • Save shu1/bb0acf14107bb783861df694b2acb010 to your computer and use it in GitHub Desktop.
Save shu1/bb0acf14107bb783861df694b2acb010 to your computer and use it in GitHub Desktop.
foobar
/*bug-in-github-api-content-can-not-be-empty*/
/*bug-in-github-api-content-can-not-be-empty*/
var output = "endrtednedd:/os....cp.rnnn.rhhps/.tt$sfeaiaaofd.ow.otooapa.asu./thhse";
var col = output.split('');
col.sort();
col.push(col.shift());
var table = output.split('');
for (var i = table.length-1; i >= 0; --i) {
table[i] += col[i];
}
var used = Array(table.length);
for (var i=1; i < output.length-1; ++i) {
used.fill(false);
for (var j=0; j < table.length; ++j) {
table[j] += nextChar(j, i);
}
}
console.log(table);
function nextChar(index, width) {
for (var i=0; i < table.length; ++i) {
match:
if (!used[i]) {
for (var j=0; j < width; ++j) {
if (table[i][j] != table[index][j+1]) {
break match;
}
}
used[i] = true;
return table[i][width];
}
}
}
{"name":"foobar","settings":{},"filenames":["index.html","index.css","index.js"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment