CTSD Project Documentation Template (1) - Extracted
CTSD Project Documentation Template (1) - Extracted
Teddy and Tracy like to play a game based on strings. The game is as follows.
Initially, Tracy writes a Jong random string on a whiteboard. Then, each player
starting with Teddy makes turn alternately. Each turn, the player must erase a
contiguous substring that exists In the dictionary. The dictionary consists of N
words. Of course, the player that can't erase any substring in his turn loses the
game, and the other player is declared the winner. Note that after a substring
R is erased, the remaining substring becomes separated, i.e. they cannot erase
a word that occurs partially to the left of R and partially to the right of R.
Determine the winner of the game, assuming that both players play optimally.
INDEX
S.NO TITLE PAGE NO
1 Introduction 1
4 Algorithm 4
5 Flowchart 5
6 Implementation 8
8 Conclusion 11
INTRODUCTION
Teddy and Tracy like to play a game based on strings. The game is as follows.
Initially, Tracy writes a long random string on a whiteboard. Then, each player
starting with Teddy makes turn alternately. Each tum, the player must erase a
contiguous substring that exists in the dictionary. The dictionary consists of N
words. Of course, the playerthat can't erase any substring In his turn loses the
game, and the other player Is declared the winner. Note that after a substring
R is erased, the remaining substring becomes separated, I.e. they cannot erase
a word that occurs partially to the left of Rand partially to the right of R.
Determine the winner of the game, assuming that both players play optimally.
► Put each word of the Input string Into the rows of 2-D array.
► When the substring is got, then override the current row with next row and
so on upto the last row. You need to often manipulate strings according to the
need of a problem. Most, if not all, of the time string manipulation can be done
manually but, this makes programming complex and large. To solve this, C
supports a large number of string handling functions in the standard library
String.h. few commonly used string handling functions are
strlen(),strcpy(l.strcat(),strcmp(),etc .... .., strstr() function searches the given
string in the specified main siring and returns the pointer to the first
occurrence of the given string. Therefore it is necessary to include string
header file to use standard C string library function strstr( ). c strstr() function
declaration
AIM
It is based on the strings and the substring arc erased li'om the given string by
the players based on 'Nords in dictionary.
Advantages:-
Disadvantages:-
Fixed size.
Future enhancements:-
1. We can write the program for finding the substring from the given string
without using library function i.e. strstr().
2. We can build many programs with stings and arrays by using different
concepts as like of this project.
SYSTEM REQUIREMENTS
SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : Turbo-C
Operating system: Windows Xp or later.
HARDWARE REQUIREMENTS:
RAM :8GB
#include<string.h>
char d[50][50],s[100];
int t,i,j,k,n,l,g[50][50],temp[100],len[100],le,u,c=0;
{
int i;
for(i=0;i<len;i++) if(a[i]!=b[i]) return 0;
return 1;
}
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
l=strlen(s);
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%s",d[i]),len[i]=strlen(d[i]);
for(i=0;i<l;i++)
g[i][i]=0;
for(le=1;le<=l;le++){
for(i=0;i<=(l-le);i++){
j=i+le;c++;
for(k=0;k<n;k++){
if(len[k]<=le){
for(u=i;u<=(j-len[k]);u++) if(match(s+u,d[k],len[k])){
temp[g[i][u]^g[u+len[k]][j]]=c;
}
}
}
for(k=0;temp[k]==c;k++); g[i][j]=k;
}
}
printf("%s\n",(!g[0][l])?"Tracy":"Teddy");
}
}
RESULTS AND SCREENSHOTS
OUTPUTS
Screen Shots:
CONCLUSION
By this project we under stood the concepts of strings and know how to how
to get substring from the given string and got all the several string library
functions used to manipulate strings and understood and finished the project
and getting outputs for the given Inputs.