feat: add initial implementation of Cargo.toml and Cargo.lock files along with main function and Solution struct
This commit is contained in:
parent
2a5ebdad4c
commit
a442d1cd09
7
2894_divisible_and_non_divisible_sums_difference/Cargo.lock
generated
Normal file
7
2894_divisible_and_non_divisible_sums_difference/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 = "divisible_and_non_divisible_sums_difference"
|
||||||
|
version = "0.1.0"
|
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "divisible_and_non_divisible_sums_difference"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
14
2894_divisible_and_non_divisible_sums_difference/src/main.rs
Normal file
14
2894_divisible_and_non_divisible_sums_difference/src/main.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Solution;
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn difference_of_sums(n: i32, m: i32) -> i32 {
|
||||||
|
let (dividable, undividable): (Vec<i32>, Vec<i32>) =
|
||||||
|
(1..(n + 1)).partition(|&val| val % m == 0);
|
||||||
|
|
||||||
|
undividable.iter().sum::<i32>() - dividable.iter().sum::<i32>()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user