Questions tagged [palindrome]
Palindromes are words, phrases, representations of numbers or times which read the same in reverse, for example "level", "reviver", "12321", "10:01". See also the [balanced-string] tag.
105 questions
10
votes
8
answers
746
views
Closest Palindromic Number with Matching Smallest Valid Base
An extension of Find the closest palindromic number mixed with Numbers Interpreted in Smallest Valid Base.
A number is a palindrome if its sequence of digits is the same when reading them from left to ...
19
votes
30
answers
2k
views
Add Y to X to get a palindrome
Given X>0, return the smallest Y>=0 such that X+Y is a palindrome. Code golf.
Tests:
5 => 0
14 => 8
200 => 2
819 => 9
1100 => 11
1122 => 99
13
votes
9
answers
894
views
split string into minimum number of palindromic substrings [duplicate]
Every string can be split into substrings that are all palindromes quite easily. For example, "abab" can be split into the palindromes ...
19
votes
10
answers
3k
views
Numbers that can be negated by reading backwards
Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1...
19
votes
7
answers
2k
views
Farigiraf my Girafarig
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that ...
4
votes
5
answers
408
views
Rotatable numbers (Upside down) [duplicate]
Searching for rotatable numbers, like: 68089
If you consider numbers upside-down,
6 looks like ...
20
votes
28
answers
3k
views
Rearrange to a palindrome
Given a string, shuffle it so that it becomes a palindrome.
For example, adadbcc can be arranged into dacbcad, or ...
17
votes
13
answers
2k
views
Recursive palindromes
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are ...
5
votes
1
answer
383
views
Tips on golfing this Python program to generate a palindrome from a string
I wrote this function in 48 bytes and I wonder, is there any way to write this code 2 characters shorter?
p=lambda n,c:(n*c)[:n//2]+(n*c)[:n//2+n%2][::-1]
The ...
23
votes
27
answers
3k
views
Based Palindromes
A palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases?
Input
Any integer b ...
15
votes
16
answers
3k
views
Palindrome distance
Find what is the distance for a given string to its closest palindrome of the same length.
For this task I decided to give the characters further away from the string's center more weight (think of it ...
8
votes
4
answers
308
views
Find the index of reflection of a substring of a palindrome [closed]
Problem Statement:
You will receive a substring of a palindromic string. You must return the index of the substring which marks the point of reflection of the original string. You are only provided ...
20
votes
14
answers
1k
views
Number of palindrome splits
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For ...
10
votes
24
answers
2k
views
Password Bishop Goodness
Derived from this, now deleted, post.
Given a string, answer (truthy/falsy or two consistent values) if it constitutes a good Bishop password, which is when all the following conditions are met:
it ...
17
votes
15
answers
2k
views
Is this string a palindrome (in Morse Code)?
Challenge
Inspired by this video.
As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into ...
15
votes
12
answers
2k
views
Stitch Together a Palindrome from Palindromic Substrings
Given a string l, find all palindromic substrings p of l (including duplicates and single ...
10
votes
13
answers
2k
views
List all palindromic prime dates between 0000-01-01 and 99999-12-31
You know what a palindrome, a prime and a date are.
Your task is to list all dates in 100 thousands of years that fulfill
all three characteristics.
Nevermind anything but the numbers, use the ...
72
votes
26
answers
9k
views
Yo boy, must it sum
Every positive integer can be expressed as the sum of at most three palindromic positive integers in any base b≥5. Cilleruelo et al., 2017
A positive integer is palindromic in a given base if ...
8
votes
14
answers
669
views
Count the Palindromes [duplicate]
Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a ...
4
votes
1
answer
308
views
Find the Closest Double Palindrome
Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome.
Input
A floating point number x. You may use ...
20
votes
15
answers
2k
views
Fully-palindromic triangles
Consider the string 160615051. It can be "triangulated" as such:
1
606
15051
Then, each row is a palindrome. Also note ...
26
votes
14
answers
7k
views
Perfect Palindromes
Your task is to determine how much of a perfect palindrome a string is. Your typical palindrome (eg 12321) is a perfect palindrome; its perfectness is 1.
To determine the perfectness of a string, you ...
15
votes
16
answers
4k
views
Never odd or even
Did you notice, that this is a palindrome?
Input
Non-negative integer number or string representing it
Output
4 possible outputs, representing two properties of number:
is it palindrome
tricky #2
...
10
votes
6
answers
565
views
Numbers that are palindromes in N bases
Given an non-negative integer \$n \ge 0\$, output forever the sequence of integers \$x_i \ge 3\$ that are palindromes in exactly \$n\$ different bases \$b\$, where the base can be \$2 \le b le x_i-2\$....
120
votes
76
answers
29k
views
I'm a palindrome. Are you?
There have been a couple of previous attempts to ask this question, but neither conforms to modern standards on this site. Per discussion on Meta, I'm reposting it in a way that allows for fair ...