Get a string @ "ABSDFASDFSDFDSAFSD ..." all permutations length! /(same item)! * (same Item)! )-(int) numberofstring: (nsstring*) str //nsstring *str [email protected] "adfsadfasdfasdfsadfsdaxfgghfgjtyy"; int sumlength = str.length;//The number of all characters nsstring *mystr = @ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Nsmutablearray *samecharnumberarr = [Nsmutablearray array]; for (int i=0; i<mystr.length; i++) { NSString *charstr = [MyStr substringfromindex:i]; int number = [[str componentsseparatedbystring:charstr]count]-1; if (number>1) { [Samecharnumberarr addobject:[nsnumber numberwithint:number]; } } int textsum=1; For (NSNumber *nub in Samecharnumberarr) { textsum *= FAC ([nub intvalue]); } int numberofstr = FAC (sumlength)/textsum; NSLog (@ "The number of all permutations is%d", numberofstr); return NUMBEROFSTR;} int FAC (int n) { int rs=1; while (n>1) rs*=n--; return RS;}
Get a string @ "ABSDFASDFSDFDSAFSD ..." in all permutations