Questions tagged [palindrome]

Any sequence of units (typically letters or numbers) that are read the same way forward or backward.

Filter by
Sorted by
Tagged with
3
votes
6answers
6k views

Largest palindrome made from the product of two 3-digit numbers

I am working on an interview question in which I need to find the largest palindrome made from the product of two 3-digit numbers. Here is the question. ...
2
votes
1answer
112 views

Palidrome checker in haskell

I decided to avoid the trivial isPalindrome lst = lst == reverse lst and tried writing a method with pattern matching and recursion. ...
1
vote
1answer
748 views

Longest palindrome in a given string using LINQ

Problem:I need to write an algorithm that will return length of longest possible palindrome from a given string. So if the input is aabbbccdfg Program output should be 7. //-->[cabbbac] Can someone ...
7
votes
4answers
3k views

Palindrome program

Given a beginning and ending point, check how many numbers are palindromic. My solution is a bit clunky. How could it be more elegant? ...
6
votes
1answer
1k views

STL-like palindrome checking

I just read this article on how to write a standard-like algorithm and wanted to try it myself by writing (as suggested in the article) an algorithm to test if a sequence given by two bidirectional ...
4
votes
2answers
463 views

Number palindrome checker

My daughter, nine, recently had some homework looking at number palindromes. Part of the assignment was to take a number, reverse it, add the two together and repeat until she got a palindrome and to ...
2
votes
1answer
4k views

Palindrome Checker with Stack

In my answer to this question, I wrote a new solution. Personally, I would not use a stack, but given that a stack was required, how good is this solution? In this solution, I add half of the word, ...
2
votes
4answers
3k views

Palindromes with stacks

I'm creating a simple function to verify whether or not a string is a palindrome, and must use stacks in solving it. ...
4
votes
3answers
4k views

Finding the next palindrome code

I have been trying recently to develop a code finding the next palindrome from a certain number. For example, if the input is 800, the output should be 808, as 808 being the next palindrome from 800. ...
10
votes
2answers
551 views

The finest integers are palindromes

Challenge: Reverse the digits of a number and add it to the original until the number is a palindrome Specifications: Your program should accept as its first argument a path to a filename. ...
2
votes
1answer
7k views

Producing a pyramid of capital letters

Now I'm reading C Premier Plus by Stephen Prata and there's an exercise 4 in chapter 6 which has no solution in the book, so I can't check if I did it properly. My code works like it should, but I ...
6
votes
2answers
1k views

Palindromes without character

You are given a string of lowercase letters. Your task is to figure out the index of the character whose removal will result in a palindrome. There will always be a valid solution. Here is my quick ...
4
votes
2answers
6k views

Check if string can be rearranged into a palindrome

I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
8
votes
5answers
846 views

Palindrome checker using a sentinel loop

This is my first submission and have completed one quarter of Java programming. I have an assignment to create a Palindrome Checker. Fairly straight forward, I had that portion of the code figured ...
3
votes
2answers
189 views

Project Euler #4 in Haskell

Project Euler #4 asks: Find the largest palindrome made from the product of two 3-digit numbers. The code is as follows: ...
4
votes
5answers
13k views

Determining if a sentence is a palindrome

The biggest problem I see in checking palindromes on the Internet is when the user inputs a palindrome sentence or phrase and the program returns a wrong output. So for me, I tried to optimize ...
2
votes
1answer
128 views

Code that finds the largest palindrome from two three-digit factors

My code is really ugly, but I don't know how to make it better. ...
4
votes
2answers
570 views

Palindrome Checker Algorithm

Here is an example of how I solved this problem (though this is not the only nor the best way by any means) for an assignment where it was also requisite to determine if a string was a reverse prefix ...
6
votes
1answer
2k views

Anagram palindrome checking

I need to figure out if any anagram of the string can be a palindrome or not. Ideas: It relies on two observations: Frequency of every character in the string is even, if length of the string is ...
5
votes
1answer
1k views

Determine all prime, palindrome string integers within a range

I have written a program in Python 3x to determine all the prime, palindrome string integers in the range of two given numbers. ...
10
votes
3answers
2k views

Palindrome tester

This program takes lines of input. The first line is an int specifying how many further lines will be input. For the following lines (comprised of characters a-z), ...
1
vote
2answers
3k views

“The Love Letter Mystery” - storing and comparison of strings

The problem goes like this. Change the strings provided by user to form palindromes. To do this, 2 rules are: (a) Reduce the value of a letter, e.g. Change 'd' to 'c', but cannot change '...
0
votes
1answer
125 views

Finding Largest Integer Palindrome within a Set

I've "solved" Project Euler Question 4 and I was wondering if I could make my answer more efficient (I'm using Project Euler to help me learn Haskell). The problem reads: Find the largest ...
3
votes
2answers
689 views

Longest Common Subsequence and Longest Subsequence Palindrome

The following code computes: The longest common subsequence between two strings, where a subsequence of a sequence does not have to consist of contiguous elements of the sequence. The longest ...
7
votes
1answer
908 views

Palindrome check in Haskell

I am learning Haskell and I am doing 99 Haskell problems. There is a problem to check if a list if a palindrome. It's obvious solution is ...
13
votes
3answers
1k views

Optimisation of palindrome

My program takes as first input the number of test cases, n. For the following n inputs, I output the smallest positive integer that has to be added to the input to make the input a numeric palindrome....
2
votes
1answer
1k views

Index of letter removed to make string palindrome

This code finds the index in the string and removes the one which will make the string a palindrome. If the string is already a palindrome, it should return -1. This code works correct, but I am ...
3
votes
2answers
261 views

Finding palindromic numbers most efficiently

After reading why is my project euler #4 program not working?, I was contemplating the most efficient way to approach this (finding the target palindrome as early as possible). Is this snippet about ...
10
votes
3answers
2k views

Checking for palindromes using dynamic memory allocation

This is a homework assignment, but it's already done and it's not for a grade; it's meant as a refresher for the rest of the course. I've never done anything with dynamic memory allocation in C before,...
10
votes
2answers
2k views

Project Euler #4 (largest palindrome product) in Swift

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 from the product of two 3-...
2
votes
2answers
675 views

Make palindrome finder-builder function faster

I built a small JavaScript function to see if a series of characters are a palindrome or not. The functions works well and does everything it has to do, but I'm wondering if something can be tweaked ...
26
votes
9answers
56k views

Check a string to see if it is a palindrome

I have written two code pieces to check if a given string is a palindrome: ...
5
votes
2answers
2k views

Minimum number of letters removed, to make a string Peragram

Here is the link to the problem Peragrams. Peragrams: If a word is an anagram of at least one palindrome, we call it a Peragram. Problem: Given a string, find the minimum number of letters ...
14
votes
3answers
2k views

The Love-Letter Mystery

Problem Statement James got hold of a love letter that his friend Harry has written for his girlfriend. Being the prankster that James is, he decides to meddle with it. He changes all the words ...
7
votes
1answer
4k 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: 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 appears in reverse order....
10
votes
4answers
10k views

Recursive implementation of palindrome string checker

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 ...
11
votes
3answers
674 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 ...
3
votes
3answers
394 views

Find the inverted value of the string

How can this be optimized? ...
1
vote
3answers
561 views

Optimizing Project Euler 36 - double-base palindromes

This one was quick and simple. Any optimizations? ...
17
votes
5answers
24k 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 that)...
3
votes
1answer
475 views

Largest Palindrome Checker

...
24
votes
5answers
1k 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 106 ...
10
votes
4answers
9k 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 from ...
7
votes
2answers
2k 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, ...
16
votes
3answers
14k views

Return the largest palindrome from the string

Here is the question: find the largest palindrome from a string. Ex: ABCBAHELLOHOWRACECARAREYOUILOVEUEVOLIIAMAIDOINGGOOD Result: ...
5
votes
2answers
416 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 of ...
12
votes
4answers
4k views

Checking for a palindrome

What I'm basically wondering is if there's anything that is possible to improve in this C++ code: ...
2
votes
1answer
2k 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
1k 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 ...
6
votes
4answers
11k views

Palindrome program with reverse method

I wrote a program for a college assignment, and I'd like to receive some pointers on making my code a little more efficient. The program should ask the end user to enter an integer. Use the <...