Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 24 lines (18 sloc) 0.376 kb
#!/usr/bin/ruby
file = File.open("level1.txt")
text = file.readline
palindromes = Array.new
for i in 0...text.length-1
for j in i+1...text.length
if text[i..j] == text[i..j].reverse then
palindromes.push(text[i..j])
end
end
end
longest = String.new
palindromes.each do |word|
if word.length > longest.length
longest = word
end
end
puts(longest)
Jump to Line
Something went wrong with that request. Please try again.