Post Reply 
HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
09-16-2022, 01:25 PM
Post: #43
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL
(09-15-2022 03:01 PM)Werner Wrote:  
(09-15-2022 02:22 PM)David Hayden Wrote:  Has anyone determined if the check for iterations>50 is necessary? In other words, are there any numbers that hit 50 iterations before overflowing 10 or 12 digits?

Adding a number to its reverse doubles the number, 'on average' ;-)
2^50 > 1e15, so I guess not.

Cheers, Werner
On the other hand, the worst case is a number that starts with 9 and ends with 1, which grows by about 11%. (10/9)^50 is only 194.

I ran a C++ program to search for numbers that get 50+ iterations first and it didn't find any in the first few million.

Based on the C++ program, I considered removing that check from my program, but decided against it. I figured that the only way I would beat Roger Hill was if he missed one of these edge cases.

Dave
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HHC 2022 - Programming Contest - no responses until after 6am Monday 6am CENTRAL - David Hayden - 09-16-2022 01:25 PM



User(s) browsing this thread: 1 Guest(s)