Any sequence of units (typically letters or numbers) that are read the same way forward or backward.
17
votes
5answers
843 views
Count distinct primes, discarding palindromes, in under 2 seconds
Problem Statement
Generate as many distinct primes P such that reverse (P) is also prime
and is not equal to P.
Output:
Print per line one integer( ≤ 1015 ). Don't print more than
...
13
votes
5answers
1k views
Longest palindrome in a string
Please be brutal, and judge my code as if it was written at a top 3 tech company, straight out of college. (The method signature, and input parameter is given by the problem, so don't worry about ...
11
votes
1answer
228 views
Depth-first search method for searching for all “superpalindromes” whose prime factors are all <=N
A question was asked over at math.SE (here) about whether or not there are infinitely many superpalindromes. I'm going to rephrase the definition to a more suitable one for coding purposes:
...
10
votes
3answers
423 views
Searching for pseudo-palindromes (“semordnilaps”)
I was interested to know which words of the English language, when spelled backwards, are still valid words (e.g. "drawer", which when spelled backwards is "reward"), so I wrote a small program to go ...
9
votes
4answers
589 views
Recursive implementation of palindrome string checker - refactoring issue
I've tried to refactor my program to single return statement at the end of the program however it ruins the end statements of the recursion. because I want to return from function in specific line and ...
7
votes
4answers
331 views
Can I check for a palindrome in a better way than this?
What I'm basically wondering is if there's anything that is possible to improve in this C++ code:
...
7
votes
2answers
130 views
Lychrel calculator (Project Euler 55)
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
Not all numbers produce palindromes so quickly. For example,
...
7
votes
2answers
299 views
Return the largest palindrome from the string
Here is the question: find the largest palindrome from a string.
Ex:
ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD
Result:
...
7
votes
1answer
150 views
Checking ends of a substring
I was doing this particular problem AIBOHP and used a dp approach based on checking the ends of a substring of length i starting from 1. Although my time complexity is fine at O(n^2) but space is ...
6
votes
3answers
894 views
Project Euler #4 - Largest Palindrome Product
Problem Statement:
A palindromic number reads the same both ways. The largest palindrome
made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made ...
5
votes
5answers
894 views
Making palindrome program more efficient
I wrote a program for a college assignment, and I'd like to receive some pointers on making my code a little more efficient. It'd be much appreciated. I'm still new to coding, so I apologize if my ...
5
votes
2answers
165 views
Is my N-drome (variation of palindrome) checking program efficient?
An N-Drome is a string that is the same forwards and backwards when split into n-character units.
For example, a string would be a 1-drome if and only if it were a standard palindrome.
An example ...
5
votes
4answers
417 views
Largest Palindrome efficiency
I have written an algorithm to find the largest palindrome under a given number, but I am sure my code loses efficiency by creating new arrays in every pass. I am currently learning about efficiency ...
5
votes
1answer
156 views
Finding the largest mirror image of a subset/set of integers present in an array of integers
The problem I am talking about is this.
Problem statment:
We'll say that a "mirror" section in an array is a group of contiguous
elements such that somewhere in the array, the same group ...
4
votes
5answers
2k views
More functional way of writing this palindrome extractor?
I wrote this palindrome extractor. And even though it works, and I can solve the challenge with it, it feels very Java-like. I was wondering what adjustments I could make in order for it to be more ...
4
votes
3answers
182 views
4
votes
2answers
415 views
The Next Palindrome: Is my code efficient?
I was trying to solve the Next Palindrome problem listed in SPOJ in Ruby language. Please find the problem statement here. Though i came up with the below solution, i could not get the execution time ...
4
votes
1answer
1k views
Correct multithreaded reader-writer implementation
I think I'm finished writing a multithreaded reader-writer implementation for my Operating Systems course. I would like to verify that my multithreading is correct and that I'm using good C++0x style.
...
3
votes
1answer
66 views
3
votes
1answer
1k views
Create palindrome by rearranging letters of a word
Inspired by a recent question that caught my interest (now deleted), I wrote a function in Python 3 to rearrange the letters of a given string to create a (any!) palindrome:
Count the occurrences of ...
2
votes
5answers
1k views
Determining numeric palindromes
I am working on bettering my C# skills, and recently wrote this program to solve a projecteuler.net problem:
A palindromic number reads the same both ways. The largest palindrome
made from the ...
2
votes
2answers
385 views
Using pointers for string manipulation
I'm taking a sentence and determining whether or not it is a palindrome. I'm doing this while learning about stacks.
Is there a way I can use pointers instead of ...
2
votes
2answers
356 views
Project Euler, #4: Incorrect Results on 7-digit numbers
I've got my answer working (up until a 7-digit answer is requested, anyway), and would like some help
returning the correct answer
speeding up the results
I was thinking of storing the values of ...
2
votes
1answer
561 views
Finding largest string palindrome
I've attempted to write a program to find the largest palindrome in a sentence. Spaces are included and characters are case-sensitive. Can you suggest better ways of doing this?
...
2
votes
1answer
186 views
Python Palindrome Generator
I've just written a palindrome generator and would like to know what you think about it.
Especially:
code style
Is it possible to get the same result without making a special case for 1-digit ...
2
votes
1answer
145 views
Palindrome Checker
I've just started learning Java and went to compare my finished product to some others on Stack Overflow. Is there a reason why mine is "simple" and the others seem ridiculously hard to even ...
1
vote
3answers
80 views
Optimizing Project Euler 36 - double-base palindromes
This one was quick and simple. Any optimizations?
...
1
vote
4answers
5k views
Simple palindrome function for single words
I have created a simple palindrome function that works only on single words. It is working as intended, but I feel that it definitely needs improvement.
...
1
vote
1answer
446 views
Reverse and Add: find a palindrome
This is one of codeeval challenges
Challenge Description:
Credits: Programming Challenges by Steven S. Skiena and Miguel A.
Revilla
The problem is as follows: choose a number, reverse ...