From 57a133e213f8909fc4b596fbd3b73017abfa7baa Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 28 May 2008 16:33:25 -0400 Subject: [PATCH] Algorithm updates. We no longer crash/get raise:'d but we miss words. * Source/AppController.m: (-[findWords:]) --- Source/AppController.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/AppController.m b/Source/AppController.m index 45a9b6a..bb04e17 100644 --- a/Source/AppController.m +++ b/Source/AppController.m @@ -65,7 +65,7 @@ [temp release]; NSRange wildRange = [tiles rangeOfString:@"?" options:NSBackwardsSearch]; - int numWild = wildRange.length + wildRange.location; + int numWild = (wildRange.location == NSNotFound ? 0 : wildRange.length + wildRange.location); int length = [tiles length]; for (int i = 0; i < [dictionary count]; i++) @@ -79,7 +79,8 @@ } BOOL add = YES; - for (int j = 0, k = numWild; k < length; j++, k++) + int j, k; + for (j = 0, k = numWild; k < length && j < [word length]; j++, k++) { if ([[word alphagram] characterAtIndex:j] != [tiles characterAtIndex:k]) { @@ -96,6 +97,11 @@ } } + if (j < [word length] && j + wildCounter < [word length]) + { + add = NO; + } + if (add) { [wordlist addObject:word]; -- 2.43.5