Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update exercise's package manifest #2033

Merged
merged 5 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions exercises/concept/resistor-color/tests/resistor-color.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use resistor_color::{color_to_value, colors, value_to_color_string, ResistorColor};
use resistor_color::{ResistorColor, color_to_value, colors, value_to_color_string};

#[test]
fn black() {
Expand Down Expand Up @@ -50,6 +50,8 @@ fn all_colors() {
use ResistorColor::*;
assert_eq!(
colors(),
vec![Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Grey, White]
vec![
Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Grey, White
]
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use semi_structured_logs::{error, info, log, warn, LogLevel};
use semi_structured_logs::{LogLevel, error, info, log, warn};

#[test]
fn emits_info() {
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/allergies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ impl Allergies {
}

pub fn allergies(&self) -> Vec<Allergen> {
todo!("Return the list of allergens contained within the score with which the Allergies struct was made.");
todo!(
"Return the list of allergens contained within the score with which the Allergies struct was made."
);
}
}
4 changes: 3 additions & 1 deletion exercises/practice/alphametics/tests/alphametics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ fn puzzle_with_ten_letters() {
#[test]
#[ignore]
fn puzzle_with_ten_letters_and_199_addends() {
let answer = solve("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES");
let answer = solve(
"THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + TROLL + TERRIFIES + THE + HORSES + OF + FIRE + THE + TROLL + RESTS + AT + THE + HOLE + OF + LOSSES + IT + IS + THERE + THAT + SHE + STORES + ROLES + OF + LEATHERS + AFTER + SHE + SATISFIES + HER + HATE + OFF + THOSE + FEARS + A + TASTE + RISES + AS + SHE + HEARS + THE + LEAST + FAR + HORSE + THOSE + FAST + HORSES + THAT + FIRST + HEAR + THE + TROLL + FLEE + OFF + TO + THE + FOREST + THE + HORSES + THAT + ALERTS + RAISE + THE + STARES + OF + THE + OTHERS + AS + THE + TROLL + ASSAILS + AT + THE + TOTAL + SHIFT + HER + TEETH + TEAR + HOOF + OFF + TORSO + AS + THE + LAST + HORSE + FORFEITS + ITS + LIFE + THE + FIRST + FATHERS + HEAR + OF + THE + HORRORS + THEIR + FEARS + THAT + THE + FIRES + FOR + THEIR + FEASTS + ARREST + AS + THE + FIRST + FATHERS + RESETTLE + THE + LAST + OF + THE + FIRE + HORSES + THE + LAST + TROLL + HARASSES + THE + FOREST + HEART + FREE + AT + LAST + OF + THE + LAST + TROLL + ALL + OFFER + THEIR + FIRE + HEAT + TO + THE + ASSISTERS + FAR + OFF + THE + TROLL + FASTS + ITS + LIFE + SHORTER + AS + STARS + RISE + THE + HORSES + REST + SAFE + AFTER + ALL + SHARE + HOT + FISH + AS + THEIR + AFFILIATES + TAILOR + A + ROOFS + FOR + THEIR + SAFE == FORTRESSES",
);
let expected = [
('A', 1),
('E', 0),
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/book-store/tests/book-store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ fn four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three() {

#[test]
#[ignore]
fn check_that_groups_of_four_are_created_properly_even_when_there_are_more_groups_of_three_than_groups_of_five(
) {
fn check_that_groups_of_four_are_created_properly_even_when_there_are_more_groups_of_three_than_groups_of_five()
{
let input = &[
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5,
];
Expand Down
8 changes: 4 additions & 4 deletions exercises/practice/bowling/tests/bowling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ fn two_bonus_rolls_after_a_strike_in_the_last_frame_cannot_score_more_than_10_po

#[test]
#[ignore]
fn two_bonus_rolls_after_a_strike_in_the_last_frame_can_score_more_than_10_points_if_one_is_a_strike(
) {
fn two_bonus_rolls_after_a_strike_in_the_last_frame_can_score_more_than_10_points_if_one_is_a_strike()
{
let mut game = BowlingGame::new();

for _ in 0..18 {
Expand All @@ -331,8 +331,8 @@ fn two_bonus_rolls_after_a_strike_in_the_last_frame_can_score_more_than_10_point

#[test]
#[ignore]
fn the_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike(
) {
fn the_second_bonus_rolls_after_a_strike_in_the_last_frame_cannot_be_a_strike_if_the_first_one_is_not_a_strike()
{
let mut game = BowlingGame::new();

for _ in 0..18 {
Expand Down
12 changes: 9 additions & 3 deletions exercises/practice/circular-buffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ impl<T> CircularBuffer<T> {
}

pub fn write(&mut self, _element: T) -> Result<(), Error> {
todo!("Write the passed element to the CircularBuffer or return FullBuffer error if CircularBuffer is full.");
todo!(
"Write the passed element to the CircularBuffer or return FullBuffer error if CircularBuffer is full."
);
}

pub fn read(&mut self) -> Result<T, Error> {
todo!("Read the oldest element from the CircularBuffer or return EmptyBuffer error if CircularBuffer is empty.");
todo!(
"Read the oldest element from the CircularBuffer or return EmptyBuffer error if CircularBuffer is empty."
);
}

pub fn clear(&mut self) {
todo!("Clear the CircularBuffer.");
}

pub fn overwrite(&mut self, _element: T) {
todo!("Write the passed element to the CircularBuffer, overwriting the existing elements if CircularBuffer is full.");
todo!(
"Write the passed element to the CircularBuffer, overwriting the existing elements if CircularBuffer is full."
);
}
}
4 changes: 3 additions & 1 deletion exercises/practice/dominoes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn chain(input: &[(u8, u8)]) -> Option<Vec<(u8, u8)>> {
todo!("From the given input '{input:?}' construct a proper dominoes chain or return None if it is not possible.");
todo!(
"From the given input '{input:?}' construct a proper dominoes chain or return None if it is not possible."
);
}
4 changes: 3 additions & 1 deletion exercises/practice/minesweeper/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn annotate(minefield: &[&str]) -> Vec<String> {
todo!("\nAnnotate each square of the given minefield with the number of mines that surround said square (blank if there are no surrounding mines):\n{minefield:#?}\n");
todo!(
"\nAnnotate each square of the given minefield with the number of mines that surround said square (blank if there are no surrounding mines):\n{minefield:#?}\n"
);
}
5 changes: 4 additions & 1 deletion exercises/practice/nucleotide-codons/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ impl<'a> CodonsInfo<'a> {
}

pub fn of_rna(&self, rna: &str) -> Result<Vec<&'a str>, Error> {
todo!("Return a list of protein names that correspond to the '{}' RNA string or Err if the RNA string is invalid", rna);
todo!(
"Return a list of protein names that correspond to the '{}' RNA string or Err if the RNA string is invalid",
rna
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/poker/tests/poker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ fn both_hands_have_three_of_a_kind_tie_goes_to_highest_ranked_triplet() {

#[test]
#[ignore]
fn with_multiple_decks_two_players_can_have_same_three_of_a_kind_ties_go_to_highest_remaining_cards(
) {
fn with_multiple_decks_two_players_can_have_same_three_of_a_kind_ties_go_to_highest_remaining_cards()
{
let input = &["5S AH AS 7C AD", "4S AH AS 8C AD"];
let output = winning_hands(input).into_iter().collect::<HashSet<_>>();
let expected = ["4S AH AS 8C AD"].into_iter().collect::<HashSet<_>>();
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/protein-translation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn translate(rna: &str) -> Option<Vec<&str>> {
todo!("Return a list of protein names that correspond to the '{rna}' RNA string or None if the RNA string is invalid");
todo!(
"Return a list of protein names that correspond to the '{rna}' RNA string or None if the RNA string is invalid"
);
}
4 changes: 3 additions & 1 deletion exercises/practice/pythagorean-triplet/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::collections::HashSet;

pub fn find(sum: u32) -> HashSet<[u32; 3]> {
todo!("Given the sum {sum}, return all possible Pythagorean triplets, which produce the said sum, or an empty HashSet if there are no such triplets. Note that you are expected to return triplets in [a, b, c] order, where a < b < c");
todo!(
"Given the sum {sum}, return all possible Pythagorean triplets, which produce the said sum, or an empty HashSet if there are no such triplets. Note that you are expected to return triplets in [a, b, c] order, where a < b < c"
);
}
4 changes: 2 additions & 2 deletions exercises/practice/queen-attack/tests/queen-attack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ fn can_attack_on_fourth_diagonal() {

#[test]
#[ignore]
fn cannot_attack_if_falling_diagonals_are_only_the_same_when_reflected_across_the_longest_falling_diagonal(
) {
fn cannot_attack_if_falling_diagonals_are_only_the_same_when_reflected_across_the_longest_falling_diagonal()
{
let white_queen = Queen::new(ChessPosition::new(4, 1).unwrap());
let black_queen = Queen::new(ChessPosition::new(2, 5).unwrap());
assert!(!white_queen.can_attack(&black_queen));
Expand Down
80 changes: 50 additions & 30 deletions exercises/practice/react/tests/react.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ fn compute_cells_fire_callbacks() {
let output = reactor
.create_compute(&[CellId::Input(input)], |v| v[0] + 1)
.unwrap();
assert!(reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some()
);
assert!(reactor.set_value(input, 3));
cb.expect_to_have_been_called_with(4);
}
Expand Down Expand Up @@ -226,9 +228,11 @@ fn callbacks_only_fire_on_change() {
|v| if v[0] < 3 { 111 } else { 222 },
)
.unwrap();
assert!(reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some()
);

assert!(reactor.set_value(input, 2));
cb.expect_not_to_have_been_called();
Expand All @@ -245,9 +249,11 @@ fn callbacks_can_be_called_multiple_times() {
let output = reactor
.create_compute(&[CellId::Input(input)], |v| v[0] + 1)
.unwrap();
assert!(reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some()
);

assert!(reactor.set_value(input, 2));
cb.expect_to_have_been_called_with(3);
Expand All @@ -268,12 +274,16 @@ fn callbacks_can_be_called_from_multiple_cells() {
let minus_one = reactor
.create_compute(&[CellId::Input(input)], |v| v[0] - 1)
.unwrap();
assert!(reactor
.add_callback(plus_one, |v| cb1.callback_called(v))
.is_some());
assert!(reactor
.add_callback(minus_one, |v| cb2.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(plus_one, |v| cb1.callback_called(v))
.is_some()
);
assert!(
reactor
.add_callback(minus_one, |v| cb2.callback_called(v))
.is_some()
);

assert!(reactor.set_value(input, 10));
cb1.expect_to_have_been_called_with(11);
Expand All @@ -296,18 +306,22 @@ fn callbacks_can_be_added_and_removed() {
let callback = reactor
.add_callback(output, |v| cb1.callback_called(v))
.unwrap();
assert!(reactor
.add_callback(output, |v| cb2.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb2.callback_called(v))
.is_some()
);

assert!(reactor.set_value(input, 31));
cb1.expect_to_have_been_called_with(32);
cb2.expect_to_have_been_called_with(32);

assert!(reactor.remove_callback(output, callback).is_ok());
assert!(reactor
.add_callback(output, |v| cb3.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb3.callback_called(v))
.is_some()
);

assert!(reactor.set_value(input, 41));
cb1.expect_not_to_have_been_called();
Expand All @@ -329,9 +343,11 @@ fn removing_a_callback_multiple_times_doesnt_interfere_with_other_callbacks() {
let callback = reactor
.add_callback(output, |v| cb1.callback_called(v))
.unwrap();
assert!(reactor
.add_callback(output, |v| cb2.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb2.callback_called(v))
.is_some()
);
// We want the first remove to be Ok, but the others should be errors.
assert!(reactor.remove_callback(output, callback).is_ok());
for _ in 1..5 {
Expand Down Expand Up @@ -367,9 +383,11 @@ fn callbacks_should_only_be_called_once_even_if_multiple_dependencies_change() {
|v| v[0] * v[1],
)
.unwrap();
assert!(reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(output, |v| cb.callback_called(v))
.is_some()
);
assert!(reactor.set_value(input, 4));
cb.expect_to_have_been_called_with(10);
}
Expand All @@ -392,9 +410,11 @@ fn callbacks_should_not_be_called_if_dependencies_change_but_output_value_doesnt
|v| v[0] - v[1],
)
.unwrap();
assert!(reactor
.add_callback(always_two, |v| cb.callback_called(v))
.is_some());
assert!(
reactor
.add_callback(always_two, |v| cb.callback_called(v))
.is_some()
);
for i in 2..5 {
assert!(reactor.set_value(input, i));
cb.expect_not_to_have_been_called();
Expand Down
4 changes: 3 additions & 1 deletion exercises/practice/rectangles/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub fn count(lines: &[&str]) -> u32 {
todo!("\nDetermine the count of rectangles in the ASCII diagram represented by the following lines:\n{lines:#?}\n.");
todo!(
"\nDetermine the count of rectangles in the ASCII diagram represented by the following lines:\n{lines:#?}\n."
);
}
8 changes: 6 additions & 2 deletions exercises/practice/rna-transcription/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ pub struct Rna;

impl Dna {
pub fn new(dna: &str) -> Result<Dna, usize> {
todo!("Construct new Dna from '{dna}' string. If string contains invalid nucleotides return index of first invalid nucleotide");
todo!(
"Construct new Dna from '{dna}' string. If string contains invalid nucleotides return index of first invalid nucleotide"
);
}

pub fn into_rna(self) -> Rna {
Expand All @@ -16,6 +18,8 @@ impl Dna {

impl Rna {
pub fn new(rna: &str) -> Result<Rna, usize> {
todo!("Construct new Rna from '{rna}' string. If string contains invalid nucleotides return index of first invalid nucleotide");
todo!(
"Construct new Rna from '{rna}' string. If string contains invalid nucleotides return index of first invalid nucleotide"
);
}
}
4 changes: 3 additions & 1 deletion exercises/practice/sublist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ pub enum Comparison {
}

pub fn sublist(first_list: &[i32], second_list: &[i32]) -> Comparison {
todo!("Determine if the {first_list:?} is equal to, sublist of, superlist of or unequal to {second_list:?}.");
todo!(
"Determine if the {first_list:?} is equal to, sublist of, superlist of or unequal to {second_list:?}."
);
}
4 changes: 3 additions & 1 deletion exercises/practice/triangle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ pub struct Triangle;

impl Triangle {
pub fn build(sides: [u64; 3]) -> Option<Triangle> {
todo!("Construct new Triangle from following sides: {sides:?}. Return None if the sides are invalid.");
todo!(
"Construct new Triangle from following sides: {sides:?}. Return None if the sides are invalid."
);
}

pub fn is_equilateral(&self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/two-bucket/tests/two-bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ fn measure_one_step_using_bucket_one_of_size_1_and_bucket_two_of_size_3_start_wi

#[test]
#[ignore]
fn measure_using_bucket_one_of_size_2_and_bucket_two_of_size_3_start_with_bucket_one_and_end_with_bucket_two(
) {
fn measure_using_bucket_one_of_size_2_and_bucket_two_of_size_3_start_with_bucket_one_and_end_with_bucket_two()
{
let output = solve(2, 3, 3, &Bucket::One);
let expected = Some(BucketStats {
moves: 2,
Expand Down