Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Com o objetivo de alcançar uma abrangência maior e encorajar novas pessoas a c
|-------------------------------------|-------|------|--------|----|------|----|--------|-------|------|
| Lista com 2 Pilhas | C/C++ | Java | [Python](./src/python/lista_com_pilhas.py) | Go | Ruby | JS | Pascal | Swift | Rust |
| Soma de 2 Números | C/C++ | Java | [Python](./src/python/soma_dois_numeros.py) | Go | Ruby | JS | Pascal | Swift | Rust |
| [Palíndromo][49] | [C/C++](./src/c/Palindromo.c) | Java | Python | Go | [Ruby](./src/ruby/Palindromo.rb) | [JS](./src/javascript/Palindromo.js) | Pascal | Swift | Rust |
| [Palíndromo][49] | [C/C++](./src/c/Palindromo.c) | Java | Python | Go | [Ruby](./src/ruby/Palindromo.rb) | [JS](./src/javascript/Palindromo.js) | Pascal | Swift | [Rust](./src/rust/palindromo.rs) |
| Lista Ligada Desordenada | C/C++ | Java | [Python](./src/python/lista_encadeada_desordenada.py) | Go | Ruby | JS | Pascal | Swift | Rust |
| [Calculo do PI (Leibniz)][50] | C/C++ | Java | [Python](./src/python/calculate_pi.py) | [Go](./src/go/calculatepi/calculatepi.go) | Ruby | [JS](./src/javascript/calculate_pi.js) | Pascal | Swift | Rust |
| Busca em Labirinto | C/C++ | Java | [Python](./src/python/busca_em_labirinto.py) | Go | Ruby | JS | Pascal | Swift | Rust |
Expand Down
17 changes: 17 additions & 0 deletions src/rust/palindromo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn main() {
println!("{:?}", palindromo("".to_string()));
println!("{:?}", palindromo("a".to_string()));
println!("{:?}", palindromo("abba".to_string()));
println!("{:?}", palindromo("abbas".to_string()));
println!("{:?}", palindromo("tattarrattat".to_string()));
println!("{:?}", palindromo("Was it a palindrome?".to_string()));
println!("{:?}", palindromo("No lemon, no melon".to_string()));
}
pub fn palindromo(mut word: String) -> bool {
word = word.to_lowercase().split_whitespace().collect::<String>();
let reversed_string: String = word.chars().rev().collect::<String>();
if word.len() <= 1 {
return true;
}
word == reversed_string
}