Another thought: let N be the string recording the beads starting at any arbitrary position ( since it's circular ), then we are basically looking for the length of the longest sequence matching the pattern:
(w*r(r*w*)*w*b(b*w*)*w*) | (w*b(b*w*)*w*r(r*w*)*w*) (where * is Kleene Closure, | is logical or, and parenthesis groups expressions) in the string NN ( concatenated to handle the circular nature of the necklace ), and if the length is greater than the length of the necklace, the answer is the length of the necklace. I have written a program that scan through the necklace twice and parse the pattern the hard way. It seems to work for the 1 test case they have on the site but I'd need more tests to be confident about the solution. On Jun 5, 7:06 am, maverick gugu <[email protected]> wrote: > Hi, > Sorry, I'm stuck again. almost had the solution. > > While we scan through the array once and divide them into regions: > > Are we supposed to have over lapping regions, because when we consider a 'w' > it can be included in either of the regions right? > > -Maverick -- You received this message because you are subscribed to the Google Groups "google-codejam" 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/google-code?hl=en.
