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 <[email protected]>
To: [email protected]; [email protected]
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&#39;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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to