All pastes #822391 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-18 18:35 UTC
rendered paste body

int main()
{

  int i,j;
  int basis[k]; //vector of generators
  int word=0;
  int minweight=k;

  //fill basis

  for(i=0;i<(1<<k); i++ )
    {
      for(j=0;j<k;j++)
      {
	if((i & (1<<j))==1)word=word+basis[j];
      }
      
      if(hweight(word)<minweight)minweight=hweight(word);

    }

  printf("Min Weight=%d",minweight);

  return 0;
}

int hweight(int word)
{
  int i;
  int dist=0;
  
  for(i=0;i<k;i++)
    {
      if(word & (1<<i)==1)dist++;
    }

  return dist;
}