File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
69
69
| -------------------------------------| -------| ------| --------| ----| ------| ------------| --------|
70
70
| Lista com 2 Pilhas | C/C++ | Java | [ Python] ( /src/python/lista_com_pilhas.py ) | Go | Ruby | Javascript | Pascal |
71
71
| Problema da Soma de 2 Números | C/C++ | Java | [ Python] ( /src/python/soma_dois_numeros.py ) | Go | Ruby | Javascript | Pascal |
72
- | [ Palíndromo] [ 49 ] | [ C/C++] ( /src/c/Palindromo.c ) | Java | Python | Go | Ruby | Javascript | Pascal |
72
+ | [ Palíndromo] [ 49 ] | [ C/C++] ( /src/c/Palindromo.c ) | Java | Python | Go | [ Ruby] ( /src/ruby/Palindromo.rb ) | Javascript | Pascal |
73
73
| Lista Encadeada Desordenada | C/C++ | Java | [ Python] ( /src/python/lista_encadeada_desordenada.py ) | Go | Ruby | Javascript | Pascal |
74
74
| [ Calcula o PI (Fórmula de Leibniz)] [ 50 ] | C/C++ | Java | [ Python] ( /src/python/calculate_pi.py ) | Go | Ruby | Javascript | Pascal |
75
75
| Busca em Labirinto | C/C++ | Java | [ Python] ( /src/python/busca_em_labirinto.py ) | Go | Ruby | Javascript | Pascal |
Original file line number Diff line number Diff line change
1
+ require "test/unit/assertions"
2
+ include Test ::Unit ::Assertions
3
+
4
+ #the easiest implementation would be using .reverse method
5
+
6
+
7
+ def is_palindrome ( string )
8
+
9
+ return true if string . size == 1 || string . size == 0
10
+
11
+ reversed = ""
12
+ string = string . gsub ( " " , "" ) . downcase
13
+ string . chars . reverse_each do |c |
14
+ reversed << c
15
+ end
16
+
17
+ reversed == string ? true : false
18
+ end
19
+
20
+ assert_equal is_palindrome ( "abba" ) , true
21
+ assert_equal is_palindrome ( "abbas" ) , false
22
+ assert_equal is_palindrome ( "tattarrattat" ) , true
23
+ assert_equal is_palindrome ( "Was it a palindrome?" ) , false
24
+ assert_equal is_palindrome ( "No lemon, no melon" ) , true
You can’t perform that action at this time.
0 commit comments