add without carry
sjmachin at lexicon.net
Fri Sep 15 16:50:24 CEST 2006
> Jon Ribbens wrote:
> > In article <450a7dec$0$14661$626a54ce at news.free.fr>, Bruno Desthuilliers wrote:
> > >
> > > No need to think too long to come up with the most possibly Q&D solution:
> > >
> > > res = int(str(5 + 7)[-1])
> > Am I missing something subtle in the question or is there some reason
> > that nobody has posted the correct solution:
> > (a + b) % 10
> > ?
> You're not missing anything. That's the obvious solution. We're just
> celebrating our non-Dutchness at the moment.
> >>> def bound(value, maxBound):
> ... while value > maxBound:
Does non-Dutchness require or permit bugs like > instead of >= or are
you merely having a braino?
> ... value -= maxBound
> ... return value
> >>> bound(5 + 6, 10)
> >>> bound(8 + 7, 10)
> See? I'm definitely not Dutch.
More information about the Python-list