我有一个25个字符的代码,我知道一些字符,但我遗漏了剩下的字符。到目前为止,我有以下代码来帮助解决丢失的代码选项:
function combinations(w) {
var x = new Array(
"B","C","D","F","G","H","J","K",
"M","P","Q","R","T","V",
"W","X","Y","Z",2,3,4,6,7,8,9
),
n = w.match(/\!/g).length,
x_n = new Array(),
r = new Array(),
c = null;
for (var i = n; i > 0; i--) {
x_n.push(x);
}
c = x_n.reduce(function(a, b) {
var c = [];
a.forEach(function(a) {
b.forEach(function(b) {
c.push(a.concat([b]));
});
});
return c;
}, [[]]);
for (var i = 0, j = 0; i < c.length; i++, j = 0) {
r.push(w.replace(/\!/g, function(s, k) {
return c[i][j++];
}));
}
return r;}
console.log(combinations("6X3#!-#!KHY-BgVDT-W!WDV-H6HJR"))
对于25个字符的代码&#34; 7X3 !! - #!KHY-BKVDT-W!QDV-H6HFR&#34;这段代码可以很好地列出所有空格的所有可能结果,使用&#34;!&#34;。
我想进一步改进我的结果。我试图找出如何使用&#34;!&#34;从一组可能性中进行选择,并使用&#34;#&#34;从不同的可能性中选择,并最终得到所有可能结果的列表。
第二组可能性如下:
var p = new Array(
"B","D",
"P","R",
2,8)