From 2f60f486cfbf0ed0b53a55da9a318f6e8deb7d0d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 5 Jun 2008 15:07:14 -0400 Subject: [PATCH] Finished the algorithm for finding words * Source/AppController.m: (findWords:) --- Source/AppController.m | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/AppController.m b/Source/AppController.m index 30653c0..4b9800f 100644 --- a/Source/AppController.m +++ b/Source/AppController.m @@ -78,10 +78,17 @@ } BOOL add = YES; - int j, k; - for (j = 0, k = numWild; k < length && j < [word length]; j++, k++) + int j = 0, k = numWild; + while (k < length && j < [word length]) { - if ([[word alphagram] characterAtIndex:j] != [tiles characterAtIndex:k]) + unichar charW = [[word alphagram] characterAtIndex:j]; + unichar charT = [tiles characterAtIndex:k]; + if (charW == charT) + { + j++; + k++; + } + else if (charW < charT) { wildCounter--; if (wildCounter < 0) @@ -91,9 +98,14 @@ } else { - continue; + j++; + k++; } } + else + { + k++; + } } if (j < [word length] && j + wildCounter < [word length]) -- 2.22.5