Commits

rgrau committed 94a67ce

palindrome

  • Participants
  • Parent commits 528f7cf

Comments (0)

Files changed (1)

+# -*- coding: utf-8 -*-
 require 'rubygems'
 require 'sinatra'
 require '3scale_client'
 
 helpers do
   def sanitize_word(word)
-    word.gsub(/[ !.,]/, '').chars.sort
+    word.gsub(/[ !.,]/, '').
+      tr("áÁéÉíÍóÓúÚü", "aaeeiioouuu").
+      chars.sort
   end
 end
 
     word2: params[:word2],
     is_anagram: sanitize_word(params[:word1]) == sanitize_word(params[:word2])}.to_json
 end
+
+get("/v1/palindrome") do
+  return {
+    word1: params[:word1],
+    is_palindrome: sanitize_word(params[:word1]) == sanitize_word(params[:word1]).reverse }.to_json
+end