Yahoo India Web Search

Search results

  1. Oct 13, 2008 · @Steve314 to describe an algorithm to convert an integer to a string, which of course requires you to understand modulo - no. Computing in the target number system, being able to add will do (think how you commonly convert from decimal to binary - being used to think computation means binary doesn't mean you can't do, e.g., decimal arithmetic (and you can do conversion from binary to decimal without division or modulo 2).

  2. Mar 4, 2014 · This shortcuts when it's impossible to return an i*j > the largest recorded and correctly returns 906609 (note, if you're in python 2, the below would work for you, but you'd prefer to use xrange instead of range to avoid creating unnecessary lists in memory):

  3. Jun 27, 2013 · I'm trying to check for a palindrome with Python. The code I have is very for-loop intensive.. And it seems to me the biggest mistake people do when going from C to Python is trying to implement C logic using Python, which makes things run slowly, and it's just not making the most of the language.

  4. If a string is zero or one letters long, it's a palindrome. If a string has the first and last letters the same, and the remaining letters (I think it's a [1: -1] slice in Python, but my Python is a bit rusty) are a palindrome, it's a palindrome. Now, write that as a palindrome function that takes a string. It will call itself.

  5. Dec 19, 2016 · x=input('Please insert a word') y=reversed(x) if x==y: print('Is a palindrome') else: print('Is not a palindrome') This always returns false because y becomes something like <reversed object at 0x00E16EF0> instead of the reversed string.

  6. Oct 25, 2012 · Integer numbers don't have len(). Testing if a number is a palindrome is as simple as testing if the number is equal to its reverse (though if you want maximum efficiency you can just compare characters from both ends of the string until you reach the middle).

  7. generate_palindrome only needs to collect the palindromes for all needed length', and take care of the boundary. The algorithm is in O(2*p), with p being the number of palindromes. The algorithm does work. However, as my python skills are rusty, any advice for a more elegant solution is appreciated.

  8. Jul 19, 2015 · $ python t.py Enter a number: 123 You entered 123, but the next palindrome is 131 $ python t.py Enter a number: 121 Congratulations! 121 is a palindrome. Share Improve this answer

  9. I'm having trouble with this problem that simply return True of False if a number n, is a palindrome. Note: wherever I have a ____ indicates where there is a blank that needs to be filled in. There are 2 blank spaces.

  10. If a word is inputted, for example : rotor , I want the program to check whether this word is palindrome and give output as "The given word is a palindrome". But I'm facing problem that, the program checks first r and r and prints "The given word is a palindrome" and then checks o and o and prints "The given word is a palindrome".

  1. People also search for