Skip navigation

Palindromes Puzzle

Given the following table of words:

create table words(word varchar(50) not null primary key);

insert into words values('even');
insert into words values('never');
insert into words values('odd');
insert into words values('or');
insert into words values('madam');
insert into words values('adam');

Write a query that produces all possible palindromes (sentences that look the
same when spelled backwards) made of unique words.
The desired output for the given sample data is:

palindrome
------------------
madam
never even
never or even
never odd or even
madam adam

Cheers,
--
BG

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish