X-Git-Url: https://harishankar.org/repos/?p=getaclue.git;a=blobdiff_plain;f=crosswordpuzzle.py;fp=crosswordpuzzle.py;h=a02f469d21521818f2c4028966049cf8bbe0c81e;hp=3c0ab4e4cdb089008a11216a413a146c48f9d6f1;hb=9e110bd4d38e7bd3d78f1cda65244e6b036f32dd;hpb=33acaf6d4771fb9e0befd81f3366b841f7bfbb10 diff --git a/crosswordpuzzle.py b/crosswordpuzzle.py index 3c0ab4e..a02f469 100644 --- a/crosswordpuzzle.py +++ b/crosswordpuzzle.py @@ -520,3 +520,39 @@ class CrosswordPuzzle: self.data[row][col].reset () self.frozen_grid = False + + # remove an across word at position + def remove_word_across (self, row, col): + # if grid is frozen don't allow removal of word + if self.frozen_grid is True: + raise FrozenGridException + + word, brow, bcol, l = self.get_word_across (row, col) + + # traverse from the beginning to end of the word and erase it + c = bcol + while True: + if self.data[brow][c].occupied_across is True: + self.data[brow][c].clear_across_data () + else: + break + c += 1 + + # remove a down word at position + def remove_word_down (self, row, col): + # if grid is frozen don't allow removal of word + if self.frozen_grid is True: + raise FrozenGridException + + word, brow, bcol, l = self.get_word_down (row, col) + # traverse from the beginn to end of the word and erase it + r = brow + while True: + if self.data[r][bcol].occupied_down is True: + self.data[r][bcol].clear_down_data () + else: + break + r += 1 + + +