Which finite abelian group is this?
Matlab, 326 bytes
With some group theory the idea is quite simple: Here the TL;DR Calculate all possible orders of elements of the group. Then find the biggest subgroup of a certain prime power order and "factorize" it out of the group, rinse, repeat.
function r=c(h,l)
%factorize group order
N=numel(L);
f=factor(N);
P=unique(f); %prime factors
for k=1:numel(P);
E(k)=sum(f==P(k)); %exponents of unique factors
end;
%calculate the order O of each element
O=L*0-1;
l=L;
for k=2:N+1;
l=h(l,L);
O(l==L & O<0)=k-1
end;
%%
O=unique(O); % (optional, just for speedupt)
R=[];
% for each prime,find the highest power that
% divides any of the orders of the element, and
% each time substract that from the remaining
% exponent in the prime factorization of the
% group order
for p=1:nnz(P); % loop over primes
while E(p)>1; % loop over remaining exponent
for e=E(p):-1:1; % find the highest exponent
B=mod(O,P(p)^e)==0;
if any(B)
R=[R,P(p)^e]; % if found, add to list
O(B)=O(B)/(P(p)^e);
E(p)=E(p)-e;
break;
end;
end;
end;
if E(p)==1;
R=[R,P(p)];
end;
end;
r=sort(R)
Example inputs:
L = 0:3;
h=@(a,b)mod(a+b,4);
h=@(a,b)bitxor(a,b);
L = 0:80;
h=@(a,b)mod(mod(a,3)+mod(b,3),3)+mod(floor(a/3)+floor(b/3),3)*3+ mod(floor(a/9)+floor(b/9),9)*9;
Golfed version:
function r=c(h,l);N=numel(L);f=factor(N);P=unique(f);for k=1:numel(P);E(k)=sum(f==P(k));end;O=L*0-1;l=L;for k=2:N+1;l=h(l,L);O(l==L&O<0)=k-1;end;R=[];for p=1:nnz(P);while E(p)>1;for e=E(p):-1:1;B=mod(O,P(p)^e)==0; if any(B);R=[R,P(p)^e]; O(B)=O(B)/(P(p)^e);E(p)=E(p)-e;break;end;end;end;if E(p)==1;R=[R,P(p)];end;end;r=sort(R)