Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Challenge: Nearest Palindromic Number

by Limbic~Region (Chancellor)
on Feb 02, 2005 at 19:34 UTC ( [id://427390]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Challenge: Nearest Palindromic Number
in thread Challenge: Nearest Palindromic Number

halley,
Forgive my hasty initial response. I knew your method was flawed but gave a bad test case. 999 and 1001 are both valid when the input is 1000. Your method fails on the updated test case though 1085. The correct answer should be 1111.

Cheers - L~R

Replies are listed 'Best First'.
Re^5: Challenge: Nearest Palindromic Number
by halley (Prior) on Feb 02, 2005 at 19:45 UTC
    Which is why I initially mentioned that incrementing would be easy, to find the alternative. If the input isn't already palindromic, you have to find two palindromic alternatives. Roy Johnson wrote the code I foresaw: '10##'++ would be '1111'.

    --
    [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://427390]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found