Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 3rd, 2008, 03:58 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

But you see, all the other answers are equally valid.

"Find the number of times the *WORD* aaa appears in aaaaaaaaaaaa."

In ordinary text, a word is separated from other words by space or punctionation. So the answer is 0.

"Find the number of times inflections of the WORD aaa appear in aaaaaaaaaaaa."

We could consider that an inflection is any string that starts as specified and has any suffix. So the first aaa is the word and all else is part of the inflection. So the answer 1.

"Find the number of times the characters aaa appear in aaaaaaaaaaaa including overlaps." Clearly, there are 10 locations that start the text aaa, so the answer is 10.

And then your answer, and my original answer, to "Find the number of times the characters aaa appear in aaaaaaaaaaaa NOT including overlaps." I think this is the natural computer-ish way to do this, and the answer is of course 4. But I wonder if that's the right answer for any real-world application, where TEXT--and not just string s of characters--is involved.

Again, I'd vote for either 0 or 1, but of course we shouldn't and can't vote. KHB3283's instructor has the only vote that matters.
Old October 5th, 2008, 09:12 PM
Friend of Wrox
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts

The original post did not ask for "words", but occurrences.

Dr. Purdum

Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
Old October 5th, 2008, 11:10 PM
Friend of Wrox
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

The original poster is not very English literate, as is evident from the text of his post even before one notices he is from Vietnam.

Please don't get me wrong: You will note that my first answer agreed with your answer/assumption. Yes, I think the computerish instinct is to do it the way you suggested and that I implemented.

But I am much less sanguine than you that it is (a) the correct answer for this particular request or (b) the correct answer in general, in common usage. I would guess that for (a) there's a 75% chance that four is the correct result. For (b), I don't think there's any such thing a "correct result."

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to count the number of access the webpage ? khb3283 ASP.NET 2.0 Basics 2 October 2nd, 2008 09:08 PM
Need to Count number of lines in a file lawsoncobol Access VBA 2 July 19th, 2007 04:28 AM
Count the number of output lines joyces XSLT 7 July 6th, 2005 11:49 AM
count the number of rows in the table crmpicco Javascript How-To 4 February 2nd, 2005 12:58 AM
count the TOTAL number of segments crmpicco Classic ASP Basics 2 February 1st, 2005 05:03 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.