Created
November 2, 2015 10:35
-
-
Save nbarnold01/07f1f162a1526da4a5df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
// insert code here... | |
int numOfStones = 0; | |
scanf("%d", &numOfStones); | |
NSMutableArray *stoneList = [NSMutableArray arrayWithCapacity:numOfStones]; | |
for (int i=0; i<numOfStones; i++){ | |
char composition[100]; | |
scanf("%100s",composition); | |
NSString *str = [NSString stringWithCString:composition encoding:NSUTF8StringEncoding]; | |
NSMutableSet *set = [NSMutableSet setWithCapacity:[str length]]; | |
for (int i = 0; i< str.length; i++){ | |
NSString *character = [str substringWithRange:NSMakeRange(i,1)]; | |
[set addObject:character]; | |
} | |
[stoneList addObject:set]; | |
} | |
NSMutableSet *commenElements = [stoneList firstObject]; | |
for (NSSet *set in stoneList){ | |
[commenElements intersectSet:set]; | |
} | |
printf("%lu",(unsigned long)[commenElements count]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment