javascript - Generating all possible binary combinations in words ('true' 'false') performance -


I see the performance improvement of the script below. I am pretty sure that it can be modified to a great extent, I did it because it was the first thing that came to my head and it is only for the performance which I am seeing.

  function pad Nn, width, z) {z = z || '0'; Nn = nn + ''; Return nn.length & gt; = Width? Nn: new array (width - nn.length + 1) .join (z) + nn; } Var makeIntoBinary = function (ii, length) {return pad (ii.toString (2), length); } Make makeIntoTrueFalse = function (binary) {var str = ''; (Iii = 0; iii & lt; binary.length; iii ++) for (if (binary [iii] == '0') {str + = 'false';} Else {str + = 'true'; }}; Console.log (str + "+ + binary);} Var runner = function {n} {var iter = Math.pow (2, n); for (i = 0; i ; iter; i ++) {makeIntoTrueFalse (MTN)}}}  

I want to generate a set of words for all possible combinations which are basically binary above (< Code> Runner (2); false false , false true , true false , will generate true true ) I'm seeing fast algorithms of electricity Which takes me to this point.

Try to manipulate without bit string conversion, Directly.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -