hehe :) i was talking about Shahansad's code, not mine :). Mine was just an on the spot generation nothing else... it can easily be reduced down to your code...
2011/12/22 Jérémie Marguerie <[email protected]> > 2011/12/21 Vikram Gaur <[email protected]>: > > shorter and better i think :) > > @Vikram Gaur: > Your code is doing a lot of useless computation. > You need neither to compute the length of the string nor to copy it. > So I'm not sure it's really "better". > > > Starting back at my code, you may optimize a bit more : > > int compute(char* s) > { > int n = 0; > char p = s; > for (; *s; s++) > n += *s; > n -= '0' * ((int)s - (int)p) / sizeof(*s); > return (n); > } > > And you seem to like the main function so... > > int main(int argc, char** argv) > { > if (argc != 2) > return (1); > > printf("%d\n", compute(argv[1])); > return (0); > } > > Happy? :) > > -- > Jérémie MARGUERIE > Student at EPITA, France > "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. > > -- Thanks and Regards Vikram Gaur Software Engineer Samsung Engineering Labs, Noida +91-9818540102 "Since human beings themselves are not fully debugged yet, there will be bugs in your code no matter what you do." - Chris Mason -- 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.
