Skip to main content

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.

Filter by
Sorted by
Tagged with
10 votes
8 answers
746 views

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 ...
Value Ink's user avatar
  • 13.5k
19 votes
30 answers
2k views

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
Steve Bennett's user avatar
13 votes
9 answers
894 views

Every string can be split into substrings that are all palindromes quite easily. For example, "abab" can be split into the palindromes ...
Used_Brain's user avatar
19 votes
10 answers
3k views

Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1...
bsoelch's user avatar
  • 6,095
19 votes
7 answers
2k views

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 ...
FryAmTheEggman's user avatar
4 votes
5 answers
408 views

Searching for rotatable numbers, like: 68089 If you consider numbers upside-down, 6 looks like ...
F. Hauri  - Give Up GitHub's user avatar
20 votes
28 answers
3k views

Given a string, shuffle it so that it becomes a palindrome. For example, adadbcc can be arranged into dacbcad, or ...
emanresu A's user avatar
  • 46.2k
17 votes
13 answers
2k views

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 ...
AnttiP's user avatar
  • 8,048
5 votes
1 answer
383 views

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 ...
Diana Andrei's user avatar
23 votes
27 answers
3k views

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 ...
Gio D's user avatar
  • 504
15 votes
16 answers
3k views

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 ...
Galen Ivanov's user avatar
  • 21.5k
8 votes
4 answers
308 views

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 ...
user192361237's user avatar
20 votes
14 answers
1k views

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 ...
Wheat Wizard's user avatar
  • 103k
10 votes
24 answers
2k views

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 ...
Adám's user avatar
  • 31.8k
17 votes
15 answers
2k views

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 ...
Cowabunghole's user avatar
  • 1,660
15 votes
12 answers
2k views

Given a string l, find all palindromic substrings p of l (including duplicates and single ...
Magic Octopus Urn's user avatar
10 votes
13 answers
2k views

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 ...
Peter Wirdemo's user avatar
72 votes
26 answers
9k views

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 ...
Luis Mendo's user avatar
  • 107k
8 votes
14 answers
669 views

Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a ...
ATaco's user avatar
  • 11.7k
4 votes
1 answer
308 views

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 ...
AJMansfield's user avatar
  • 2,898
20 votes
15 answers
2k views

Consider the string 160615051. It can be "triangulated" as such: 1 606 15051 Then, each row is a palindrome. Also note ...
Conor O'Brien's user avatar
26 votes
14 answers
7k views

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 ...
Okx's user avatar
  • 16.5k
15 votes
16 answers
4k views

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 ...
Dead Possum's user avatar
  • 3,454
10 votes
6 answers
565 views

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\$....
mbomb007's user avatar
  • 23.6k
120 votes
76 answers
29k views

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 ...
user avatar