Anagrams: Difference between revisions

Content added Content deleted
(minor correction to Clojure version)
Line 108:
#include <time.h>
 
char *sortedWord(const char *word, char *wbuf)
{
char *p1, *p2, *endwrd;
Line 152:
 
 
int Str_Hash( const char *key, int ix_max )
{
const char *cp = key;
short mash;
int hash = 33501551;
whilefor (cp = key; *cp; cp++) {
mash = cxmap[*cp % CXMAP_SIZE];
hash = ((hash >>4) ^ 0x5C5CF5C) ^ ((hash<<1) + (mash<<5));
hash &= 0x3FFFFFFF;
cp++;
}
return hash % ix_max;
Line 168 ⟶ 167:
typedef struct sDictWord *DictWord;
struct sDictWord {
const char *word;
DictWord next;
};
Line 174 ⟶ 173:
typedef struct sHashEntry *HashEntry;
struct sHashEntry {
const char *key;
HashEntry next;
DictWord words;
Line 221 ⟶ 220:
we->next = he->words;
he->words = we;
he->wordCount += 1+;
if ( maxPC < he->wordCount) {
maxPC = he->wordCount;
Line 232 ⟶ 231:
}
numWords += 1+;
}
printf("%d words in dictionary max ana=%d\n", numWords, maxPC);
Line 239 ⟶ 238:
 
 
int main( int argc, char *argv[] )
{
HashEntry he;