i am coding quine mcclusky algoritm in javascript. i took inputs as decimal values for example 0,2,6,7. i can have varialbles from 1 to 5 in my code, 1 being a or a' and 5 being a,b,c,d,e. in my code i converted the inputs to binary values. for example for 0,2,6,7 i have an array with binary equivalent ["000","010","110","111"]. i made another logic for counting 1's. i take every elemnt of binary array and count number of 1's and save them in an object in the following way:

{0:"000",1:"010",2:"110",3:"111"}

this might not be very difficult but if i have the input 0,2,4,3,5 and i run a loop such that:

function onesgrp(str)
{

var tmp= str.split(""); //splits the string for example "010" into [0 1 0]
for(i=0;i<len.str;i++)
{
if(tmp[i]==1)

index++;

else 
continue;

}
}
this function will tell how many ones each string have and index value will represent the no. of ones.

now i want to insert this string into 'index' position in object. if index=2, i want to insert the array into index 2 and so on. then if i have another string with'index'=2 i want to add it in obj position 2 such that i donot overwrite the previous string. at the end i have an obj with each index having the strings with 'index' number of 1's. but the problem is i have different length variables.

can anyone tell me a way to do this, i found some javascript versions of quine mcclusky algorithm, but i find them too hard to understand what is going on, since i am a beginner and not very comfortable with advanced javascript.. does anyone know a simpler code for logic minimization using quine mccluskey. i would be really obliged.

another description of my question:

i am coding quine mcclusky algorithm in javascript. i am trying a write a code such that i have an array of binary strings, for each element of the array, i count the number of 1's in the string.i can have variable length strings max upto 5,but for every input all strings in the array will be of same length, and for each input i want to group the strings by "no. of 1's" in an object. for exmple, i have a binary sring 0001, it has one '1' in it. this string would be saved at index 1 in object. second, then i have another string 0010 this should also be added to index 1, but it shud not overwrite the previous string saved, then i have for example 1010 it would go to index 2 in object. after i assign all the strings of array to object with each index of object shows the number of '1s' in the strings at that key position. then, i want to compare obj[0] elements with other key positions and if the elements differ in only one position, example 0000 and 0001 differ by one bit position, i want to save 000- in another obj, following the above method until i find all the prime implicants.

share|improve this question
I've tried to understand what question you're asking and not been able to figure it out. Perhaps you could take another shot at describing the particular question you want help with. – jfriend00 Apr 25 '12 at 2:16
hi jfriend00, i edit my post, plz see at the bottom of the post – user1325120 Apr 25 '12 at 2:47
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.