Show remaining numbers hack for gnome-sudoku



Hi!  I find myself keeping a spare gedit window open to track the
numbers that I've finished dealing with.

This patch causes these to get displayed in the status bar
unconditionally.  This patch isn't final, I still want to make it
optional, etc.  But before I go and remind myself how gtk works, I
wanted to get feedback on it.

I'm not subscribe to the list, please keep me on the to/cc list.

2006-12-10  Jeff Bailey  <jbailey raspberryginger com>

       * src/lib/gnome_sudoku.py: Add remaining numbers to tot_string

       * src/lib/sudoku.py (SudokuGrid): Keep a running total of
numbers in use.

--
Jeff Bailey - http://www.raspberryginger.com/jbailey/
Index: gnome_sudoku.py
===================================================================
RCS file: /cvs/gnome/gnome-games/gnome-sudoku/src/lib/gnome_sudoku.py,v
retrieving revision 1.10
diff -u -p -r1.10 gnome_sudoku.py
--- gnome_sudoku.py	28 Nov 2006 20:15:59 -0000	1.10
+++ gnome_sudoku.py	10 Dec 2006 18:46:06 -0000
@@ -665,6 +665,10 @@ class UI (gconf_wrapper.GConfWrapper):
         tot_string = _("Playing ") + self.current_puzzle_name
         tot_string += " - " + "%s"%self.current_puzzle_diff.value_string()
         tot_string += " " + "(%1.2f)"%self.current_puzzle_diff.value
+        tot_string += " " + _("Remaining Numbers") + ": "
+        for n in range(1,10):
+            if self.gsd.grid.number_count[n] != 9:
+                tot_string += "%d"%n + " "
         #if self.timer.tot_time or self.timer.tot_time_complete:
         #    time_string = _("%s (%s active)")%(
         #        self.timer.total_time_string(),
Index: sudoku.py
===================================================================
RCS file: /cvs/gnome/gnome-games/gnome-sudoku/src/lib/sudoku.py,v
retrieving revision 1.2
diff -u -p -r1.2 sudoku.py
--- sudoku.py	27 Oct 2006 21:50:20 -0000	1.2
+++ sudoku.py	10 Dec 2006 18:46:06 -0000
@@ -74,6 +74,10 @@ class SudokuGrid:
         self.box_by_coords = {}
         self.box_coords = {}
         self.calculate_box_coords() # sets box_coords and box_by_coords
+        # Running total of how many of each number.
+        self.number_count = {}
+        for n in range(1,10):
+            self.number_count[n] = 0
         self.row_coords = {}
         for n,row in enumerate([[(x,y) for x in range(self.group_size)] for y in range(self.group_size)]):
             self.row_coords[n]=row
@@ -129,6 +133,7 @@ class SudokuGrid:
         self.cols[x].add(val)
         self.boxes[box].add(val)
         self._set_(x,y,val)
+        self.number_count[val] += 1
 
     def remove (self, x, y):
         val = self._get_(x,y)
@@ -136,6 +141,7 @@ class SudokuGrid:
         self.cols[x].remove(val)
         self.boxes[self.box_by_coords[(x,y)]].remove(val)
         self._set_(x,y,0)
+        self.number_count[val] -= 1
 
     def _get_ (self, x, y): return self.grid[y][x]
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]