Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 24 lines (18 sloc) 376 Bytes
#!/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)