# Thread: Beginner Programming Challenge #10

1. ## Beginner Programming Challenge #10

Welcome to the 10th programming challenge, sponsored by The Ubuntu Beginners Team Development Focus Group. I have been tasked with coming up with this challenge by virtue of 'winning' programming challenge #9.

background
:
-----
I have a connection with Lychrel numbers so I wanted to make this challenge something in relation to those.

lychrel numbers:
-----
A Lychrel number is a natural number which cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. The name "Lychrel" was coined by Wade VanLandingham; a rough anagram of his girlfriend's name Cheryl.

example: The reverse and add process produces the sum of a number and the number formed by reversing the order of its digits.eg. 56 + 65 = 121, 125 + 521 = 646, 9999 + 9999 = 19998

-----
Find all the Lychrel candidate numbers below 10,000

bonus points
:
-----
Find all the Lychrel seed numbers below 10,000

Disqualified Entries:
-----
Any overly obfuscated code will be immediately disqualified without account for programmers skill. Please remember that these challenges are for beginners and therefore the code should be easily readable and well commented.

Any non-beginner entries will not be judged. Please use common sense when posting code examples. Please do not give beginners a copy paste solution before they have had a chance to try this for themselves.

Assistance:
-----
If you require any help with this challenge please do not hesitate to come and chat to the development focus group. We have a channel on irc.freenode.net #ubuntu-beginners-dev

----------
OK -- time for you all to be rockstars!

2. ## Re: Beginner Programming Challenge #10

Looks great! Let's see some entries, people!

3. ## Re: Beginner Programming Challenge #10

I'm not sure I'd call this a "beginner" challenge...

4. ## Re: Beginner Programming Challenge #10

Originally Posted by schauerlich
I'm not sure I'd call this a "beginner" challenge...
+1

Is 196 a Lychrel number? Nobody knows, it hasn't been proven yet. So 196 would be a Lychrel candidate number? But how many iterations should be made before calling a number a Lychrel candidate? And what is a Lychrel seed number?

5. ## Re: Beginner Programming Challenge #10

What is a Lychrel seed number?
From Wikipedia:
Seed numbers are a subset of Lychrel numbers, that is the smallest number of each non palindrome producing thread. A seed number may be a palindrome itself.
-Silver Fox

6. ## Re: Beginner Programming Challenge #10

+1

Is 196 a Lychrel number? Nobody knows, it hasn't been proven yet. So 196 would be a Lychrel candidate number? But how many iterations should be made before calling a number a Lychrel candidate? And what is a Lychrel seed number?
Wikipedia says that the largest number of iterations for a number under 10,000 to resolve to a palindrome is 24. So I'd say go for 30 iterations before calling it a lychrel candidate.

7. ## Re: Beginner Programming Challenge #10

PHP Code:
``` readInt             :: String -> IntreverseInt          :: Int -> IntisPalindrome        :: Int -> BoolisCandidate         :: (Int, Int) -> BoolreadInt             = readreverseInt n        = if n < 10                        then n                        else readInt (reverse (show n))isPalindrome n      = if n < 10                        then True                        else ns == reverse ns                            where ns = show nisCandidate (30, _) = TrueisCandidate (n, p)  = if isPalindrome p                        then False                        else isCandidate (n + 1, p + reverseInt p)main = print [n | n <- [1..9999], isCandidate (0, n)]  ```
I'll do the seed-hunting later. I don't think it really needs commenting, but someone correct me if I'm wrong.
Last edited by Bachstelze; March 7th, 2010 at 10:45 PM.

8. ## Re: Beginner Programming Challenge #10

Originally Posted by schauerlich
Wikipedia says that the largest number of iterations for a number under 10,000 to resolve to a palindrome is 24. So I'd say go for 30 iterations before calling it a lychrel candidate.
Yup. I went up to 10,000 iterations, and it gave me the same results as 30.

9. ## Re: Beginner Programming Challenge #10

I think its a good challenge.

I am going to do it in a language I am still a bit green with: Python

-Silver Fox

10. First Cup of Ubuntu
Join Date
Aug 2011
Beans
10
Distro
Ubuntu 11.04 Natty Narwhal

## Re: Beginner Programming Challenge #10

You can't prove that a number is lychrel number ... You can take n iterations to get to a palindrome and prove it's a non-lychrel number, but if you want to determine it's a lychrel number you'll need to take all the possible iterations, and that's an infinite number of iterations. Sorry man great try !