How to get the odd and even parity on a game board

I am creating a memory game where there are "X" and "O" on the board. The user selects particular row and column to change it to "X" if it is "O" or to change it to "O" if it is "X". The other player need to find the changed piece on the board.

Everything is working fine. But, on the game board I need to have "ODD" number of "X" in each row and column. How can I achieve this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <iomanip>

using namespace std;

char p1,  p2,  p3,  p4,  p5,  p6,
     p7,  p8,  p9,  p10, p11, p12,
     p13, p14, p15, p16, p17, p18,
     p19, p20, p21, p22, p23, p24,
     p25, p26, p27, p28, p29, p30,
     p31, p32, p33, p34, p35, p36;

void random()
{
	p1 = rand() ; p2 = rand() ; p3 = rand(); p4 = rand() ; p5 = rand(); p6 = rand() ;
	p7 = rand() ; p8 = rand() ; p9 = rand(); p10 = rand() ; p11 = rand(); p12 = rand();
	p13 = rand(); p14 = rand(); p15 = rand(); p16 = rand(); p17 = rand(); p18 = rand();
	p19 = rand(); p20 = rand(); p21 = rand(); p22 = rand(); p23 = rand(); p24 = rand();
	p25 = rand(); p26 = rand(); p27 = rand(); p28 = rand(); p29 = rand(); p30 = rand();
	p31 = rand(); p32 = rand(); p33 = rand(); p34 = rand(); p35 = rand(); p36 = rand();

	if (p1 % 2 == 0)  { p1 = 'X'; }  	else { p1 = 'O'; }
	if (p2 % 2 == 0)  { p2 = 'X'; }	else { p2 = 'O'; }
	if (p3 % 2 == 0)  { p3 = 'X'; }	else { p3 = 'O'; }
	if (p4 % 2 == 0)  { p4 = 'X'; }	else { p4 = 'O'; }
	if (p5 % 2 == 0)  { p5 = 'X'; }	else { p5 = 'O'; }
	if (p6 % 2 == 0)  { p6 = 'X'; }	else { p6 = 'O'; }
	if (p7 % 2 == 0)  { p7 = 'X'; }	else { p7 = 'O'; }
	if (p8 % 2 == 0)  { p8 = 'X'; }	else { p8 = 'O'; }
	if (p9 % 2 == 0)  { p9 = 'X'; }	else { p9 = 'O'; }
	if (p10 % 2 == 0) { p10 = 'X'; }	else { p10 = 'O'; }
	if (p11 % 2 == 0) { p11 = 'X'; }	else { p11 = 'O'; }
	if (p12 % 2 == 0) { p12 = 'X'; }	else { p12 = 'O'; }
	if (p13 % 2 == 0) { p13 = 'X'; }	else { p13 = 'O'; }
	if (p14 % 2 == 0) { p14 = 'X'; }	else { p14 = 'O'; }
	if (p15 % 2 == 0) { p15 = 'X'; }	else { p15 = 'O'; }
	if (p16 % 2 == 0) { p16 = 'X'; }	else { p16 = 'O'; }
	if (p17 % 2 == 0) { p17 = 'X'; }	else { p17 = 'O'; }
	if (p18 % 2 == 0) { p18 = 'X'; }	else { p18 = 'O'; }
	if (p19 % 2 == 0) { p19 = 'X'; }	else { p19 = 'O'; }
	if (p20 % 2 == 0) { p20 = 'X'; }	else { p20 = 'O'; }
	if (p21 % 2 == 0) { p21 = 'X'; }	else { p21 = 'O'; }
	if (p22 % 2 == 0) { p22 = 'X'; }	else { p22 = 'O'; }
	if (p23 % 2 == 0) { p23 = 'X'; }	else { p23 = 'O'; }
	if (p24 % 2 == 0) { p24 = 'X'; }	else { p24 = 'O'; }
	if (p25 % 2 == 0) { p25 = 'X'; }	else { p25 = 'O'; }
	if (p26 % 2 == 0) { p26 = 'X'; }	else { p26 = 'O'; }
	if (p27 % 2 == 0) { p27 = 'X'; }	else { p27 = 'O'; }
	if (p28 % 2 == 0) { p28 = 'X'; }	else { p28 = 'O'; }
	if (p29 % 2 == 0) { p29 = 'X'; }	else { p29 = 'O'; }
	if (p30 % 2 == 0) { p30 = 'X'; }	else { p30 = 'O'; }
	if (p31 % 2 == 0) { p31 = 'X'; }	else { p31 = 'O'; }
	if (p32 % 2 == 0) { p32 = 'X'; }	else { p32 = 'O'; }
	if (p33 % 2 == 0) { p33 = 'X'; }   else { p33 = 'O'; }
	if (p34 % 2 == 0) { p34 = 'X'; }	else { p34 = 'O'; }
	if (p35 % 2 == 0) { p35 = 'X'; }	else { p35 = 'O'; }
	if (p36 % 2 == 0) { p36 = 'X'; }	else { p36 = 'O'; }
}

void display()
{
	cout << setw(3) << "  " << setw(2) << "1" << setw(3) << "2" << setw(3) << "3" << setw(3) << "4" << setw(3) << "5" << setw(3) << "6" << endl;
	cout << setw(3) << "  " << setw(2) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << endl;
	cout << setw(3) << "A" << "|" << p1  << setw(3) << p2  << setw(3) << p3  << setw(3) << p4  << setw(3) << p5  << setw(3) << p6 << "|" << endl;
	cout << setw(3) << "B" << "|" << p7  << setw(3) << p8  << setw(3) << p9  << setw(3) << p10 << setw(3) << p11 << setw(3) << p12 << "|" << endl;
	cout << setw(3) << "C" << "|" << p13 << setw(3) << p14 << setw(3) << p15 << setw(3) << p16 << setw(3) << p17 << setw(3) << p18 << "|" << endl;
	cout << setw(3) << "D" << "|" << p19 << setw(3) << p20 << setw(3) << p21 << setw(3) << p22 << setw(3) << p23 << setw(3) << p24 << "|" << endl;
	cout << setw(3) << "E" << "|" << p25 << setw(3) << p26 << setw(3) << p27 << setw(3) << p28 << setw(3) << p29 << setw(3) << p30 << "|" << endl;
	cout << setw(3) << "F" << "|" << p31 << setw(3) << p32 << setw(3) << p33 << setw(3) << p34 << setw(3) << p35 << setw(3) << p36 << "|" << endl;
	cout << setw(3) << "  " << setw(2) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << setw(3) << "-" << endl;
}

void change(char user1, int user2)
{
	if (user1 == 'a'&&user2 == 1)
	{
		if (p1 == 'X'){	p1 = 'O';}	else{p1 = 'X';}
	}
	if (user1 == 'a'&&user2 == 2)
	{
		if (p2 == 'X') { p2 = 'O'; }else { p2 = 'X'; }
	}
	if (user1 == 'a'&&user2 == 3)
	{
		if (p3 == 'X') { p3 = 'O'; }else { p3 = 'X'; }
	}
	if (user1 == 'a'&&user2 == 4)
	{
		if (p4 == 'X') { p4 = 'O'; }else { p4 = 'X'; }
	}
	if (user1 == 'a'&&user2 == 5)
	{
		if (p5 == 'X') { p5 = 'O'; }else { p5 = 'X'; }
	}
	if (user1 == 'a'&&user2 == 6)
	{
		if (p6 == 'X') { p6 = 'O'; }else { p6 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 1)
	{
		if (p7 == 'X') { p7 = 'O'; }else { p7 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 2)
	{
		if (p8 == 'X') { p8 = 'O'; }else { p8 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 3)
	{
		if (p9 == 'X') { p9 = 'O'; }else { p9 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 4)
	{
		if (p10 == 'X') { p10 = 'O'; }else { p10 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 5)
	{
		if (p11 == 'X') { p11 = 'O'; }else { p11 = 'X'; }
	}
	if (user1 == 'b'&&user2 == 6)
	{
		if (p12 == 'X') { p12 = 'O'; }else { p12 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 1)
	{
		if (p13 == 'X') { p13 = 'O'; }else { p13 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 2)
	{
		if (p14 == 'X') { p14 = 'O'; }else { p14 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 3)
	{
		if (p15 == 'X') { p15 = 'O'; }else { p15 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 4)
	{
		if (p16 == 'X') { p16 = 'O'; }else { p16 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 5)
	{
		if (p17 == 'X') { p17 = 'O'; }else { p17 = 'X'; }
	}
	if (user1 == 'c'&&user2 == 6)
	{
		if (p18 == 'X') { p18 = 'O'; }else { p18 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 1)
	{
		if (p19 == 'X') { p19 = 'O'; }else { p19 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 2)
	{
		if (p20 == 'X') { p20 = 'O'; }else { p20 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 3)
	{
		if (p21 == 'X') { p21 = 'O'; }else { p21 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 4)
	{
		if (p22 == 'X') { p22 = 'O'; }else { p22 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 5)
	{
		if (p23 == 'X') { p23 = 'O'; }else { p23 = 'X'; }
	}
	if (user1 == 'd'&&user2 == 6)
	{
		if (p24 == 'X') { p24 = 'O'; }else { p24 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 1)
	{
		if (p25 == 'X') { p25 = 'O'; }else { p25 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 2)
	{
		if (p26 == 'X') { p26 = 'O'; }else { p26 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 3)
	{
		if (p27 == 'X') { p27 = 'O'; }else { p27 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 4)
	{
		if (p28 == 'X') { p28 = 'O'; }else { p28 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 5)
	{
		if (p29 == 'X') { p29 = 'O'; }else { p29 = 'X'; }
	}
	if (user1 == 'e'&&user2 == 6)
	{
		if (p30 == 'X') { p30 = 'O'; }else { p30 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 1)
	{
		if (p31 == 'X') { p31 = 'O'; }else { p31 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 2)
	{
		if (p32 == 'X') { p32 = 'O'; }else { p32 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 3)
	{
		if (p33 == 'X') { p33 = 'O'; }else { p33 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 4)
	{
		if (p34 == 'X') { p34 = 'O'; }else { p34 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 5)
	{
		if (p35 == 'X') { p35 = 'O'; }else { p35 = 'X'; }
	}
	if (user1 == 'f'&&user2 == 6)
	{
		if (p36 == 'X') { p36 = 'O'; }else { p36 = 'X'; }
	}
}

int main()
{
	int user2;
	int user4;
	char user1;
	char user3;
	srand(time(NULL));
	random();
	display();

	cout << "Which one do you want to change ";
	cin >> user1;
	cin >> user2;

	change(user1, user2);
	display();
	cout << "Find which one has been changed ";
	cin >> user3;
	cin >> user4;
	if (user1 == user3 && user2 == user4)
	{
		cout << "Congratulations! You won " << endl;
	}
	else
	{
		cout << "Sorry, it was " << user1 << user2 << endl;
	}


	system("pause");
	return 0;
}
That's a lot of ifs. Have you learned to use arrays yet?

Is there a particular reason you need an odd number of 'X' in each row and column? Does the board need to be generated uniformly randomly over the set of legal boards or is it okay if the distribution is not uniform? It is not hard to generate boards that fit the first criterion or the second alone, but I can't think of a very easy way to do them together other than generating the set of all legal boards and randomly picking one.
@Browni3141, it's actually pretty simple. You can populate the board randomly, adjust rows to odd number of X's, and then iteratively adjust the columns and rows until there's no change. The length of the code below is mostly repetition (adjust_rows and adjust_cols are very similar). I'm not sure how to reduce it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

const int Size = 6;

void display(const char p[][Size]) {
    cout << "    ";
    for (int i = 1; i <= Size; ++i) cout << setw(3) << i;
    cout << "\n    ";
    for (int i = 0; i < Size; ++i) cout << setw(3) << '-';
    cout << '\n';
    for (int row = 0; row < Size; ++row) {
        cout << "  " << char('A' + row) << '|';
        for (int col = 0; col < Size; ++col)
            cout << setw(3) << p[row][col];
        cout << '\n';
    }
}

bool adjust_rows(char p[][Size]) {
    bool change = false;
    for (int row = 0; row < Size; ++row) {
        int cnt = 0;
        for (int col = 0; col < Size; ++col)
            if (p[row][col] == 'X')
                ++cnt;
        if (cnt % 2 == 0) {
            change = true;
            if (cnt == 0 || (cnt != Size && rand() % 2)) {
                cnt = rand() % (Size - cnt);
                for (int col = 0; col < Size; ++col)
                    if (p[row][col] == 'O' && cnt-- == 0) {
                        p[row][col] = 'X';
                        break;
                    }
            }
            else {
                cnt = rand() % cnt;
                for (int col = 0; col < Size; ++col)
                    if (p[row][col] == 'X' && cnt-- == 0) {
                        p[row][col] = 'O';
                        break;
                    }
            }
        }
    }
    return change;
}

bool adjust_cols(char p[][Size]) {
    bool change = false;
    for (int col = 0; col < Size; ++col) {
        int cnt = 0;
        for (int row = 0; row < Size; ++row)
            if (p[row][col] == 'X')
                ++cnt;
        if (cnt % 2 == 0) {
            change = true;
            if (cnt == 0 || (cnt != Size && rand() % 2)) {
                cnt = rand() % (Size - cnt);
                for (int row = 0; row < Size; ++row)
                    if (p[row][col] == 'O' && cnt-- == 0) {
                        p[row][col] = 'X';
                        break;
                    }
            }
            else {
                cnt = rand() % cnt;
                for (int row = 0; row < Size; ++row)
                    if (p[row][col] == 'X' && cnt-- == 0) {
                        p[row][col] = 'O';
                        break;
                    }
            }
        }
    }
    return change;
}

void randomize(char p[][Size]) {
    for (int row = 0; row < Size; ++row)
        for (int col = 0; col < Size; ++col)
            p[row][col] = rand() % 2 ? 'O' : 'X';
    adjust_rows(p);
    while (adjust_cols(p) && adjust_rows(p))
        ;
}

bool check(char p[][Size]) {
    for (int row = 0; row < Size; ++row) {
        int cnt = 0;
        for (int col = 0; col < Size; ++col)
            cnt += p[row][col] == 'X';
        if (cnt % 2 == 0) return false;
    }
    for (int col = 0; col < Size; ++col) {
        int cnt = 0;
        for (int row = 0; row < Size; ++row)
            cnt += p[row][col] == 'X';
        if (cnt % 2 == 0) return false;
    }
    return true;
}

int main() {
    srand(time(0));
    char p[Size][Size];
    for (int i = 0; i < 1000; ++i) {
        randomize(p);
        if (!check(p)) cout << "bad\n";
    }
    display(p); // show the last one
}

Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

const int NROW = 6, NCOL = 6;
const char opt[] = { 'O', 'X' };

//======================================

class Game
{
   char board[NROW][NCOL];
public:
   void setup();
   void display();
};

//---------------------------

void Game::setup()
{
   // Choose first NROW-1 by NCOL-1 randomly
   for ( int i = 0; i < NROW - 1; i++ )
   {
      for ( int j = 0; j < NCOL - 1; j++ ) board[i][j] = opt[ rand() % 2 ];
   }

   // Last column is then fixed to make the row count odd (first NROW-1)
   for ( int i = 0; i < NROW - 1; i++ )
   {
      int sumParity = 0;
      for ( int j = 0; j < NCOL - 1; j++ ) sumParity += ( board[i][j] == opt[1] );
      board[i][NCOL-1] = opt[ 1 - sumParity % 2 ];
   }

   // Last row is then fixed to make the column count odd (all NCOL)
   for ( int j = 0; j < NCOL; j++ )
   {
      int sumParity = 0;
      for ( int i = 0; i < NROW - 1; i++ ) sumParity += ( board[i][j] == opt[1] );
      board[NROW-1][j] = opt[ 1 - sumParity % 2 ];
   }
}

//---------------------------

void Game::display()
{
   cout << "   ";   for ( int j = 0; j < NCOL; j++ ) cout << 1 + j << ' ';   cout << '\n';
   cout << "   ";   for ( int j = 0; j < NCOL; j++ ) cout <<  '-'  << ' ';   cout << '\n';

   for ( int i = 0; i < NROW; i++ ) 
   {
      cout << (char)( 'A' + i ) << "| ";
      for ( int j = 0; j < NCOL; j++ ) cout << board[i][j] << ' ';
      cout << '\n';
   }
   cout << '\n';
}

//======================================

int main()
{
   srand( time( 0 ) ) ;

   Game g;
   g.setup();
   g.display();
}


   1 2 3 4 5 6 
   - - - - - - 
A| O X X X O O 
B| O X O X X O 
C| O X X O X O 
D| X X X X X O 
E| O O X O O O 
F| O X X O O X 
@lastchance, Thanks, for the reply. But, I am not supposed to use arrays. Can you please tell me in my method. That would be more helpful. Thanks again.
Can you please tell me in my method.

No.

That would be more helpful.

To whom?

But, I am not supposed to use arrays.

Why on earth not? 36 items being treated in the same way ... says only one thing to me.
@lastchance, It's much simpler (and faster, and just generally better looking!) than mine. But it's statistics seem a little worse.

Out of 100000 runs, counting rows and cols with 1, 3, or 5 Xs:
             1       3       5
Yours:  224462  750756  224782 
Mine :  290221  618902  290877 

I feel it makes sense that 3 would be more common in general, but mine creates more 1's and 5's.
Hi @dutch,
If there were free choice of elements from 6 then they would be in the ratio 3:10:3 (consider binomial distribution with n=6, p=1/2), giving 0.1875 as the fraction of 1's. However, the last row is fixed once you have the other rows ... so that will change the probabilities slightly (haven't quite worked out how!).

I'll have to work out how your code operates, but there is indeed a statistical difference.
Hey @lastchance,

Are you sure about those calculated probabilities? (I have no idea.) I just wrote a version that places the Xs randomly over the whole board and then checks for the odd-criterion. If it doesn't pass the check, it starts over again. It's pretty much the least efficient method imaginable, but it seems to me that it should be totally random. However, it has the same stats as yours! So I have no idea which stats are more correct.

As for my algorithm in the program above, it places the Xs randomly, then adjust the rows one at a time (by randomly adding or removing an X if it's not odd). Then it goes into a loop, adjusting the columns and, if there's a change, adjusts the rows and, if there's a change, adjusts the columns and ..., until there's no change. It runs faster than one might think (4 to 5 times slower than yours). But maybe that process is queering the stats.

Here's that "totally random" (I think) version:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

const int Size = 6;

int stats[6];

bool check(char p[][Size], bool do_stats = false) {
    for (int row = 0; row < Size; ++row) {
        int cnt = 0;
        for (int col = 0; col < Size; ++col)
            cnt += p[row][col] == 'X';
        if (cnt % 2 == 0) return false;
        if (do_stats) ++stats[cnt];
    }
    for (int col = 0; col < Size; ++col) {
        int cnt = 0;
        for (int row = 0; row < Size; ++row)
            cnt += p[row][col] == 'X';
        if (cnt % 2 == 0) return false;
        if (do_stats) ++stats[cnt];
    }
    return true;
}

void randomize(char p[][Size]) {
    do {
        for (int row = 0; row < Size; ++row)
            for (int col = 0; col < Size; ++col)
                p[row][col] = rand() % 2 ? 'O' : 'X';
    } while (!check(p));
}

int main() {
    srand(time(0));
    char p[Size][Size];
    for (int i = 0; i < 10000; ++i) { // 100000 takes over a minute (for me)
        randomize(p);
        check(p, true);
    }
    for (int i = 1; i < 6; i += 2) cout << stats[i] << ' '; cout << '\n';
}

Last edited on
Are you sure that your lines 32 and 62 (in your first code) aren't creating a slight bias to particular values of cnt? Also, only changing a few selected elements isn't the same as regenerating all 6: you might do better regenerating a whole row if there is an even count.

For the probabilities, the chance of getting x from 6 is, from binomial(6,1/2):
if x=1: 6C1/2^6, or 6/2^6
if x=3: 6C3/2^6, or 20/2^6
if x=5: 6C5/2^6, or 6/2^6
so the ratios are 6:20:6, or 3:10:3
and the relative probabilities are 3/16, 10/16, 3/16

This doesn't apply in the last row, because that would be fixed by the preceding rows, so the final probabilities aren't very easy to work out.

Our editing has just crossed! If your second code gives the same stats as mine then I'm happy. Your second code looks statistically correct. My daughter has just grabbed my computer, so I'm not in a position to do more on it at the moment: dratted university holidays!
Last edited on
Are you sure that your lines 32 and 62 (in your first code) aren't creating a slight bias to particular values of cnt?

I think that's probably the case.
philip1999 wrote:
@lastchance, Thanks, for the reply. But, I am not supposed to use arrays. Can you please tell me in my method. That would be more helpful. Thanks again.


If your professor wants you to create and modify 36 individually named variables like this then he's an idiot. This is not learning how to program. Feel free to tell him/her so and use arrays anyway.
Topic archived. No new replies allowed.