Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9101911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:15:04+00:00 2026-06-17T01:15:04+00:00

hi i want to display string combination on nslog like this format abc bca

  • 0

hi i want to display string combination on nslog like this format

abc
bca
acb
and so on 

but
my program show me it like this format
permutations =

 (
        (
        c,
        b,
        a
    ),
        (
        b,
        c,
        a
    ),
        (
        c,
        a,
        b
    ),
        (
        a,
        c,
        b
    ),
        (
        b,
        a,
        c
    ),
        (
        a,
        b,
        c
    )
)

this is the code i am using

NSArray *array = [NSArray arrayWithObjects:@"a",@"b",@"c",nil];

NSMutableArray *permutations = nil;

int i = 0;
for (i = 0; i < array.count ; i++){

    if (!permutations){
        permutations = [NSMutableArray array];
        for (NSString *character in array){
            [permutations addObject:[NSArray arrayWithObject:character]];


        }

    } else {

        //make copy of permutations array and clean og array
        NSMutableArray *aCopy = [permutations copy] ;
        [permutations removeAllObjects];

        for (NSString *character in array){

            //loop through the copy
            for (NSArray *oldArray in aCopy){

                //check if old string contains looping char..
                if ([oldArray containsObject:character] == NO){

                    //update array
                    NSMutableArray *newArray = [NSMutableArray arrayWithArray:oldArray];
                    [newArray addObject:character];

                    //add to permutations
                    [permutations addObject:newArray];

                }

            }
        }            
    }



}

NSLog(@"permutations = \n %@",permutations);
}

kindly tell me how i can display it in my require format

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:15:06+00:00Added an answer on June 17, 2026 at 1:15 am

    Try this way :

    NSString *stringPermuted=[NSString new];
    for (NSArray *array in permutations) {
        for (NSString *string in array) {
            stringPermuted=[stringPermuted stringByAppendingFormat:@"%@",string];
        }
        stringPermuted=[stringPermuted stringByAppendingFormat:@"\n"];
    }
    
    NSLog(@"permutations=\n%@",stringPermuted);
    

    Another Way :

    NSString *stringPermuted=[NSString new];
    for (NSArray *array in permutations) {
        stringPermuted=[stringPermuted stringByAppendingFormat:@"%@\n",[array componentsJoinedByString:@""]];
    }
    NSLog(@"permutations=\n%@",stringPermuted);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display different string array elements like this: Clubs 1 Hearts Ace
I want to display strings like &amp; in an HTML page, but it is
I am just learning PHP . i want to display string like 32th meet
I want to display a colored string of text in the minibuffer, but when
I want to display one String which is comes from SQLC. String is Like
String=880814 now i want to display this string as 88/08/14 by either means either
I want to display a string in a message box with a following format:
I want to display a string with leading whitespace in a Textview. But what
I want to display the string Hello in the TextBlock. If the Culture is
I am using PHP, i want to display a string which comes as title

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.