Hey guys,

I'm struggling with yet another problem. The goal is to run 1000 "draws" of three numbers but the catch is, the three numbers can't be repeating. So, no 4 1 4 or 7 7 7 or 8 1 8 and so on and so forth. Every line of three numbers must have the three numbers be from 1-8.

``````#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
int Yellow = 1;
int Blue = 2;
int Red = 3;
int Purple = 4;
int Orange = 5;
int Green = 6;
int Maroon = 7;
int Black = 8;
int tally_total = 1000;
int tally[tally_total];

for(int i = 0; i < tally_total; i++)
{
tally[i] = (rand()%8)+1;
tally[i+1] = (rand()%8)+1;
tally[i+1] != tally[i];

while(tally[i+1] == tally[i])
{
if(tally[i+1] == tally[i])
{
tally[i+1] = (rand()%8)+1;
continue;}
}
tally[i+2] = (rand()%8)+1;
tally[i+2] != tally[i] || tally[i+1];

while(tally[i+2] == tally[i])
{
if(tally[i+2] == tally[i])
{
tally[i+2] = (rand()%8)+1;
continue;
}
}

while(tally[i+2] == tally[i+1])
{
if(tally[i+2] == tally[i+1])
{
tally[i+2] = (rand()%8)+1;
continue;
}
}

if(tally[i+1] == tally[i])
cout << "NUMBERS REPEATED";
if(tally[i+1] == tally[i+2])
cout << "NUMBERS REPEATED";
if(tally[i] == tally[i+2])
cout << "NUMBERS REPEATED";

cout << tally[i]
<< " "
<< tally[i+1]
<< " "
<< tally[i+2]
<< endl;
}

getchar();
getchar();
return 0;
}``````

## jonsca 1,059

`tally[i+2] != tally[i] || tally[i+1]` (line 34) is not doing what you want it to do. You need `(tally[i+2] !=tally[i]) || (tally[i+2] !=tally[i+1])` .

## firstPerson 761

Have a test condition in your for loop.

In psuedocode :

``````for i = 0 untill MAX{
pick1 = random number
pick2 = random number
while(pick2 == pick1 ) pick2 = another random number
pick3 = random number
while(pick3 == pick2 or pick3 == pick1) pick3 = another random number
}``````