Assign 0 to K numbers to all K colors, such that color -> color_tag (a number b/w [0,K-1]). code[k] = {0,2,..,k-1} foreach (permutation from all possible-permuations of code[]) sort balls[] on the basis of code[color_tag] print balls[]
________________________________ From: ankur aggarwal <ankur.mast....@gmail.com> To: lets-talk-g...@googlegroups.com; algogeeks@googlegroups.com Sent: Sunday, 6 September, 2009 1:36:01 PM Subject: [algogeeks] n balls having k colors You have N balls having one of K colors. Arrange them into groups of same colors. e.g. RRRRRRGRG can be arranged as RRRRRRRGG (Answer) GGRRRRRRR See the Web's breaking stories, chosen by people like you. Check out Yahoo! Buzz. http://in.buzz.yahoo.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---