Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,35 @@
#import <Foundation/Foundation.h>
-(NSString*)lookAndSay:(NSString *)word{
if (!word) {
return nil;
}
NSMutableString *result = [NSMutableString new];
char repeat = [word characterAtIndex:0];
int times = 1;
word = [NSString stringWithFormat:@"%@ ",[word substringFromIndex:1] ];
for (NSInteger index = 0; index < word.length; index++) {
char actual = [word characterAtIndex:index];
if (actual != repeat) {
[result appendFormat:@"%d%c", times, repeat];
times = 1;
repeat = actual;
} else {
times ++;
}
}
return [result copy];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSString *num = @"1";
for (int i=1;i<=10;i++) {
NSLog(@"%@", num);
num = [self lookAndSay:num];
}
}