hashset difference def difference(selfother)result hashset(selfresult difference_update(otherreturn result the difference method is implemented using the difference_update method on the result hashset notice that new set is returned the hash set referenced by self is not updated the code is simple and it has the added benefit that if difference_update is correctly writtenso will this method programmers should always avoid writing duplicate code when possible and difference and difference_udpate are nearly identical except that the difference method performs the difference on newly constructed set instead of the set that self references solving sudoku using set or hashset datatypewe now have the tools to solve most sudoku puzzles puzzle can be read from file where known values are represented by their digit and unknown values are ' as in the puzzle below reading the dateable can be done line at time splitting the line will provide string with each known and unknown value as separate item in the list when an is encountered set containing all values - can be constructedjust as you would if solving sudoku by hand when known value is found set with the known number in it can be constructed the sets are added to two-dimensional matrix the matrix is list of lists so reading line corresponds to reading row of the matrix each line becomes list of sets each list of sets is added to list we'll call the matrix somatrix[row][colis one set within the sudoku puzzle there are sets within sudoku puzzle howevereach set is member of three groupsthe rowthe columnand the square in which it resides the rules presented in the sudoku puzzle description above each deal with reducing set within one of these groups after reading the input from the file and forming the matrix with the sets groups are formed by creating list of groups shallow copy of each row is first appended to the list of groups shallow copy means that each of the sets is the same set that was created when the puzzle was read this copy belongs to 'acha