Skip to content
Open
Changes from all commits
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
16 changes: 13 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn validate_grading_system() {

/// Calculate the grade
fn calculate_grade(carrots: i32, nuts: i32, seeds: i32) -> i32 {
todo!()
(carrots + nuts) * (carrots + nuts + seeds)
}

/// Validate the safety system
Expand All @@ -49,7 +49,7 @@ fn calculate_safety_status(
has_carrot: bool,
friends_nearby: i32,
) -> bool {
todo!()
!wolves_nearby && day_time || has_carrot || friends_nearby > 3
}

/// Validate the simulation
Expand All @@ -67,7 +67,17 @@ fn validate_simulation() {

/// Simulate the rabbit population
fn simulate(starting_rabbits: i128) -> i32 {
todo!()
let mut days: i32 = 0;
let mut rabbits: i128 = starting_rabbits;
while rabbits > 1 {
if rabbits % 2 == 0 {
rabbits = rabbits / 2;
} else {
rabbits = rabbits * 3 + 1;
}
days += 1;
}
days
}

#[cfg(test)]
Expand Down