Skip to content

Instantly share code, notes, and snippets.

@mayoff
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayoff/e2c5be3e2262fbac8c03 to your computer and use it in GitHub Desktop.
Save mayoff/e2c5be3e2262fbac8c03 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSMutableArray *myNums = [NSMutableArray array];
NSString *inputs = @"392 392 339 394 393 394 339";
for (NSString *word in [inputs componentsSeparatedByString:@" "]) {
NSNumber *n = [NSDecimalNumber decimalNumberWithString:word];
[myNums addObject:n];
}
NSNumber *avg = [myNums valueForKeyPath:@"@avg.self"];
int64_t result = avg.longLongValue;
if (result < 100) {
NSLog(@"result < 100: %lld", result);
} else {
NSLog(@"result >= 100: %lld", result);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment