Thursday, November 19, 2009

C++ Palendrome Detector

Don't ask me why (please don't!) but i've just written a Palendrome detector in C++. If you don't already know, a palendrome is a sentence that reads the same backwards as forwards. Some famous palendromes are:

"A man, a plan, a canal, Panama"
"Madam, I'm Adama"
"Madam, in Eden I'm Adam"

etc.

To test the function I also use the one of the longest palendromes ever created - a 15,139 word palendrome at http://norvig.com/pal1txt.html which I copied into a file and read into a string.

Here is the code:



2 comments:

Zhi-Ren said...

Hi Andew,
What font did u use in your editor? Looks nice.

Andrew Sealy-Bell said...

Hi Ren, I use http://alexgorbatchev.com/wiki/SyntaxHighlighter to format code in my blog because I think it looks pretty good and also comes with the handy 'copy' and 'print' pop-up when you hover the mouse over the code. All you have to do is paste some JavaScript into your HTML template that you are using on blogspot. If you have any problems let me know :-)

Unweaving the Rainbow, by Richard Dawkins

We are going to die, and that makes us the lucky ones. Most people are never going to die because they are never going to be born. The potential people who could have been here in my place but who will in fact never see the light of day outnumber the sand grains of Sahara. Certainly those unborn ghosts include greater poets than Keats, scientists greater than Newton. We know this because the set of possible people allowed by our DNA so massively outnumbers the set of actual people. In the teeth of these stupefying odds it is you and I, in our ordinariness, that are here.
RichardDawkins.net

Books I am reading this book at the moment:

Atheist

The Out Campaign: Scarlet Letter of Atheism