Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 DWITE NOVEMBER 25 2005 PROBLEM 3 SOLUTION
Index -> CompSci.ca, Contests -> DWITE
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
zylum




PostPosted: Mon Nov 28, 2005 10:11 am   Post subject: (No subject)

you should use String.split(String s); rather than tokenizer.. its much more powerful. it accepts a string as a parameter and it returns an array of strings. the string is split based on the string you provided. you can even use regular expressions as a parameter. so for the example above ie hyphen, space, or both you would do:

String[] splitArray = stringToSplit.split("[ -]++");
Sponsor
Sponsor
Sponsor
sponsor
bugzpodder




PostPosted: Mon Nov 28, 2005 10:38 am   Post subject: (No subject)

umm not really (to the post above zylum). there are design issues with this idea.

for example, if we were to tokenize based on "--" and "-"
on the string

omg---omg
MysticVegeta




PostPosted: Mon Nov 28, 2005 2:04 pm   Post subject: (No subject)

I am confused Confused Does the (" -") split both " " and "-"? also, what is the "++" for? Mad
bugzpodder




PostPosted: Mon Nov 28, 2005 2:41 pm   Post subject: (No subject)

i believe thats regular expressions.
Cervantes




PostPosted: Mon Nov 28, 2005 4:12 pm   Post subject: (No subject)

bugzpodder wrote:
umm not really (to the post above zylum). there are design issues with this idea.

for example, if we were to tokenize based on "--" and "-"
on the string

omg---omg


Good point. I guess you'd throw an error if one of the strings is a substring of another string. ie. "-" is a substring of "--".

Still, it could be useful.
xXInsanityXx




PostPosted: Mon Nov 28, 2005 6:28 pm   Post subject: (No subject)

To Mysticvegeta,

Ignore my idiocy, but in this particular case, doesnt your way seem to be a bit too complicated, or elongated, and the logic is stretching much more farther than the necessity, please i want feedback and opinions from everybody. Honestly, i would love to have programming skills like mystic, but wouldnt this take much more time?
MysticVegeta




PostPosted: Mon Nov 28, 2005 6:54 pm   Post subject: (No subject)

what the heck? Your team scored more than me! Besides if you want programming skills really good, make them like Zylum, Bugz, Cervantes, wtd, rizzix, Hikaru.... I am really a noobie compared to them Exclamation
bugzpodder




PostPosted: Mon Nov 28, 2005 7:01 pm   Post subject: (No subject)

Cervantes wrote:
bugzpodder wrote:
umm not really (to the post above zylum). there are design issues with this idea.

for example, if we were to tokenize based on "--" and "-"
on the string

omg---omg


Good point. I guess you'd throw an error if one of the strings is a substring of another string. ie. "-" is a substring of "--".

Still, it could be useful.


what about trying to use
hello
lol
as tokens on

hellololol

there are two problems here, hello and lol overlap, and lol overlaps with itself.

too many errors thrown, i'd say.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Mon Nov 28, 2005 8:17 pm   Post subject: (No subject)

Good point, bugzpodder.

Still, it seems like a feature that would be useful. Consider the same problem, except instead of using "-" they used "--". One wouldn't be able to use the tokenizer then.

Perhaps it would work with an precedence order. First it splits everything up based on the first element of the array, then splits those up based on the second, etc.
bugzpodder




PostPosted: Mon Nov 28, 2005 10:27 pm   Post subject: (No subject)

acutally you can still use the tokenizer. i am just not sure the correct behaviour though, you might either get empty string between the double dash or you might not get it. its easy enough to just skip over the empty strings.

All in all, I see no point in extending tokenizer to general strings. if you want the behaviour you descirbed, you can just use the find/search command for the first string, then the second, etc...
zylum




PostPosted: Mon Nov 28, 2005 11:06 pm   Post subject: (No subject)

can anybody post the harder problems from the last contest?
JackTruong




PostPosted: Mon Nov 28, 2005 11:30 pm   Post subject: (No subject)

Which ones are the harder ones? I thought the hard ones were #4 and possibly #5. I can post the Java for them.
zylum




PostPosted: Tue Nov 29, 2005 2:00 pm   Post subject: (No subject)

i mean the problems not the solutions...
xXInsanityXx




PostPosted: Wed Nov 30, 2005 1:16 pm   Post subject: (No subject)

zylum wrote:
i mean the problems not the solutions...


go to dwite.org previous contest, november 2005, scroll down and you will find a list of the problems in pdf format read em test em with data, and solve em too Wink
MysticVegeta




PostPosted: Wed Nov 30, 2005 2:34 pm   Post subject: (No subject)

oh. dont worry about him, he will complete all 5 in 45 mins.
Display posts from previous:   
   Index -> CompSci.ca, Contests -> DWITE
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 30 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: