feat: 3280_convert_date_to_binary
This commit is contained in:
parent
18d9c661e8
commit
758200be5c
7
3280_convert_date_to_binary/Cargo.lock
generated
Normal file
7
3280_convert_date_to_binary/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "convert_date_to_binary"
|
||||
version = "0.1.0"
|
6
3280_convert_date_to_binary/Cargo.toml
Normal file
6
3280_convert_date_to_binary/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "convert_date_to_binary"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
12
3280_convert_date_to_binary/src/lib.rs
Normal file
12
3280_convert_date_to_binary/src/lib.rs
Normal file
@ -0,0 +1,12 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn convert_date_to_binary(date: String) -> String {
|
||||
let [y, m, d]: [i32; 3] = date.split('-')
|
||||
.map(|num_str| num_str.parse().unwrap())
|
||||
.collect::<Vec<i32>>()
|
||||
.try_into()
|
||||
.unwrap();
|
||||
format!("{:b}-{:b}-{:b}", y, m, d)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user