Skip to content
Snippets Groups Projects
Commit 5a896337 authored by hdd29's avatar hdd29
Browse files

The anagram lab with README file - apostrophe still there

parent 0f4a3f42
No related branches found
No related tags found
No related merge requests found
The file needed to be run is anagram
Syntax: bash anagram dictionary.txt
(in this case dictionary.txt is actualy /usr/share/dict/words)
I have not remove the apostrophe yet, but may update later
#!/bin/bash
#
#Created by Hanh Do Phung
# 4/26/2019
#
# To sort out a dictionaries and find words with largest number of anagrams
gcc -osign sign.c
./sign < $1 | sort | awk -f squash.awk > tempoutput
awk '{$1=NF; print $0}' < ./tempoutput | sort -n | tail > final
cat "./final"
rm final
rm tempoutput
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define WORDMAX 101
int main()
{
char thisword[WORDMAX], sig[WORDMAX];
int compchar();
while( scanf( "%s", thisword ) != EOF ) {
strcpy( sig, thisword );
qsort( sig, strlen(sig), sizeof(char), compchar );
printf( "%s %s\n", sig, thisword );
}
}
int compchar( a, b )
char *a, *b;
{
if( *a < *b )
return(-1);
else if (*a == *b)
return(0);
else return(1);
}
#!/hdd29/bin/awk
$1 != prev { prev = $1; if (NR > 1) printf "\n" }
{ printf "%s ", $2 }
END { printf "\n" }
$1 != prev { prev = $1; if (NR > 1) printf "\n" }
{ printf "%s ", $2 }
END { printf "\n" }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment