1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

feat(solutions): add is-palindrome/rust/function

This commit is contained in:
Divlo
2023-01-04 18:28:14 +01:00
parent 257ab19f53
commit e17156f0ab
5 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,14 @@
use std::io;
fn main() {
let mut string = String::new();
io::stdin()
.read_line(&mut string)
.expect("Failed to read `stdin` line.");
let string = string.trim().replace(" ", "").to_lowercase();
let mut reverse: Vec<char> = string.chars().collect();
reverse.reverse();
let reverse: String = reverse.into_iter().collect();
let is_palindrome = reverse == string;
println!("{is_palindrome}");
}