I have a form with 2 rich-text-boxes (one on top of the other) and 2 buttons. The top box is the master text (string) and the bottom box is the entry text (string). Every contestant is sending a text to an email account, from the email we copy and paste the text into the Entry RTB and compare to the Master RTB. For each single word and single space counts as a thing to check. And for every error add 1 sec. to their time.
Examples:
- Hello there! <= 3 checks (2 words and 1 space)
- Helothere! <= 2 errors (Helo and space)
- Hello there!! <= 1 error (extra ! at end of there!)
- Hello there! How are you? <= 9 checks (5 words and 4 spaces)
- Helothere!! How a re you? <= still 9 checks, 4 errors(helo, no space, extra !, and a space in are)
- Hello there!@ Ho are yu?? <= 3 errors (@ at end of there!, no w, no o and extra ? (all errors are still under the 1 word)
I've created 6 arrays (3 for master, 3 for entry) and they are
- Char array of all chars
- String array delimited with " " and also counting the " "
- Int array with length of the string in each string array
I hope I have made myself clear enough as to what I need help with. If anyone could give some code examples or something to shoot me in the right path would be very helpful.

Krishna GaradRank #191 · 12.8K reputationPosted Mar 16, 2011, 11:16 PM EDT
KaktusJack26 reputationPosted Mar 16, 2011, 11:31 PM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 17, 2011, 6:13 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Mar 17, 2011, 8:13 AM EDT
string[] master = ("Hello there!").Split(' ');
KaktusJack26 reputationPosted Mar 17, 2011, 9:03 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 17, 2011, 9:18 AM EDT
However, this isn't a very sophisticated way of doing things and, when I have a bit more time, I'll have another think about it.
KaktusJack26 reputationPosted Mar 17, 2011, 9:49 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 17, 2011, 4:40 PM EDT
KaktusJack26 reputationPosted Mar 17, 2011, 6:30 PM EDT
In my head:
first check if strings match if they do then its done. if not then check StringArray if they compare. If they do, for loop and continue until they don't. If they don't then manage somehow to check the CharPerString.Length to see if the lengths are the same. If not then 1 error. Problem starts here if the space is missing and the second word is part of first word. Then I think that maybe we check if next mStringArray index is space, if so continue to next mStringArray. If the substring is found in first word then we have to do something to get it to count 1 for word1 and 1 for space then check for word two and start from there again to continue. Or check the two words on each side of the first space then compare to the first 3 entry ones. If words or substrings are found and blabla then we have to check to see if the spaces are right......
Wow! Look at me go. Ok.
Maybe this will help someone with a greater knowledge of the C# language to do more with that train of thought.
Sam HobbsRank #107 · 20.5K reputationPosted Mar 17, 2011, 7:22 PM EDT
KaktusJack26 reputationPosted Mar 17, 2011, 7:54 PM EDT
thanks for replying.
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2011, 4:16 AM EDT
I'm sure there will be some other cases we haven't considered which it won't cope with either but FWIW here it is:
using System;
KaktusJack26 reputationPosted Mar 18, 2011, 8:55 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 18, 2011, 11:15 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Mar 18, 2011, 12:59 PM EDT
KaktusJack26 reputationPosted Mar 19, 2011, 7:15 PM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 20, 2011, 12:48 AM EDT
KaktusJack26 reputationPosted Mar 20, 2011, 5:48 PM EDT
I'm going to implement a cap check with your code and see if that helps.
I do have one question about the code you posted tho.
if(words.Length == 1) return 1; // we know they're not the same so 1 error
I'm not sure as what this was supposed to do. I commented it out and it still worked and as far as logic I would think that but it doesn't check anything to know they're not the same. So that was kind of my question.
{KJ}
KaktusJack26 reputationPosted Mar 20, 2011, 7:43 PM EDT
I thank you all for trying to help! Especially you Vulpes. After countless hours and a weeks worth of work I decided to accept defeat and just use the Levenshtein Distance Algorithm and just change the error management. I went through so many ideas and trials that none was what I was looking for (although Vulpes's last code was the closest by far). I even tried to treat the situation as I was entering the entry text one character at a time and it worked great for a bit....I was so close, real close but oh well.
Again thanks to all who tried to help.
KaktusJack
My other post:
http://stackoverflow.com/questions/5335244/how-to-compare-2-strings-with-int-out-of-errors
VulpesRank #55 · 29.2K reputationPosted Mar 21, 2011, 2:09 AM EDT
It's been an interesting exercise to try and come up with something though because, as Sam said, questions like this are rarely asked on C# forums.
KaktusJack26 reputationPosted Mar 21, 2011, 7:43 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Mar 21, 2011, 8:49 AM EDT