How to filter

İf You Run program below you will get result


(start result filter from top to bottom)

01 02 03 04 05 + take first row
01 02 03 04 06 - in second row, 3 or more same with first row dont want this
01 02 03 04 07 - in third row, 3 or more same with first row I dont want this
01 02 03 04 08 -
01 02 03 05 06 -
01 02 03 05 07 - (I want program to write signed with +)
01 02 03 05 08 - 3 same with upper thats why dont want this and proggram
01 02 03 06 07 - will not write this (shortly I dont want - signed
01 02 03 06 08 -
01 02 03 07 08 -
01 02 04 05 06 - I did this manualy
01 02 04 05 07 -
01 02 04 05 08 - I want result like this
01 02 04 06 07 -
01 02 04 06 08 - 01 02 03 04 05 (first row)
01 02 04 07 08 - 01 04 06 07 08 (34 row)
01 02 05 06 07 -
01 02 05 06 08 -
01 02 05 07 08 -
01 02 06 07 08 -
01 03 04 05 06 -
01 03 04 05 07 -
01 03 04 05 08 -
01 03 04 06 07 -
01 03 04 06 08 -
01 03 04 07 08 -
01 03 05 06 07 -
01 03 05 06 08 -
01 03 05 07 08 -
01 03 06 07 08 -
01 04 05 06 07 -
01 04 05 06 08 -
01 04 05 07 08 -
01 04 06 07 08 +
01 05 06 07 08 -
02 03 04 05 06 -
02 03 04 05 07 -
02 03 04 05 08 -
02 03 04 06 07 -
02 03 04 06 08 -
02 03 04 07 08 -
02 03 05 06 07 -
02 03 05 06 08 -
02 03 05 07 08 -
02 03 06 07 08 -
02 04 05 06 07 -
02 04 05 06 08 -
02 04 05 07 08 -
02 04 06 07 08 -
02 05 06 07 08 -
03 04 05 06 07 -
03 04 05 06 08 -
03 04 05 07 08 -
03 04 06 07 08 -
03 05 06 07 08 -
04 05 06 07 08 -



#include <iostream>
#include <fstream>
using namespace std;

int main()
{
const int NMAX = 8;
int i = 0;

//Choose ONE of the following
//ofstream out( "outputt.txt" ); // for file
ostream & out = cout; // for screen

for ( int a = 1; a <= NMAX - 2; a++ )
{
for ( int b = a + 1; b <= NMAX - 1; b++ )
{
for ( int c = b + 1; c <= NMAX; c++ )
{
for ( int d = c + 1; d <= NMAX; d++ )
{
for ( int e = d + 1; e <= NMAX; e++ )
{


int n = 100 * a + 10 * b + c + d + e;
i++;









//out << i << ": " << n << '\n';
out << i << ": " << a << " " << b << " " << c << " " << d << " " << e << '\n';

}
}
}
}
}
}

avnitoto wrote:

3 or more same with first row I dont want this

01 02 03 04 05 (first row)
01 04 06 07 08 (34 row)


So why isn't your answer
01 02 03 04 05
01 02 06 07 08


Perhaps you would like to explain again?

To avoid this becoming a classic XY problem
http://xyproblem.info/
could you state what you are actually trying to do, not what you have (mis)coded.


BTW, please put your code in code tags (first item in the format menu; works except for an initial post, but that can easily be edited). I really don't enjoy alignments like
1
2
3
4
5
6
}
}
}
}
}
}




Last edited on
You are right
yours also an answer


01 02 03 04 05 (first row)
01 04 06 07 08 (34 row)

also an answer

01 02 04 05 06
01 03 06 07 08

My question is when I run program it must eliminate the other 54 row and write answer just above (2 row)





From program const int NMAX = 8;
when I change 8 by 9 or 10 or 11


it gives too many row how to eliminate if 3 same in a row
is 08 the largest value or just an example?
if the values are something simple like 0-8, you can just remap all the rows into bits of an integer, and then do logic (like bitwise xor, then count the bits that are 1, which may be something your cpu can do for you cheap) to get the answer.

another approach is some sort of pre-filtering. find some sort of row-wise hash that lets you know that 2 rows are candidates to be eliminated (this won't do it but for example sum the digits, it won't be THAT easy but some playtime will find something) and then check the candidates against each other. This should give you a high quality result … false means they can't possibly have 3 matches, true means a 75% or better chance they do have 3, that sort of thing... this takes time and effort to figure out, but isn't hard to code once you see something usable.

Last edited on
İf you run this program const int NMAX = 8 above it will give 56 row

if you run this program const int NMAX = 9 above it wil give 126 row

if you run this program const int NMAX = 10 above it wil give 252 row

Topic archived. No new replies allowed.