134 Loglan Logical Language

All about problems in Volume I. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

134 Loglan Logical Language

Postby ezra » Mon Nov 10, 2003 4:38 am

hello everyone,
i try to solve this prob but i continously got WA. Please anyone be kind to share some important sample input so i can repair my program mistakes.
Thank you.
User avatar
ezra
New poster
 
Posts: 31
Joined: Thu Nov 21, 2002 2:11 pm

Postby cplusplus » Sat Nov 15, 2003 10:50 am

I search this forum and find a topic about P134
here are some test cases...
I got WA, too...

And can anyone please tell me why the answer of the test case
"du zaoya. " is "BAD!" ??
It is the grammar "DA PREDS",isn't it?? Do I misundertand anything??

thank you all very much... :)

INPUT:
le bcade ga fgiho.
le bcade ge fgiho le bcade.
le bcade gi fgiho li bcade.
le bcade go fgiho lo bcade.
le bcade gu fgiho lu bcade.
foobar ge juklo li manpi.
lo qrase ba tviwu a xiyzu.
lo qrase ba tviwu a xiyzu e futye i
futno o blara u jukko.
da ztoya.
de ztoya i grota u thomo.
di ztoya.
do ztoya a brute.
du ztoya.
la mutce
bunbo mrenu ba ditca a ghoto.
futon be ditca.
gruton bi ditca.
le blara bunbo mrenu bo ditca.
jhqdhjqdwhjqwdhjqdjhwefdjhqwedhjwefzz bu ditca.
djb ba bbaba.
djan ga vedma le negro ketpi.
bad starts now.
la fumna bi le mrenu.
dja blarg.
djb ba.
.
le bcad ga fgiho.
le bcade gn fgiho le bcade.
le bcade gi fgiho ly bcade.
le bcade go fgiho lo bcadf.
bcade gu fgiho lu bcade.
lo qrase ba tviwu x xiyzu.
lo qrase ba tviwu a xiyzu e futye i
futno o blara u jukk.
la ztoya.
ge ztoya i grota u thomo.
bi ztoya.
do ztoya a bruten.
du zaoya.
futon e ditca.
gruton li ditca.
le blar bunbo mrenu bo ditca.
djan da vedma le negro ketpi.
#

My OUTPUT:
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Good
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
Bad!
cplusplus
New poster
 
Posts: 13
Joined: Fri Feb 07, 2003 10:20 pm

Postby junjieliang » Sat Nov 15, 2003 11:44 am

predicates which have the form CCVCV or CVCCV where C represents a consonant and V represents a vowel

"zaoya" is not a predicate under this rule.

As for the test cases it appears correct (tested it with AC program), but somehow I got one more "Bad!" output than yours. Perhaps you missed one line when you pasted the output? :D
junjieliang
Experienced poster
 
Posts: 169
Joined: Wed Oct 31, 2001 2:00 am
Location: Singapore

Postby ezra » Sat Nov 15, 2003 5:37 pm

it's weird,my program gave same result as junjieliang said but it's still WA.
I used the logic that separate the sentence into pattern of words and check the structure of the pattern from the beginning of the sentence.
Looks like i should post my code here.
here it is
[cpp]
#include<iostream>
#include<string>
using namespace std;

class word
{
string s;
public:
void read();
int resolve();
bool empty();
bool predicate();
bool detectdot();
bool detectend();
friend bool isvocal(char );
};

bool word::empty()
{
if(s.empty())
return true;
return false;
}

void word::read()
{
cin >> s;
}

bool isvocal(char c)
{
if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'||c=='A'||c=='I'||c=='U'||c=='E'||c=='O')
return true;
return false;
}

bool word::predicate()
{
if(s.length()==5)
{
if(isvocal(s[0])==false&&isvocal(s[1])==false&&isvocal(s[2])==true&&isvocal(s[3])==false&&isvocal(s[4])==true)
return true;
if(isvocal(s[0])==false&&isvocal(s[1])==true&&isvocal(s[2])==false&&isvocal(s[3])==false&&isvocal(s[4])==true)
return true;
}
return false;
}

int word::resolve()
{
if(s=="a" || s=="e" || s=="i" || s=="o" || s=="u")
return 1;
if(s=="ga" || s=="ge" || s=="gi" || s=="go" || s=="gu")
return 2;
if(s=="ba" || s=="be" || s=="bi" || s=="bo" || s=="bu")
return 3;
if(s=="da" || s=="de" || s=="di" || s=="do" || s=="du")
return 4;
if(s=="la" || s=="le" || s=="li" || s=="lo" || s=="lu")
return 5;
if(predicate())
return 7;
if(isvocal(s[s.length()-1])==false)
return 6;
return 0;
}

bool word::detectdot()
{
if(s[s.length()-1]=='.')
{
s=s.substr(0,s.length()-1);
return true;
}
return false;
}

bool word::detectend()
{
if(s[0]=='#')
return true;
return false;
}

class loglan
{
int pattern[2000];
int curr;
int size;
public:
loglan(){size=0;curr=0;}
void readpattern(word &);
bool sentence();
bool predclaim();
bool preds();
bool predname();
bool predstring();
bool statement();
bool verbpred();
};

void loglan::readpattern(word & w)
{
if(!w.empty())
pattern[size++]=w.resolve();
}

bool loglan::verbpred()
{
int rec=curr;
if(pattern[curr++]==2&&predstring())
return true;
curr=rec;
return false;
}

bool loglan::predname()
{
int rec=curr;
if(pattern[curr++]==5&&predstring())
return true;
curr=rec;
if(pattern[curr]==6)
{
curr++;
return true;
}
return false;
}

bool loglan::predstring()
{
if(pattern[curr]==7)
{
curr++;
while(pattern[curr]==7)
{curr++;}
return true;
}
return false;
}

bool loglan::preds()
{
int rec=curr;
if(predstring())
{
while(pattern[curr]==1)
{
curr++;
if(!predstring())
{
curr=rec;
return false;

}
}
return true;
}
curr=rec;
return false;
}

bool loglan::statement()
{
int rec=curr;
if(predname()&&verbpred()&&predname())
return true;
curr=rec;
if(predname()&&verbpred())
return true;
curr=rec;
return false;
}

bool loglan::predclaim()
{
int rec=curr;
if(predname()&&pattern[curr]==3)
{
curr++;
if(preds())
return true;
}
curr=rec;
if(pattern[curr++]==4&&preds())
return true;
curr=rec;
return false;
}

bool loglan::sentence()
{
if(statement()||predclaim())
if(curr==size)
return true;
return false;
}

int main()
{
word w;
loglan *l;
bool EndProgram,EndSentence;
w.read();
EndSentence=w.detectdot();
EndProgram=w.detectend();
while(!EndProgram)
{
l=new loglan;
l->readpattern(w);
while(!EndSentence)
{
w.read();
EndSentence=w.detectdot();
l->readpattern(w);
}
if(l->sentence())
cout<<"Good";
else
cout<<"Bad!";
cout<<endl;
delete l;
w.read();
EndSentence=w.detectdot();
EndProgram=w.detectend();
}
return 0;
}
[/cpp]
please help me. I'll really grateful for your help. Thanks b4.
User avatar
ezra
New poster
 
Posts: 31
Joined: Thu Nov 21, 2002 2:11 pm

Postby cplusplus » Sun Nov 16, 2003 9:07 am

junjieliang wrote:
predicates which have the form CCVCV or CVCCV where C represents a consonant and V represents a vowel

"zaoya" is not a predicate under this rule.

As for the test cases it appears correct (tested it with AC program), but somehow I got one more "Bad!" output than yours. Perhaps you missed one line when you pasted the output? :D


:) thank you very much , I forgot that I have fixed that bug before I paste these test cases. :P
...so still..I got WA again and again...

Can anyone give me some more test cases or some hints ,please ?? Thank you.... :wink:
cplusplus
New poster
 
Posts: 13
Joined: Fri Feb 07, 2003 10:20 pm

Postby cplusplus » Wed Nov 19, 2003 12:27 am

junjieliang wrote:
predicates which have the form CCVCV or CVCCV where C represents a consonant and V represents a vowel

"zaoya" is not a predicate under this rule.

As for the test cases it appears correct (tested it with AC program), but somehow I got one more "Bad!" output than yours. Perhaps you missed one line when you pasted the output? :D

OK...I got AC now...
if a word ends with a vovel but is not a A,GA....MOD, or PREDA....
it will be considered a NAM....
I just return "BAD!" before....I hope this helps you...
cplusplus
New poster
 
Posts: 13
Joined: Fri Feb 07, 2003 10:20 pm

Postby ezra » Sat Dec 27, 2003 6:47 pm

i still get wa on this prob. Is there any input like cplusplus said that a word ends with vowel but not include to one of any loglan words? For my code ,i already posted it,please help me check it. Thank you very much for helping.
User avatar
ezra
New poster
 
Posts: 31
Joined: Thu Nov 21, 2002 2:11 pm

Postby UFP2161 » Mon Feb 16, 2004 5:02 am

Tabs are considered "spaces" too. *sigh*
User avatar
UFP2161
A great helper
 
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm

Postby ezra » Mon Mar 01, 2004 3:01 am

i dont understand. what do you mean about "tabs" ?
Please explain me,i really dont understand,thanks.
User avatar
ezra
New poster
 
Posts: 31
Joined: Thu Nov 21, 2002 2:11 pm

Postby UFP2161 » Mon Mar 01, 2004 3:41 am

The problem statement has been corrected to reflect the input. Please consider carefully what "whitespace" signifies.
User avatar
UFP2161
A great helper
 
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm

Some fine points

Postby lantimilan » Wed Aug 17, 2005 2:42 pm

1. There is BAD formed words, words that are NOT in the grammar. This is very unfortunate because the problem statement says "you can assume all words will be correctly formed". I checked this by an assertion which catches bad words.

2. There is NO upper case characters. So you don't have to worry about case .
-- This is Unix, any explanatory error message is seen as a sign of weakness
lantimilan
New poster
 
Posts: 11
Joined: Sat Mar 19, 2005 11:12 am
Location: HKU

Spaces after the period

Postby danielrocha » Mon Oct 03, 2005 3:30 am

I would just like to warn everyone who's trying to solve this problem that there are spaces after the period. Since this is not clearly stated in the input specification I think it should be mentioned here.
Daniel
UFRN HDD-1
Brasil
User avatar
danielrocha
New poster
 
Posts: 44
Joined: Sun Apr 27, 2003 3:17 am
Location: Rio Grande do Norte - Brazil

Re: 134 Loglan Logical Language

Postby charles1117 » Wed Jun 30, 2010 9:02 am

I got accepted by
1. Passing all the above test cases by cplusplus
2. Remembering that the definition of name is any word that is not ended with a vowel
3. Discarding any characters after the period (don't know whether it is compulsory)
4. Ignoring the extra space between the words

I got WA several times for missing point 2 (the test cases posted by cplusplus does not include the testing of invalid names)
Hope it helps
charles1117
New poster
 
Posts: 2
Joined: Sun Jan 24, 2010 3:31 pm


Return to Volume I

Who is online

Users browsing this forum: No registered users and 1 guest