oops i mean the rhs :) On 22 December 2011 18:21, Shahansad K.P <[email protected]> wrote:
> Oh.. i read the question wrong first time. you dont need the n*=10; line. > > > > n -= '0' * ((int)s - (int)p) / sizeof(*s); > > Is unsafe. Left hand side can gorw very fast and would limit the size of > string on which the function can run. > > > > 2011/12/22 Jérémie Marguerie <[email protected]> > >> 2011/12/21 Luke Pebody <[email protected]>: >> > For sheer expressiveness reasons, I would choose something like Python's >> > >> >> print sum([int(char) for char in "142857"]) >> > 27 >> >> But the point gere is to find a fast algorithm, you need a low level >> language to do so :) >> >> Thinkinf of that, if we consider the memory block containing the >> string to be 4-bytes aligned, we can process 4 integers in the loop >> and avoid a jump between each byte and only jump each four bytes. >> >> -- >> Jérémie MARGUERIE >> Étudiant à l'EPITA, ing2 >> "Many snake oil algorithms claim unbreakability by claiming to be a OTP. >> Pseudo-OTPs give pseudo-security" -- Peter Gutmann >> >> -- >> 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]. >> For more options, visit this group at >> http://groups.google.com/group/google-code?hl=en. >> >> > -- 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]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
