[gnome-sudoku] Fix sort syntax error
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sudoku] Fix sort syntax error
- Date: Fri, 8 Nov 2013 04:21:25 +0000 (UTC)
commit 93f53fb4eab1451b6b0b002611c539da5c0d76ab
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu Nov 7 22:17:26 2013 -0600
Fix sort syntax error
I don't dare try to determine what this lambda is trying to do, so let's
use a sledgehammer to make it work. This requires a Python version bump,
but we haven't released since the port to Python 3, so that's hardly a
big deal.
configure.ac | 2 +-
src/lib/sudoku.py | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7de6ac9..a53891c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ GNOME_MAINTAINER_MODE_DEFINES
GLIB_GSETTINGS
-AM_PATH_PYTHON([3.0],,AC_MSG_ERROR([Python not found]))
+AM_PATH_PYTHON([3.2],,AC_MSG_ERROR([Python not found]))
dnl ###########################################################################
dnl Dependencies
diff --git a/src/lib/sudoku.py b/src/lib/sudoku.py
index 394c1d1..9170537 100644
--- a/src/lib/sudoku.py
+++ b/src/lib/sudoku.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import functools
import random
import math
import re
@@ -445,8 +446,9 @@ class SudokuSolver (SudokuGrid):
print('Solved!')
return True
# otherwise, find the possibility with the least possibilities
- poss.sort(lambda a, b: len(a[1]) > len(b[1]) and 1 or len(a[1]) < len(b[1]) and -1 or \
- a[0] > b[0] and 1 or a[1] < b[1] and -1 or 0)
+ poss.sort(key=functools.cmp_to_key(lambda a, b: len(a[1]) > len(b[1]) \
+ and 1 or len(a[1]) < len(b[1]) and -1 or \
+ a[0] > b[0] and 1 or a[1] < b[1] and -1 or 0))
least = poss[0]
# remove anything we've already guessed
possible_values = least[1] - self.guesses.guesses_for_coord(*least[0])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]