I need a little help with an assignment. Following is the code I am
being asked to create, any help with this would be great.
Ask the user to enter two strings, a and b. Then return the number of
positions where they contain the same length 2 substring. So “xxcaazz”
and “xxbaaz” yields 3, since the “xx”, “aa”, and “az” substrings appear
in the same place in both strings.
We generally don't do homework outright on this forum/list. Perhaps
you could write up some code, see if it works, and if not, post it
here and we can discuss how to improve it.
···
On Wed, Apr 25, 2012 at 2:48 PM, Clay Tzoucalis <lists@ruby-forum.com> wrote:
I need a little help with an assignment. Following is the code I am
being asked to create, any help with this would be great.
Ask the user to enter two strings, a and b. Then return the number of
positions where they contain the same length 2 substring. So “xxcaazz”
and “xxbaaz” yields 3, since the “xx”, “aa”, and “az” substrings appear
in the same place in both strings.
I also against solving someones homework, but I'll give you maybe a helpful
advice.
You should look at algorithms, that solve Largest Common Subsequence
problem. Here the sequences
are arrays of consecutive length 2 substrings. For instance "abcde" should
be represented with sequence
["ab", "bc", "cd", "de"]. The rest is up to you
···
26 апреля 2012 г. 6:48 пользователь Clay Tzoucalis <lists@ruby-forum.com>написал:
I need a little help with an assignment. Following is the code I am
being asked to create, any help with this would be great.
Ask the user to enter two strings, a and b. Then return the number of
positions where they contain the same length 2 substring. So “xxcaazz”
and “xxbaaz” yields 3, since the “xx”, “aa”, and “az” substrings appear
in the same place in both strings.
On Wed, Apr 25, 2012 at 10:36 PM, Clay Tzoucalis <lists@ruby-forum.com> > wrote:
I understand that. I am looking more for where to start,in attempt to
match the sub strings. This one is just boggling me a little bit.
Think how you would do it on paper and translate the approach into a
program.
Kind regards
robert
I also understand this concept. I mean more should I be thinking, array?
if statements? etc? Is there an approach that I should think about when
tackling this.
Stop trying to decide things like if statements, arrays, etc. Take
Robert's advice. If you were given two strings "abcdefghi" and
"qwcderghz", what steps would you do mentally or on a piece of paper
to figure out how many matches there were? Break your own mental
process down into steps. Then you can worry about translating those
steps into code, if statements, or whatever you decide to use. Robert
gave you a very good approach to tackle this, but I think you perhaps
didn't fully understand his suggestion.
Aaron out.
···
On Wed, Apr 25, 2012 at 2:57 PM, Clay Tzoucalis <lists@ruby-forum.com> wrote:
Robert Klemme wrote in post #1058371:
On Wed, Apr 25, 2012 at 10:36 PM, Clay Tzoucalis <lists@ruby-forum.com> >> wrote:
I understand that. I am looking more for where to start,in attempt to
match the sub strings. This one is just boggling me a little bit.
Think how you would do it on paper and translate the approach into a
program.
Kind regards
robert
I also understand this concept. I mean more should I be thinking, array?
if statements? etc? Is there an approach that I should think about when
tackling this.