From 554ac3b526112436a98d9ad3f85d1c930ce73f4f Mon Sep 17 00:00:00 2001 From: kaushik713 <47024279+kaushik713@users.noreply.github.com> Date: Sat, 26 Jan 2019 06:33:32 +0530 Subject: [PATCH 1/3] palindrome.rs this is a program for palindrome --- palindrome | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 palindrome diff --git a/palindrome b/palindrome new file mode 100644 index 0000000..e47f12c --- /dev/null +++ b/palindrome @@ -0,0 +1,14 @@ +use std::io; +fn main(){ +//here we take input + let mut num=String::new(); + io::stdin().read_line(&mut num).expect(""); + //here we use len() to find length of string + let half_len = num.len()/2; + // here we use take() for taking a substring and eq for comparing + //here we check palindrome + if num.chars().take(half_len).eq(num.chars().rev().take(half_len)) + {println!("it is palindrome");} + else + { println!("it is not palindrome");} +} From 408e932e7a331033c3c92fd38d8887685751af05 Mon Sep 17 00:00:00 2001 From: kaushik713 <47024279+kaushik713@users.noreply.github.com> Date: Sat, 26 Jan 2019 06:39:56 +0530 Subject: [PATCH 2/3] checking if a string is palindrome --- src/trivial_demonstrations/palindrome.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/trivial_demonstrations/palindrome.rs diff --git a/src/trivial_demonstrations/palindrome.rs b/src/trivial_demonstrations/palindrome.rs new file mode 100644 index 0000000..e47f12c --- /dev/null +++ b/src/trivial_demonstrations/palindrome.rs @@ -0,0 +1,14 @@ +use std::io; +fn main(){ +//here we take input + let mut num=String::new(); + io::stdin().read_line(&mut num).expect(""); + //here we use len() to find length of string + let half_len = num.len()/2; + // here we use take() for taking a substring and eq for comparing + //here we check palindrome + if num.chars().take(half_len).eq(num.chars().rev().take(half_len)) + {println!("it is palindrome");} + else + { println!("it is not palindrome");} +} From f2fd6ce85e5d1af3dfd026224cecffc1064a741a Mon Sep 17 00:00:00 2001 From: kaushik713 <47024279+kaushik713@users.noreply.github.com> Date: Sat, 26 Jan 2019 06:40:22 +0530 Subject: [PATCH 3/3] Delete palindrome --- palindrome | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 palindrome diff --git a/palindrome b/palindrome deleted file mode 100644 index e47f12c..0000000 --- a/palindrome +++ /dev/null @@ -1,14 +0,0 @@ -use std::io; -fn main(){ -//here we take input - let mut num=String::new(); - io::stdin().read_line(&mut num).expect(""); - //here we use len() to find length of string - let half_len = num.len()/2; - // here we use take() for taking a substring and eq for comparing - //here we check palindrome - if num.chars().take(half_len).eq(num.chars().rev().take(half_len)) - {println!("it is palindrome");} - else - { println!("it is not palindrome");} -}