RATS in Python
What is RATS? Well, this is a challenge in the programming site Dream.In.Code and the gist of it is this:
take any number as your seed, (59)
reverse the digits of the number (five 9 reversed becomes 95)
add the original and the reversed number together (59+95 = 154)
sort the digits of the value (154 sorted becomes 145)
the sorted value is your output (145)
So initial runs would give us this
RATS(59,1)
145
RATS(59,2)
668
You can read more about it here:
http://www.dreamincode.net/forums/topic/292760-open-language-code-golf-rats/
I don't know what Code Golf is, but here's what I did. Be wary that I'm new to the Python language. I will not tolerate "Oh no! He didn't use <insert powerful Python feature here>! That's not Pythonic!" What's Pythonic anyway? Don't worry, as I go along with the language I'll come back and fix this mess.
def RATS(seed, val):
rats =[]
ctr = 0
s = seed
while ctr != val:
s = str(s)[::-1]
s = int(s) + seed
s = int("".join(sorted(str(s))))
rats.append(s)
ctr = ctr + 1
seed = s
print rats