Skip to content

Commit

Permalink
sum_of_multiples
Browse files Browse the repository at this point in the history
  • Loading branch information
Falilah committed Sep 29, 2024
1 parent 9731348 commit b4c848e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/sum-of-multiples/.meta/example.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub fn sum_of_multiple(limit: u32, factors: Array<u32>) -> u32 {
pub fn sum_of_multiples(limit: u32, factors: Array<u32>) -> u32 {
let mut multiples: Array<u32> = ArrayTrait::new();

let mut i = 0;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/sum-of-multiples/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub fn sum_of_multiple(limit: u32, factors: Array<u32>) -> u32 {
pub fn sum_of_multiples(limit: u32, factors: Array<u32>) -> u32 {
panic!("implement `sum_of_multiples`")
}
34 changes: 17 additions & 17 deletions exercises/practice/sum-of-multiples/tests/sum_of_multiples.cairo
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use sum_of_multiples::sum_of_multiple;
use sum_of_multiples::sum_of_multiples;

#[test]
fn no_multiples_within_limit() {
let mut factors: Array<u32> = ArrayTrait::new();
factors.append(3);
factors.append(5);
let limit = 1;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 0, 'Test failed: Expected 0.');
}

Expand All @@ -17,7 +17,7 @@ fn one_factor_has_multiples_within_limit() {
factors.append(3);
factors.append(5);
let limit = 4;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 3, 'Test failed: Expected 3.');
}

Expand All @@ -27,7 +27,7 @@ fn more_than_one_multiple_within_limit() {
let mut factors: Array<u32> = ArrayTrait::new();
factors.append(3);
let limit = 7;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 9, 'Test failed: Expected 9.');
}

Expand All @@ -38,7 +38,7 @@ fn more_than_one_factor_with_multiples_within_limit() {
factors.append(3);
factors.append(5);
let limit = 10;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 23, 'Test failed: Expected 23.');
}

Expand All @@ -49,7 +49,7 @@ fn each_multiple_is_only_counted_once() {
factors.append(3);
factors.append(5);
let limit = 100;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 2318, 'Test failed: Expected 2318.');
}

Expand All @@ -60,7 +60,7 @@ fn a_much_larger_limit() {
factors.append(3);
factors.append(5);
let limit = 1000;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 233168, 'Test failed: Expected 233168.');
}

Expand All @@ -72,7 +72,7 @@ fn three_factors() {
factors.append(13);
factors.append(17);
let limit = 20;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 51, 'Test failed: Expected 51.');
}

Expand All @@ -83,7 +83,7 @@ fn factors_not_relatively_prime() {
factors.append(4);
factors.append(6);
let limit = 15;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 30, 'Test failed: Expected 30.');
}

Expand All @@ -95,7 +95,7 @@ fn some_pairs_of_factors_relatively_prime_and_some_not() {
factors.append(6);
factors.append(8);
let limit = 150;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 4419, 'Test failed: Expected 4419.');
}

Expand All @@ -106,7 +106,7 @@ fn one_factor_is_a_multiple_of_another() {
factors.append(5);
factors.append(25);
let limit = 51;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 275, 'Test failed: Expected 275.');
}

Expand All @@ -117,7 +117,7 @@ fn much_larger_factors() {
factors.append(43);
factors.append(47);
let limit = 10000;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 2203160, 'Test failed: Expected 2203160.');
}

Expand All @@ -127,7 +127,7 @@ fn all_numbers_are_multiples_of_1() {
let mut factors: Array<u32> = ArrayTrait::new();
factors.append(1);
let limit = 100;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 4950, 'Test failed: Expected 4950.');
}

Expand All @@ -136,7 +136,7 @@ fn all_numbers_are_multiples_of_1() {
fn no_factors_means_an_empty_sum() {
let mut factors: Array<u32> = ArrayTrait::new();
let limit = 10000;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 0, 'Test failed: Expected 0.');
}

Expand All @@ -146,7 +146,7 @@ fn the_only_multiple_of_0_is_0() {
let mut factors: Array<u32> = ArrayTrait::new();
factors.append(0);
let limit = 1;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 0, 'Test failed: Expected 0.');
}

Expand All @@ -157,7 +157,7 @@ fn the_factor_0_does_not_affect_the_sum_of_multiples_of_other_factors() {
factors.append(3);
factors.append(0);
let limit = 4;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 3, 'Test failed: Expected 3.');
}

Expand All @@ -171,6 +171,6 @@ fn solutions_using_include_exclude_must_extend_to_cardinality_greater_than_3() {
factors.append(7);
factors.append(11);
let limit = 1500;
let output = sum_of_multiple(limit, factors);
let output = sum_of_multiples(limit, factors);
assert(output == 888403, 'Test failed: Expected 888403.');
}

0 comments on commit b4c848e

Please sign in to comment.