[gbrainy] Fixes #612652
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Fixes #612652
- Date: Fri, 12 Mar 2010 16:20:00 +0000 (UTC)
commit 4fe30f016a79dc14c1166fbc3d2a9d3375b4c123
Author: Jordi Mas <jmas softcatala org>
Date: Fri Mar 12 17:20:34 2010 +0100
Fixes #612652
src/Games/Logic/PuzzleOstracism.cs | 32 +++++++++++++++++++++-----------
1 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/src/Games/Logic/PuzzleOstracism.cs b/src/Games/Logic/PuzzleOstracism.cs
index 9d74022..8cd9714 100644
--- a/src/Games/Logic/PuzzleOstracism.cs
+++ b/src/Games/Logic/PuzzleOstracism.cs
@@ -103,20 +103,30 @@ namespace gbrainy.Games.Logic
break;
case GameType.Numbers:
{
- int num;
- int [] seeds = {25, 26, 28, 30, 21, 18, 21, 22};
+ int num, evens;
+ int [] seeds = {25, 26, 28, 30, 18, 21, 22};
ArrayListIndicesRandom random_seeds = new ArrayListIndicesRandom (seeds.Length);
- random_seeds.Initialize ();
- equations = new string [max_equations];
- for (int i = 0; i < max_equations - 1; i++)
+ // Make sure that one of the numbers only is not even or odd to avoid
+ // this rationale as valid answer too
+ do
{
- num = seeds [random_seeds [i]];
- equations [i] = num.ToString () + (num * num).ToString ();
- }
-
- num = seeds [random_seeds [max_equations - 1]];
- equations [max_equations - 1] = num.ToString () + ((num * num) - 20).ToString ();
+ evens = 0;
+ random_seeds.Initialize ();
+
+ equations = new string [max_equations];
+ for (int i = 0; i < max_equations - 1; i++)
+ {
+ num = seeds [random_seeds [i]];
+ equations [i] = num.ToString () + (num * num).ToString ();
+ if (num % 2 == 0) evens++;
+ }
+ num = seeds [random_seeds [max_equations - 1]];
+ equations [max_equations - 1] = num.ToString () + ((num * num) - 20).ToString ();
+
+ if (num % 2 == 0) evens++;
+
+ } while (evens <= 1 || max_equations - evens <= 1 /* odds */);
break;
}
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]