Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,18 @@
function pset = powerset(theSet)
pset = cell(size(theSet)); %Preallocate memory
%Generate all numbers from 0 to 2^(num elements of the set)-1
for i = ( 0:(2^numel(theSet))-1 )
%Convert i into binary, convert each digit in binary to a boolean
%and store that array of booleans
indicies = logical(bitget( i,(1:numel(theSet)) ));
%Use the array of booleans to extract the members of the original
%set, and store the set containing these members in the powerset
pset(i+1) = {theSet(indicies)};
end
end

View file

@ -0,0 +1,5 @@
powerset({{}})
ans =
{} {1x1 cell} %This is the same as { {},{{}} }

View file

@ -0,0 +1,5 @@
powerset({{1,2},3})
ans =
{1x0 cell} {1x1 cell} {1x1 cell} {1x2 cell} %This is the same as { {},{{1,2}},{3},{{1,2},3} }