LoginSignup
4
3

More than 5 years have passed since last update.

ズンドコキヨシ with Objective-C

Posted at

Objective-Cで書いてみた

    NSString *zun = @"ズン";
    NSString *doko = @"ドコ";
    NSArray *expected = @[zun,zun,zun,zun,doko];
    NSMutableArray *list = [NSMutableArray array];
    NSUInteger loc = 0;
    NSUInteger len = 0;

    while (![[list subarrayWithRange:NSMakeRange(loc, len)] isEqualToArray:expected]) {
        int val = arc4random_uniform(2);
        switch (val) {
            case 0:
                NSLog(@"%@",zun);
                [list addObject:zun];
                break;
            case 1:
                NSLog(@"%@",doko);
                [list addObject:doko];
            default:
                break;
        }

        len++;
        len = len > expected.count ? expected.count : len;
        loc = list.count > expected.count - 1 ? list.count - expected.count : 0;
    };

    NSLog(@"キ・ヨ・シ!");

こういうの書いてみるとSwiftの便利さが身に染みますね。。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3