update everything

This commit is contained in:
2024-09-23 01:27:01 +02:00
parent 4a6378dab0
commit 27f87cefda
10 changed files with 710 additions and 469 deletions

View File

@@ -28,15 +28,20 @@ public class BitWise
if (numberOfElementToSelect>totalNumberOfElement)
{
return result;
}
if(numberOfElementToSelect == 0)
{
result.Add(0);
return result;
}
long v = (1L << numberOfElementToSelect) - 1;
long v = (1L << numberOfElementToSelect) - 1L;
long end = 1L << totalNumberOfElement;
while (v < end)
{
result.Add(v);
long t = (v | (v - 1)) + 1;
v = t | ((((t & -t) / (v & -v)) >> 1) - 1);
long t = (v | (v - 1L)) + 1L;
v = t | ((((t & -t) / (v & -v)) >> 1) - 1L);
}
return result;