Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTravis John Villanueva
5,052 PointsUnderstanding the question
Hi please help me to understand the task as I'm very new in C#. I understand the concept but having difficulties in understanding the task
namespace Treehouse.CodeChallenges
{
class SequenceDetector
{
public virtual bool Scan(int[] sequence)
{
return true;
}
}
}
namespace Treehouse.CodeChallenges
{
class RepeatDetector : SequenceDetector
{
public override bool Scan(int[] sequence)
{
return true;
}
}
}
1 Answer
Steven Parker
231,198 PointsIt looks like you're down to the last step.
So far, so good. You seem to already have your override established, so now all that's left is to "return true if any value in the array is a repeat of the value immediately preceding it."
So for this you'd probably want to set up a loop that starts at the second item and goes to the end (the length of the array). Then, in the loop body, test if the current item is the same as the previous one, and return false if so. But if the loop finishes without finding a match, return true.
Give it another shot. I'll bet you can get it without an explicit code spoiler.