On Wednesday, June 15, 2016 at 1:14:34 AM UTC+4:30, Robert Stacey wrote: > On Tuesday, 14 June 2016 18:06:32 UTC+1, Morteza Keshtkaran wrote: > > I will be appreciate if you can tell me if the code is correct or not. > > > > Thanks. > > Your solve code doesn't work properly once there are 8 or more players. > Your first for loop works and is: > for (i = 0; i < 8; i += 2) > This runs 4 times putting results in 0, 2, 4, 6 > > The next loop is: > for (i = 0; i < 4; i += 4) > This only runs once checking 0 vs 2. 4 vs 6 is left unchecked, giving a win > to 4 no matter what.
Dear Robert, Thanks for your reply. You are right. The end of the interval must be kept unchanged, and I didn't care about its change during the loop (A bad mistake). I only needed to change my while statement to while(ch!=p) and to not change the ch during the run. Best regards, Morteza -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/78d1414e-cc4b-4bdb-b09d-032a279f31ac%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
