in reply to Challenge: Nearest Palindromic Number

I don't think this yields an elegant solution. At least, not one that is anywhere faster than the brute force one.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

  • Comment on Re: Challenge: Nearest Palindromic Number

Replies are listed 'Best First'.
Re^2: Challenge: Nearest Palindromic Number
by herveus (Prior) on Feb 02, 2005 at 20:08 UTC
    Howdy!

    The problem is to find which of the two nearest palindromic numbers is closest. If missing one of the pair when both are equally distant is acceptable (as in the problem as laid out here), then slinging strings is both fast and elegant, given that palindromicity is a string property, not a numeric property.

    The solution Roy_Johnson got into print before I could (and which is a refinement of halley's, attacks the given problem about as elegantly as you can.

    yours,
    Michael