Compare commits
No commits in common. "bf3efe73e070967d3d025bdf2a1f79a29bedb255" and "24a619b9e8eb2d92944e9e116edbe0a027e42eba" have entirely different histories.
bf3efe73e0
...
24a619b9e8
@ -60,8 +60,8 @@ We encourage you to share your progress and ask questions in the Discussions sec
|
|||||||
| Day #11 | [Restore IP Addresses](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-11_Restore-IP-Addresses) | :white_check_mark: |
|
| Day #11 | [Restore IP Addresses](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-11_Restore-IP-Addresses) | :white_check_mark: |
|
||||||
| Day #12 | [Mountains or Valleys](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-12_Mountains_And_Valleys) | :white_check_mark: |
|
| Day #12 | [Mountains or Valleys](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-12_Mountains_And_Valleys) | :white_check_mark: |
|
||||||
| Day #13 | [Need Help With Your Packing](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-13_Need-Help-With-Packing) | :white_check_mark: |
|
| Day #13 | [Need Help With Your Packing](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-13_Need-Help-With-Packing) | :white_check_mark: |
|
||||||
| Day #14 | [The Karacas Encryption Algorithm](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-14_Karacas-Encryption-Algorithm) | :white_check_mark: |
|
| Day #14 | [The Karacas Encryption Algorithm](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-02/Day-14_Karacas-Encryption-Algorithm) | :white_large_square: |
|
||||||
| Day #15 | [Valid Anagram](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-15_Valid-Anagram) | :white_check_mark: |
|
| Day #15 | [Valid Anagram](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-15_Valid-Anagram) | :white_large_square: |
|
||||||
| Day #16 | [Nim Game](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-16_Nim-Game) | :white_large_square: |
|
| Day #16 | [Nim Game](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-16_Nim-Game) | :white_large_square: |
|
||||||
| Day #17 | [Prison Break](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-17_Prison-Break) | :white_large_square: |
|
| Day #17 | [Prison Break](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-17_Prison-Break) | :white_large_square: |
|
||||||
| Day #18 | [Unique Paths](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-18_Unique-Paths) | :white_large_square: |
|
| Day #18 | [Unique Paths](https://github.com/LiveGray/100-Days-Of-Rust/tree/main/Week-03/Day-18_Unique-Paths) | :white_large_square: |
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "day14"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -1,18 +0,0 @@
|
|||||||
pub fn encrypt(plaintext: &str) -> String {
|
|
||||||
let mut encrypted = String::new();
|
|
||||||
|
|
||||||
for c in plaintext.chars().rev() {
|
|
||||||
encrypted.push(match c {
|
|
||||||
'a' => '0',
|
|
||||||
'e' => '1',
|
|
||||||
'i' => '2',
|
|
||||||
'o' => '2',
|
|
||||||
'u' => '3',
|
|
||||||
_ => c,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
encrypted.push_str("aca");
|
|
||||||
|
|
||||||
encrypted
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
use day14::encrypt;
|
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut buffer = String::new();
|
|
||||||
|
|
||||||
print!("Insert the string you want to encrypt: ");
|
|
||||||
io::stdout().flush().expect("Failed to flush stout.");
|
|
||||||
|
|
||||||
io::stdin()
|
|
||||||
.read_line(&mut buffer)
|
|
||||||
.expect("Failed to read from stdin.");
|
|
||||||
|
|
||||||
println!("Your message encrypted is: {}", encrypt(buffer.trim()));
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
use day14::encrypt;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example1() {
|
|
||||||
assert_eq!(encrypt("banana"), "0n0n0baca");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example2() {
|
|
||||||
assert_eq!(encrypt("karaca"), "0c0r0kaca");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example3() {
|
|
||||||
assert_eq!(encrypt("burak"), "k0r3baca");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example4() {
|
|
||||||
assert_eq!(encrypt("alpaca"), "0c0pl0aca");
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "day15"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
@ -1,14 +0,0 @@
|
|||||||
pub fn is_anagram(s: &str, t: &str) -> bool {
|
|
||||||
let mut t = t.to_string();
|
|
||||||
|
|
||||||
for c in s.chars() {
|
|
||||||
if let Some(index) = t.find(c) {
|
|
||||||
let (before, after) = t.split_at(index);
|
|
||||||
t = format!("{}{}", before, &after[1..]);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
true
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
use day15::is_anagram;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let mut buffer = String::new();
|
|
||||||
|
|
||||||
print!("Insert the first string: ");
|
|
||||||
io::stdout().flush().expect("Failed to flush stdout.");
|
|
||||||
|
|
||||||
io::stdin()
|
|
||||||
.read_line(&mut buffer)
|
|
||||||
.expect("Failed to read from input");
|
|
||||||
|
|
||||||
let s = buffer.trim();
|
|
||||||
let mut buffer = String::new();
|
|
||||||
|
|
||||||
print!("Insert the first string: ");
|
|
||||||
io::stdout().flush().expect("Failed to flush stdout.");
|
|
||||||
|
|
||||||
io::stdin()
|
|
||||||
.read_line(&mut buffer)
|
|
||||||
.expect("Failed to read from input");
|
|
||||||
|
|
||||||
if is_anagram(s, buffer.trim()) {
|
|
||||||
println!("{s} is the anagram of {buffer}");
|
|
||||||
} else {
|
|
||||||
println!("{s} is not the anagram of {buffer}")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
use day15::is_anagram;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example1() {
|
|
||||||
assert!(is_anagram("anagram", "nagaram"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn example2() {
|
|
||||||
assert!(!is_anagram("rat", "car"));
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user