M
mrajanikrishna
Hi friends,
I am generating combinations from a set with different sub sets.
Here is my code. For this example, actually I need to get 56
combinations but I am getting 35 only. Can anybody suggest where I was
wrong?
<script language="javascript">
var st=Array("1","2","3","4","5","6");
var n=0;
n=parseInt(st.length);
for(k=2;k<=parseInt(st.length);++k)
{
document.write("<br>Subset is " + k + "<br>");
for(i=0;i<parseInt(st.length);++i)
{
for(j=i+1;j<parseInt(st.length);++j)
{
if(j<=(n-(k-1)))
{
document.write("(" + st + ",");
for(l=1;l<k;++l)
{
document.write(st[j+(l-1)] + ",");
}
document.write(")<br>");
}
}
}
}
</script>
I am generating combinations from a set with different sub sets.
Here is my code. For this example, actually I need to get 56
combinations but I am getting 35 only. Can anybody suggest where I was
wrong?
<script language="javascript">
var st=Array("1","2","3","4","5","6");
var n=0;
n=parseInt(st.length);
for(k=2;k<=parseInt(st.length);++k)
{
document.write("<br>Subset is " + k + "<br>");
for(i=0;i<parseInt(st.length);++i)
{
for(j=i+1;j<parseInt(st.length);++j)
{
if(j<=(n-(k-1)))
{
document.write("(" + st + ",");
for(l=1;l<k;++l)
{
document.write(st[j+(l-1)] + ",");
}
document.write(")<br>");
}
}
}
}
</script>