Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,148,879 members, 7,802,838 topics. Date: Friday, 19 April 2024 at 10:57 PM |
Nairaland Forum / Science/Technology / Programming / Coding Challenge 2: Palindromes (1409 Views)
Mini Web Application Coding Challenge For Programmers / . / Java Coding Challenge: Task Scheduler (2) (3) (4)
Coding Challenge 2: Palindromes by Fayimora(m): 10:00am On Jul 06, 2011 |
Challenge Your task is to write code that checks is a word is a palindrome. So when given input Madam i'm adam!Your program should return true. Hint: Ignore non-characters Time limit: 1s Goodluck |
Re: Coding Challenge 2: Palindromes by kandiikane(m): 5:53pm On Jul 06, 2011 |
Hmm, I don't understand what you mean but I do know what palindrome is. Never odd or even |
Re: Coding Challenge 2: Palindromes by Nobody: 5:56pm On Jul 06, 2011 |
Re: Coding Challenge 2: Palindromes by kandiikane(m): 5:59pm On Jul 06, 2011 |
Omo_to_dun, pleas explain, I am not really good with programmings/ |
Re: Coding Challenge 2: Palindromes by tundebabzy: 2:04am On Jul 07, 2011 |
python solution: <code> import time def check_palin(st): t1 = time.time() stripped = "" for ch in st: if (ord(ch) > 64 and ord(ch) < 91) or (ord(ch) > 96 and ord(ch) < 123): stripped += ch t2 = time.time() print 'running time is %f' %(t2-t1) return stripped.lower() == stripped[::-1].lower() </code> Ideally I would have imported re so i can use regular expressions to strip any non-alphabet from the string instead of looping character by character. |
Re: Coding Challenge 2: Palindromes by Fayimora(m): 2:07am On Jul 07, 2011 |
hmm cool A java solution class Palindrome Again its coded the OO way for reuse so it could be much shorter, |
Re: Coding Challenge 2: Palindromes by kandiikane(m): 2:10am On Jul 07, 2011 |
@fayimora, can you explain? |
Re: Coding Challenge 2: Palindromes by Fayimora(m): 2:13am On Jul 07, 2011 |
Yeah sure, would be much easier if i just carpet bomb the code with comments, Before that, give me your own algorithm for checking if a string is a palindrome. What would you do, it doesn't matter if you can but it helps to have a solution in mind, Aiit am waiting, Do that while i bombad the code, |
Re: Coding Challenge 2: Palindromes by kandiikane(m): 2:19am On Jul 07, 2011 |
Fayimora, trust me with computer and codes I am not good but I do like to learn that is why I asked |
(1) (Reply)
I Need A Mentor In Web Programming Language Type Java / Programming Challenge 1 (any Language). / Hello Programmer Need Ur Assistance
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |