Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

46 lines (29 sloc) 1.642 kB

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.

Jump to Line
Something went wrong with that request. Please try again.