Looks similar to set partitioning
Try something like this roughly
int len = length(N); // for your case of N = 2034, this will be 4
int x; // x is number of commas in one set of your aswer
for (x = 0; x < len; x++) {
place the comma in x out of (len-1) possible places; /// This will give you
(len-1) permutation
Handle special cases for zero
}
On Friday, 16 November 2012 16:58:35 UTC+5:30, Amir wrote:
>
> Hi,
>
> In previous email I posed my questions regarding computing sub-sequences
> and operators.
> But have not received appropriate answer.
>
> Therefore, I write another question.
>
> I need to generate digit sequences from a number.
> Give N= 2034
> int[] s = reverseDigit(N); // s[] = {2, 0, 3, 4};
> Now, I need to generate the following set numbers
> S1 = {2, 0, 3, 4}
> s2 = {2, 0, 34}
> s3 = {2, 034} // not acceptable
> s4 = {20, 3, 4}
> s5 = {20, 34}
> s6 = {203, 4}
> s7 = {2034}
>
> I tried, but could not write the code.
>
> Thank you very much for assistance.
> -- Amir
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/google-code/-/fdadk3PikkgJ.
For more options, visit https://groups.google.com/groups/opt_out.