diff --git a/exercises/practice/armstrong-numbers/.meta/example.cairo b/exercises/practice/armstrong-numbers/.meta/example.cairo index edcaa330..b4011d4c 100644 --- a/exercises/practice/armstrong-numbers/.meta/example.cairo +++ b/exercises/practice/armstrong-numbers/.meta/example.cairo @@ -1,6 +1,6 @@ use alexandria_math::armstrong_number; -fn is_armstrong_number(num: u32) -> bool { +fn is_armstrong_number(num: u128) -> bool { armstrong_number::is_armstrong_number(num.into()) } diff --git a/exercises/practice/armstrong-numbers/src/lib.cairo b/exercises/practice/armstrong-numbers/src/lib.cairo index 76f3b347..563a2d32 100644 --- a/exercises/practice/armstrong-numbers/src/lib.cairo +++ b/exercises/practice/armstrong-numbers/src/lib.cairo @@ -1,4 +1,4 @@ -fn is_armstrong_number(num: u32) -> bool { +fn is_armstrong_number(num: u128) -> bool { panic!("true if {num} is an armstrong number") } diff --git a/exercises/practice/armstrong-numbers/src/tests.cairo b/exercises/practice/armstrong-numbers/src/tests.cairo index 00341f90..c9ae8a72 100644 --- a/exercises/practice/armstrong-numbers/src/tests.cairo +++ b/exercises/practice/armstrong-numbers/src/tests.cairo @@ -46,24 +46,11 @@ fn seven_digit_non_armstrong_number() { } #[test] -fn nine_digit_armstrong_number() { - assert!(is_armstrong_number(912_985_153)); +fn armstrong_number_containing_seven_zeroes() { + assert!(is_armstrong_number(186_709_961_001_538_790_100_634_132_976_990)); } #[test] -fn nine_digit_non_armstrong_number() { - assert!(!is_armstrong_number(999_999_999)); -} - -#[test] -fn ten_digit_non_armstrong_number() { - assert!(!is_armstrong_number(3_999_999_999)); -} - -// The following number has an Armstrong sum equal to 2^32 plus itself, -// and therefore will be detected as an Armstrong number if you are -// incorrectly using wrapping arithmetic. -#[test] -fn properly_handles_overflow() { - assert!(!is_armstrong_number(4_106_098_957)); +fn the_largest_and_last_armstrong_number() { + assert!(is_armstrong_number(115_132_219_018_763_992_565_095_597_973_971_522_401)); } diff --git a/exercises/practice/beer-song/src/tests.cairo b/exercises/practice/beer-song/src/tests.cairo index 1a345128..32965501 100644 --- a/exercises/practice/beer-song/src/tests.cairo +++ b/exercises/practice/beer-song/src/tests.cairo @@ -1,16 +1,16 @@ #[test] -fn verse_with_0_bottles() { +fn first_generic_verse() { assert_eq!( - beer_song::verse(0), - "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n" + beer_song::verse(99), + "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n" ); } #[test] -fn verse_with_1_bottle() { +fn last_generic_verse() { assert_eq!( - beer_song::verse(1), - "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n" + beer_song::verse(3), + "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n" ); } @@ -23,18 +23,18 @@ fn verse_with_2_bottles() { } #[test] -fn first_generic_verse() { +fn verse_with_1_bottle() { assert_eq!( - beer_song::verse(99), - "99 bottles of beer on the wall, 99 bottles of beer.\nTake one down and pass it around, 98 bottles of beer on the wall.\n" + beer_song::verse(1), + "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n" ); } #[test] -fn last_generic_verse() { +fn verse_with_0_bottles() { assert_eq!( - beer_song::verse(3), - "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n" + beer_song::verse(0), + "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n" ); }