On 12/09/2013 02:42 PM, Rafael Knuth wrote:
Tu sum it up (aha!): you algorithm is the right and only one

No, it's not the only one. It's certainly the most obvious one, but there is
also the pure numbers approach pointed out by me and Alan.

So far I received 7 different alternative suggestions, both pure
numbers & mixed int/str approach, which is great because I learn far
more than I would expect given that the subject discussed is a tiny,
little string to digit sum program. I play around with each piece of
code I receive, I take notes and I memorize as much as possible for
upcoming challenges. Although it's sometimes confusing to me as a
novice to programming, I actually like the idea that one and the same
task can be solved in different ways in Python (it spurs my
creativity). And, again: Thank you all for your elaborate and
extremely helpful responses!

It is indeed a tiny little piece of code, but an interesting one, and also with fundaments of computing! Think at this: * all programming languages have to decode numerals (number written representations) into numbers (or rather their representations in memory) * sum is also a basic algo, and the archetype of a whole series of "aggregating" algos, that turn a set of elements into a single element by operating on each one (and there are tons of discussions on the proper way to do that)

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to