Cases:
The number of nonwhitespace characters in self.givenPuzzle
is not exactly
BOARD_L
. See Section 7.2.1, “Case 1: Wrong number of nonwhitespace characters”.
The character count is correct, but at least one of
the nonwhitespace characters is not a digit or
"."
. See Section 7.2.2, “Case 2: Invalid characters”.
self.givenPuzzle
contains
exactly BOARD_L
nonwhitespace characters, and each is a digit or
"."
. See Section 7.2.3, “Case 3: Valid puzzle”.
The case assumption is that the number of
nonwhitespace characters in self.givenPuzzle
is not BOARD_L
.
# 1  # [ charList := a list whose elements are the # nonwhitespace characters of self.givenPuzzle in # the same order ]
charList

list of nonwhitespace characters from
self.givenPuzzle

# 2  if len(charList) != BOARD_L: raise ValueError, ( "Puzzle has %d nonblank " "characters; it should have exactly %d." % (len(charList), BOARD_L) )
By case assumption, the length of charList
is not BOARD_L
, so we raise ValueError
. The overall intended function:
[ self.givenPuzzle is a string > if self.givenPuzzle is a sudoku puzzle > ... else > raise ValueError ]
The case assumptions are: self.givenPuzzle
contains exactly
BOARD_L
nonwhitespace
characters, but at least one of those characters is not
a digit or "."
.
# 1  # [ charList := a list whose elements are the # nonwhitespace characters of self.givenPuzzle in # the same order ]
charList

list of nonwhitespace characters from
self.givenPuzzle

# 2  if len(charList) != BOARD_L: raise ValueError, ( "Puzzle has %d nonblank " "characters; it should have exactly %d." % (len(charList), BOARD_L) )
By case assumption, the number of nonwhitespace
characters is exactly BOARD_L
,
so we proceed to the next prime. The trace table is
unchanged.
# 3  # [ if each element of charList is either "." or in # the interval ["1", "9"] > # result := a list of integers corresponding to the # elements of charList consisting of # integer 0 where the value is "." and # int(c) for other values # else > # raise ValueError ]
By case assumption, at least one nonwhitespace
character of self.givenPuzzle
is neither a digit nor "."
, so
we raise ValueError
. Here is
the overall intended function:
[ self.givenPuzzle is a string > if self.givenPuzzle is a valid sudoku puzzle > ... else > raise ValueError ]
Case assumptions: the number of nonwhitespace
characters in self.givenPuzzle
is exactly BOARD_L
; and each
of those characters is either a digit or "."
.
# 1  # [ charList := a list whose elements are the # nonwhitespace characters of self.givenPuzzle in # the same order ]
charList

list of nonwhitespace characters from
self.givenPuzzle

# 2  if len(charList) != BOARD_L: raise ValueError, ( "Puzzle has %d nonblank " "characters; it should have exactly %d." % (len(charList), BOARD_L) )
By case assumption, the number of nonwhitespace
characters is exactly BOARD_L
,
so we proceed to the next prime. The trace table is
unchanged.
# 3  # [ if each element of charList is either "." or in # the interval ["1", "9"] > # result := a list of integers corresponding to the # elements of charList consisting of integer 0 # where the value is "." and an integer in [1,9] # where the value is a digit # else > # raise ValueError ]
charList

list of nonwhitespace characters from
self.givenPuzzle

result

a list of values, each 0 if the corresponding
nonwhitespace character of self.givenPuzzle is "." , or an integer in [1,9] if
the corresponding nonwhitespace character of
self.givenPuzzle is a digit

# 4  return result
This returns a list of values, each 0 if the
corresponding nonwhitespace character of self.givenPuzzle
is "."
, or an integer in [1,9] if the
corresponding nonwhitespace character of self.givenPuzzle
is a digit.
Compare this to the overall intended function:
[ self.givenPuzzle is a string > if self.givenPuzzle is a sudoku puzzle > self.__board := a list of BOARD_L integers representing that puzzle else > ... ]