#include <stdio.h>
#define NR_HP 3
#define NR_KIND ((unsigned long)(0xffffffff>>(32-NR_HP)))
#define NR_DIM 3
static get_nr(unsigned long u32);
static void print_hp(unsigned long u32[NR_DIM])
{
int i,j, k;
printf("{");
for (i=0; i < NR_DIM; i++){
k=0;
for (j=0; j<NR_HP; j++)
(1<<j)&u32[i]?printf("%cH%d", k++==0? '{': ',',j+1):0;
if (get_nr(u32[i])) {
printf("}");
if (i!=2)
printf(",");
}
}
printf("}");
printf("/n");
}
static get_nr(unsigned long u32)
{
int i,cnt=0;
for(i=0;i<NR_HP;i++)
if ((1<<i)&u32)
cnt++;
return cnt;
}
static get_first(unsigned long u32)
{
int i, tmp=0;
for (i=0; i<NR_HP; i++)
if ((1<<i)&u32)
return(i+1);
return 0;
}
int main()
{
int i,j,k,cnt=0;
unsigned long u32[NR_DIM], nr_kind=NR_KIND+1;
printf("nr_kind: %d/n", nr_kind);
for (i=0; i < nr_kind; i++) {
for (j=0; j< nr_kind; j++)
for (k=0; k< nr_kind; k++) {
if (i+j+k != NR_KIND)
continue;
if (((i&j)|(i&k)|(j&k)))
continue;
if (get_nr(i)>get_nr(j))
continue;
else if (get_nr(i)==get_nr(j)) {
if (get_first(i)>get_first(j))
continue;
}
if (get_nr(i)>get_nr(k))
continue;
else if (get_nr(i)==get_nr(k)) {
if (get_first(i)>get_first(k))
continue;
}
if (get_nr(j)>get_nr(k))
continue;
else if (get_nr(j)==get_nr(k)) {
if (get_first(j)>get_first(k))
continue;
}
u32[0]=i;
u32[1]=j;
u32[2]=k;
print_hp(u32);
cnt++;
}
}
printf("cnt: %d/n", cnt);
}