Re: Check for Common character sequence ( I will pay)?



OK. Thanks kevin.

One question for yiu.

What is FoundString[] countSubstrings(string[] rgszValues);

Do I need to return an array?

countSubstrings(string[] rgszValues); is the method.

Is FoundString[] the return type?

"Kevin Spencer" wrote:

Dude, programming is all problem-solving. Syntax is just language. If you
want to be a programmer, you have to learn problem-solving. You've been
given a problem. Solve it. Doing your homework for you simply nullifies the
benefit that the homework is intended to convey. Homework is not assigned
for the purpose of testing your ability to turn in homework on time. It is
assigned to help you learn.

Here's a few clues:

Big things are made up of lots of little things. - A large problem is made
up of smaller problems. A program is made up of lots of small instructions.
Each instruction is a solution to a small problem. Break the large problem
up into smaller ones, then break each of the smaller ones into the smallest
possible problems you can.

In this case, you're starting with an array of strings, which is made up of
one string per element.
You need to identify character sequences of 3 or more characters that appear
in more than one string.
This means that you have to identify sequences 1 character at a time,
working with 3 characters to start, and seeing how much farther it goes with
each one.
So, obviously, the first step is to iterate through the first string, one
character at a time, and test each 3-character sequence that results.
Again, obviously, if the 3-character sequence doesn't match, neither will a
4-character sequence starting from the same point match. So, if the
3-character sequence isn't found in the test string, you move on.
If the 3-character sequence *does* match, you need to (1) make a note of
that 3-character sequence, and (2) expand it by one character and test
again, against the same groups that matched the 3-character sequence.
You would continue doing this until a given 3+-character sequence is not
found to match any of the formerly-matching sequences.
After that, you would return to 3 characters, move forward 1 character, and
continue.

Okay, that's it in a nutshell. Software does one thing very well: It repeats
itself. So, the rest of it is applying this solution to the entire set of
strings. Of course, you will need to account for and prevent finding the
same match by comparing a string to a string it has previously been compared
to. But remember that once you've iterated through the first string, and
compared it with all the others, you don't need to include it when you test
the others.

Now, for extra credit, study how I analyzed the problem and learn how to
analyze programming problems for yourself. If you plan to become a
programmer, this is what you will be doing, day in and day out. And there
will be nobody around to do it for you!

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.


--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

"C" <C@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DA610AF0-E692-4739-8B2F-E5365D5FC74F@xxxxxxxxxxxxxxxx
Yeah. Its a Project I have to do in C#. And I really don't have a clue.

If you can do it I will pay you throuh Paypal.

Need it done tonight though.

Interested?

"Greg Young" wrote:

Homework?


"C" <C@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:43D5A724-542B-49C0-8B22-72CEE887F86F@xxxxxxxxxxxxxxxx
Hi,

Anyone know how I can do this?

I will pay anyone via PayPal who can do this for me. Let me know?

Write a function in C# that takes in an array of ASCII strings and
finds
all
common character sequences. A common character sequence is defined as
3
or
more adjacent characters that appear in more than one string in the
array.
Use the following function signature for your response:



//C#

class FoundString {

public int cOccurrences; //count of times this substring


//occurred in the value array
public string szSubstring; //substring that was found

}



FoundString[] countSubstrings(string[] rgszValues);



Ex. input of ("will-01", "a_williams", "will_01_iam") would return

"wil" (cOccurrences = 3)

"will" (cOccurrences = 3)

"ill" (cOccurrences = 3)

"iam" (cOccurrences = 2)



Provide coded unit tests cases that exercise your solution.



For extra credit:

1a. Order the results in descending order based on the number of input
values each sequence matched.

1b. Prune the results by removing all results that are a substring of
another result that matched the same number of input values. In the
above
example "wil" and "ill" would both be discarded because they are both a
substring of "will" and all 3 values match 3 input strings








.



Relevant Pages

  • Help in Spanish translation of the description of UDFs
    ... functions of minimum / maximum values among elements of an array column. ... GETALLWORDS- Inserts the words from a string into a global dimensioned ... WORDTRAN- Searches a character string for occurrences of a first word, ... ARRAYSUM- Returns the sum of all or a specified range of numeric (and/or ...
    (microsoft.public.fox.helpwanted)
  • Re: user defined function that converts string to float
    ... > I need user defined function that converts string to float in c. ... initial, possibly empty, sequence of white-space characters (as ... point character, then an optional exponent part as defined in ... then a nonempty sequence of hexadecimal digits ...
    (comp.lang.c)
  • Re: Check for Common character sequence ( I will pay)?
    ... Dude, programming is all problem-solving. ... You need to identify character sequences of 3 or more characters that appear ... in more than one string. ... and test each 3-character sequence that results. ...
    (microsoft.public.dotnet.framework)
  • Re: sed applying the same regexp twice
    ... >before the same dot (that terminated the just substituted sequence) ... so matching another empty sequence of non-dots is an error. ... get replaced) the search will continue at the next character ... the string as matching also and you would have got another hyphen. ...
    (comp.unix.shell)
  • Re: Check for Common character sequence ( I will pay)?
    ... Yes you are returning an array of FoundString objects. ... in more than one string. ... This means that you have to identify sequences 1 character at a time, ... Again, obviously, if the 3-character sequence doesn't match, neither will ...
    (microsoft.public.dotnet.framework)