"A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal-- Panama!" - Guy Steele, CLTL2
Some years after the faked death of John Darwin, who disappeared after rowing out to sea in his canoe, and was planning to start a new life with his wife in Panama with the insurance payout, the Grauniad had the headline "A man. A plan. A canoe. Panama" in an article (https://www.theguardian.com/uk/2008/jul/23/canoe.ukcrime1) about the case.
Pretty sure it was a kayak. People in the UK are very confused by the difference. E.g. British Canoe Union largely supports kayaking. I tend to use the terms interchangeably having been an active kayaker for around 25 years. The British public really struggle with the difference.
There's a link which takes you to the list of palindrome dates mentioned on the website [1]. There's 38 of them, but they all take the MM/DD/YYYY format into consideration. I wonder how much of a difference it would be by taking DD/MM/YYYY instead.
How does this count as a palindrome? It's just a bunch of nonsense words (ignoring all the acronyms, are the rest all actually even really words?) separated by commas, that doesn't even seem to pretend to take on the structure of a sentence.
Am I misunderstanding the level of coherence of the text? If the requirements are that loose, it seems it would be trivial to generate a 'palindrome' of arbitrary length.
"A man, a plan, a canal-- [you should book a trip to] Panama[, a country whose history is summed up by this witty list of things]!"
What I'd like to see is a version where instead of optimizing just for length, the palindrome is optimized for noun-phrases that genuinely have legit connections to Panama (as the brilliant original, "a plan, a man, a canal", does).
Apologies, I was actually referring to the very large (6MB!) palindrome text file [0] provided if you follow the article link to the GitHub project [1]. I guess the palindrome of discussion in this link is somewhat ambiguous, because there's not one specific palindrome that the article refers to.
Did you require a certain time complexity? I came across this on Leetcode. I found it really trivial to implement the “test all substrings” algorithm, but fiendishly difficult to implement the “expand around centers” algorithm.
It’s not a trick question. It’s just writing a loop any CS graduate or equivalent autodidact should have absolutely no problem with.
We didn’t require any specific time or space complexity. If the candidate whipped out a suboptimal solution quickly and correctly and time permitted we might ask them about that though and how it might be improved. The purpose of the question is not to see if the candidate has memorized the answer or sees a trick, it’s so they can demonstrate basic proficiency and systematic reasoning.
I'm also reminded of this IOCCC entry: https://www.ioccc.org/1987/westley/westley.c. Strictly speaking, it's not composed of palindromes because of the mirror-image brackets and slashes, but still, impressive.
"Nelli plaatst op n parterretrap n pot staalpillen."
The 'n's are a bit of an issue though, 'n in dutch means 'een', but reversed that doesn't work so the 'e's got dropped and replaced by "'" but they move from one side of the n's to the other in the reversal.
Perec also wrote a book with no letter E, a mystery about the missing letter. The English translation is called _A Void_. It's hard to make sense in parts, largely works.
At parts it discusses the mysterious missing letter (E is not know) like threeve, the integer between 3 and 4.
It depends on your definition of palindrome. Is it 'reads the same forwards or backwards' or is it 'had the same characters in the second half as in the first, but in reverse order'?
You'll find that according to most dictionaries, ()() is the palindrome here.
59 comments
[ 3.2 ms ] story [ 135 ms ] threadPS I converted this into three palindromic tweets https://twitter.com/sep332/status/928484353310711808
I upvoted your comment to make it up for you...hope you have a good one...
[1] https://www.livescience.com/33583-palindrome-dates-21st-cent...
But yes, YYYY-MM-DD all the way. It's indispensable to me when sorting file names by date.
Am I misunderstanding the level of coherence of the text? If the requirements are that loose, it seems it would be trivial to generate a 'palindrome' of arbitrary length.
"A man, a plan, a canal-- [you should book a trip to] Panama[, a country whose history is summed up by this witty list of things]!"
What I'd like to see is a version where instead of optimizing just for length, the palindrome is optimized for noun-phrases that genuinely have legit connections to Panama (as the brilliant original, "a plan, a man, a canal", does).
[0] https://raw.githubusercontent.com/rmeertens/palindromes/mast... [1] https://github.com/rmeertens/palindromes
It's questionable what that other junk has to do with Panama. But grammatically, the structure is the same.
Racecar
We didn’t require any specific time or space complexity. If the candidate whipped out a suboptimal solution quickly and correctly and time permitted we might ask them about that though and how it might be improved. The purpose of the question is not to see if the candidate has memorized the answer or sees a trick, it’s so they can demonstrate basic proficiency and systematic reasoning.
For any N "See [banana,]* bees." can be longer than N.
1: Are the same forwards and backwards
2: Make coherent sense
Still pretty cool nonetheless, I suppose
I know a fat man called Ella C Namtafawnoki.
I got hang of fog nah togi.
koortsmeetsysteemstrook
"Nelli plaatst op n parterretrap n pot staalpillen."
The 'n's are a bit of an issue though, 'n in dutch means 'een', but reversed that doesn't work so the 'e's got dropped and replaced by "'" but they move from one side of the n's to the other in the reversal.
(twelve plus one) is an anagram of (eleven plus two)
I guess that should be called a mathagram?
At parts it discusses the mysterious missing letter (E is not know) like threeve, the integer between 3 and 4.
Then we have
andYou'll find that according to most dictionaries, ()() is the palindrome here.
Unless you're a robot.
()() --> abab
())( --> abba
)(() --> baab
We coders could get fooled by this question if we dont pay much attention