Scripts to find and determine palindromes.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
sample_text
LICENSE
README.rdoc
find_longest_palindrome
find_longest_palindrome_assume_long
palindrome

README.rdoc

Palindrome

Various Ruby scripts for testing for and finding palindromes.

How to Use

Install Git and Ruby.

Clone this project.

cd ~
git clone http://github.com/garysweaver/palindrome.git

Examples

palindrome just determines if the inputted text is a palindrome:

$ ./palindrome abba
IS PALINDROME: true
$ ./palindrome abbaa
IS PALINDROME: false

find_longest_palindrome is a relatively quick method to find the longest palindrome, assuming that it is not terribly long:

$ ./find_longest_palindrome sample_text/raven_with_palindromes_b.txt 
Processing file...
LONGEST PALINDROME: GGGGGGGGGGGHHHHHHHGGGGGGGGGGG
Time to process: 0.679075 sec
Processing rate: 97937.635754519 characters / sec

find_longest_palindrome_assume_long is a quicker method to find the longest palindrome when the palindrome is very long (i.e. close to the size of the file):

$ ./find_longest_palindrome_assume_long sample_text/long_palindrome.txt 
Processing file...
LONGEST PALINDROME: (a very long palindrome)
Time to process: 0.000462 sec
Processing rate: 10597402.5974026 characters / sec

Notes

For testing, we use light modifications of a literary sample provided by Project Gutenberg. We also have a lightly modified version of the sample genetic sequence provided by UVA.

License

Copyright © 2012 Gary S. Weaver, released under the MIT license.