[buug] substring of integers problem

Ian Zimmerman itz at buug.org
Sat Mar 12 22:59:51 PST 2011

Michael> Not quite a "perfect" solution (e.g. it can hit some
Michael> overflow/underflow/conversion errors in some cases - including
Michael> not detecting them in some cases), but ...  I also realized
Michael> later I could've coded it to solve from left to right, rather
Michael> than right to left ... and could thus possibly not
Michael> process/parse the arguments (input integers) until they're
Michael> needed, and thus also not need to store them all.  Most of the
Michael> "real work" happens within about 21 lines of body of loop.  The
Michael> rest is mostly just initialization and final output.  It needs
Michael> more comments :-) ... I had a bunch, but stripped most of them
Michael> out ... they'd not kept up to how the code had "evolved".

Yes, I think that's correct (allowing for my rusty Perl).

I found that this is quite a famous problem, it's discussed in 2 books I
got this month :-)  It's also in wikipedia:


Ian Zimmerman <itz at buug.org>
gpg public key: 1024D/C6FF61AD 
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
Ham is for reading, not for eating.

More information about the buug mailing list