diff --git a/challenges/is-palindrome/README.md b/challenges/is-palindrome/README.md index 3acf602..f698fe2 100644 --- a/challenges/is-palindrome/README.md +++ b/challenges/is-palindrome/README.md @@ -6,7 +6,7 @@ Created by [@Divlo](https://github.com/Divlo) on 5 July 2020. The function should return `true` if a given string (case insensitive) is a palindrome and `false` if it's not the case. -**Note :** a **Palindrome** is a word, phrase, or sequence that reads the **same backwards as forwards**, e.g. Kayak. +**Note:** a **Palindrome** is a word, phrase, or sequence that reads the **same backwards as forwards**, e.g. Kayak. ## Examples diff --git a/challenges/is-palindrome/solutions/rust/function/Cargo.lock b/challenges/is-palindrome/solutions/rust/function/Cargo.lock new file mode 100644 index 0000000..c8ae10e --- /dev/null +++ b/challenges/is-palindrome/solutions/rust/function/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "rust_application" +version = "1.0.0" diff --git a/challenges/is-palindrome/solutions/rust/function/Cargo.toml b/challenges/is-palindrome/solutions/rust/function/Cargo.toml new file mode 100644 index 0000000..a119ace --- /dev/null +++ b/challenges/is-palindrome/solutions/rust/function/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "rust_application" +version = "1.0.0" +edition = "2021" + +[dependencies] diff --git a/challenges/is-palindrome/solutions/rust/function/README.md b/challenges/is-palindrome/solutions/rust/function/README.md new file mode 100644 index 0000000..014daa7 --- /dev/null +++ b/challenges/is-palindrome/solutions/rust/function/README.md @@ -0,0 +1,3 @@ +# is-palindrome/rust/function + +Created by [@Divlo](https://github.com/Divlo) on 4 January 2023. diff --git a/challenges/is-palindrome/solutions/rust/function/src/main.rs b/challenges/is-palindrome/solutions/rust/function/src/main.rs new file mode 100644 index 0000000..a6244ff --- /dev/null +++ b/challenges/is-palindrome/solutions/rust/function/src/main.rs @@ -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 = string.chars().collect(); + reverse.reverse(); + let reverse: String = reverse.into_iter().collect(); + let is_palindrome = reverse == string; + println!("{is_palindrome}"); +}