Day 11 - A Python Twist on Language with Palindromes, Semordnilaps and a Dahl of Time!
Wendy Ware
Sustainably unlocking value across mining value chains through full rock understanding
I spent most of my childhood avoiding household chores (Mum - I hope that you do not read these blogs!) - with my nose buried in a book. One of my favourite escapes was the fantastical worlds of Roald Dahl.
Dahl had a knack for concocting words that tickled the tongue and sparked the imagination. His beloved book, "The BFG", introduced a lexicon of delightful terms known as "Gobblefunk". From "snozzcumber" and "whizzpopper" to "frobscottle" and "human beans," Dahl introduced over 300 distinct "Gobblefunk" creations, making every reader delve deep into the joys of language.
Now, while Dahl’s linguistic creativity was something special, he was not alone in his love for wordplay. The English language itself has some tricks up its sleeve. Take palindromes for instance: words, phrases, or sequences of characters that read the same forwards as they do backwards, like "radar" or "level".
Then, there is the playful twist known as semordnilaps. What is that, you ask? Let us spell it backwards and see: palindromes! Yes, a "semordnilap" is a word that, when spelled in reverse, forms a different word altogether. For example, reverse "desserts" and you get "stressed." The term itself, rather than having age-old linguistic origins, is a relatively recent concoction, designed as a whimsical nod to its palindromic cousin.
I digress, let us dive into some code! Want to find out if a word is a palindrome or if it may have a semordnilap? Here is a handy Python script to do just that:
领英推荐
With this script, you can input a word and find out if it's a palindrome or if it may have a nifty semordnilap counterpart. Just a note - if one truly wants to know if a word is a semordnilap, one would need to add a list or set of valid words to check against. I did not do this in today's exercises - forgive me dear peeps! The hour of coding flew by in a jipertysweep.
In conclusion, as we revel in the joy of Dahl's Gobblefunk and explore palindromes and semordnilaps, we are reminded that language, at its core, can be a delightful playground. And who knows? Today, you might just stumble upon a new word or linguistic twist that Roald Dahl himself would have applauded!
So, my dear readers, here is a riddle to part with: What comes once in a minute, twice in a moment, but never in a thousand years? Dive deep into the world of words and see if you can unravel this puzzle!
Happy word-hunting, my fellow Coders!