1
\$\begingroup\$

I have this example data

Data: P ,B ,B ,T ,P

This must be something like this

enter image description here

But what is happening to me is this

enter image description here

here's my code

string[,] table = new string[104, 6];
string newPreviousValue = "placeholder";
int xIndex = -1;
int yIndex = 0;
if (result.Equals(newPreviousValue) &&  yIndex < table.GetLength(1) - 1)
{
    yIndex += 1;
    table[xIndex, yIndex] = result;
}
            
else
{
     xIndex += 1;
     yIndex = 0;
     table[xIndex, yIndex] = result;
}

So you won't get confuse the result variable is the data generator. What could be missing on my condition?

I tried doing something like this

if (result.Equals(newPreviousValue) && result.Equals(newPreviousValueTie) && yIndex < table.GetLength(1) - 1) but what's happening here is they're all in y axis falling in line .

\$\endgroup\$
4
  • 1
    \$\begingroup\$ What's the rule that determines when something can stack in the same column as a dissimilar entry (Tie stacking on Banker) versus when it can't? \$\endgroup\$
    – DMGregory
    May 11 '18 at 12:16
  • \$\begingroup\$ what could possibly the remedy with this @DMGregory \$\endgroup\$
    – Gin09
    May 12 '18 at 2:23
  • \$\begingroup\$ I don't know because you haven't answered the question I asked you above. \$\endgroup\$
    – DMGregory
    May 12 '18 at 11:42
  • \$\begingroup\$ As what said @DMGregory it will not move from X axis. \$\endgroup\$
    – Gin09
    May 15 '18 at 2:55
1
\$\begingroup\$

So you mean every tie must not move to X axis ? If that's the case you can do it something like this :

Inside of your

if (result.Equals(newPreviousValue) &&  yIndex < table.GetLength(1) - 1)
{
    yIndex += 1;
    table[xIndex, yIndex] = result;
}

You recode like this

if (result.Equals(newPreviousValue) &&  yIndex < table.GetLength(1) - 1)
{
     var newResult = previousValue.Contains(scoreboardWinner[2]);
     if (newResult == previousValue.Contains(scoreboardWinner[2])) 
     { 
           yIndex += 1;
           table[xIndex, yIndex] = result;
     }
     else 
     {
         yIndex += 1;
         table[xIndex, yIndex] = result;
     }
}

Maybe that will do.

\$\endgroup\$
2
  • \$\begingroup\$ Hmm i didn't think of that . I'll try this one sir when i get home . Thank you \$\endgroup\$
    – Gin09
    May 15 '18 at 2:52
  • 1
    \$\begingroup\$ Please don't "sir" me . If that's what you want on your rule then I am pretty sure that is the answer \$\endgroup\$ May 15 '18 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .