Simple solution for 2nd challenge


#1

Here is my solution, works properly, prints only one pair(name from proper names and regular word from words file)
Output example:
2014-01-14 23:25:50.126 Names[4268:303] Al/al
2014-01-14 23:25:50.234 Names[4268:303] Alan/alan
2014-01-14 23:25:50.668 Names[4268:303] Alf/alf
2014-01-14 23:25:50.778 Names[4268:303] Alison/alison
2014-01-14 23:25:50.834 Names[4268:303] Allan/allan
2014-01-14 23:25:51.159 Names[4268:303] Ami/ami
2014-01-14 23:25:51.272 Names[4268:303] Amir/amir
2014-01-14 23:25:51.383 Names[4268:303] Amy/amy
2014-01-14 23:25:52.098 Names[4268:303] Ann/ann
2014-01-14 23:25:52.151 Names[4268:303] Anna/anna
2014-01-14 23:25:52.685 Names[4268:303] Ariel/ariel
2014-01-14 23:25:52.899 Names[4268:303] Art/art

[code]#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    
    NSString *stringName = [NSString stringWithContentsOfFile:@"/usr/share/dict/propernames"
                                                     encoding:NSUTF8StringEncoding
                                                        error:NULL];
    
    NSArray *names = [stringName componentsSeparatedByString:@"\n"];
    
    
    NSString *stringWords = [NSString stringWithContentsOfFile:@"/usr/share/dict/words"
                                                      encoding:NSUTF8StringEncoding
                                                         error:NULL];
    
    NSArray *words = [stringWords componentsSeparatedByString:@"\n"];
    
    for(NSString *n in names)
    {
        for(NSString *w in words)
        {
            NSComparisonResult compResult = [w localizedCaseInsensitiveCompare:n];
            if (compResult == NSOrderedSame)
            {
                NSRange r = [n rangeOfString:w];
                if (r.location == NSNotFound)
                {
                    NSLog(@"%@/%@", n, w);
                }
            }
        }
    }
    
    
    
}
return 0;

}

[/code]