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 trialAndrew McPheron
14,290 PointsCode looks fine in debugger, but getting 'table should have 6 rows and columns'
I pasted my code into visual studio to use the debugger on it, but I'm seeing 6 rows and 6 columns with correct values when I hover over my sheet variable. I've seen some other answered questions that say to increase the max value by one, but the question currently says to return from 0 to maxValue and even shows the zeros in the example code. What am I missing here?
namespace Treehouse.CodeChallenges
{
public static class MathHelpers
{
public static int[][] BuildMultiplicationTable(int maxFactor)
{
int[][] sheet = new int[maxFactor][];
for (int x = 0; x < maxFactor; x++)
{
int[] values = new int[maxFactor];
for (int y = 0; y < maxFactor; y++)
{
values[y] = x * y;
}
sheet[x] = values;
}
return sheet;
}
}
}
2 Answers
Andrew McPheron
14,290 PointsI ended up fixing it by adding the following code to the very start of the method:
maxResult++;
Turns out it's just a matter of the input number being one lower than expected. Ah well.
Ryan Pierson
14,365 PointsThanks! That was what I was wrestling with as well!