|
| 1 | +# Instructions |
| 2 | + |
| 3 | +You're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days. |
| 4 | + |
| 5 | +You have six tasks, all dealing with the numbers of birds that visited your garden. |
| 6 | + |
| 7 | +## 1. Check what the counts were last week |
| 8 | + |
| 9 | +For comparison purposes, you always keep a copy of last week's log nearby, |
| 10 | +which were: 0, 2, 5, 3, 7, 8 and 4. Implement the `last_week_log()` function |
| 11 | +that returns last week's log |
| 12 | + |
| 13 | +```rust |
| 14 | +last_week_log(); |
| 15 | +// => [0, 2, 5, 3, 7, 8, 4] |
| 16 | +``` |
| 17 | + |
| 18 | +## 2. Check how many birds visited today |
| 19 | + |
| 20 | +Implement the `count_today()` function to return how many birds visited your garden today. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count. |
| 21 | + |
| 22 | +```rust |
| 23 | +let watch_log = [ 2, 5, 0, 7, 4, 1 ]; |
| 24 | +count_today(watch_log); |
| 25 | +// => 1 |
| 26 | +``` |
| 27 | + |
| 28 | +## 3. Increment today's count |
| 29 | + |
| 30 | +Implement the `log_today()` function to increment today's count: |
| 31 | + |
| 32 | +```rust |
| 33 | +let watch_log = [ 2, 5, 0, 7, 4, 1 ]; |
| 34 | +log_today(watch_log); |
| 35 | +count_today(watch_log); |
| 36 | +// => 2 |
| 37 | +``` |
| 38 | + |
| 39 | +## 4. Check if there was a day with no visiting birds |
| 40 | + |
| 41 | +Implement the `has_day_without_birds()` method that returns `true` if there was a day at which zero birds visited the garden; otherwise, return `false`: |
| 42 | + |
| 43 | +```rust |
| 44 | +let watch_log = [ 2, 5, 0, 7, 4, 1 ]; |
| 45 | +has_day_without_birds(watch_log); |
| 46 | +// => true |
| 47 | +``` |
| 48 | + |
| 49 | +## 5. Calculate the number of visiting birds for the first x number of days |
| 50 | + |
| 51 | +Implement the `tally_days()` function that returns the number of birds that have visited your garden from the start of the week, but limit the count to the specified number of days from the start of the week. |
| 52 | + |
| 53 | +```rust |
| 54 | +let watch_log = [ 2, 5, 0, 7, 4, 1 ]; |
| 55 | +tally_days(watch_log, 4); |
| 56 | +// => 14 |
| 57 | +``` |
| 58 | + |
| 59 | +## 6. Calculate the number of busy days |
| 60 | + |
| 61 | +Some days are busier that others. A busy day is one where five or more birds have visited your garden. |
| 62 | +Implement the `calc_busy_days()` function to return the number of busy days: |
| 63 | + |
| 64 | +```rust |
| 65 | +let watch_log = [ 2, 5, 0, 7, 4, 1 ]; |
| 66 | +calc_busy_days(watch_log); |
| 67 | +// => 2 |
| 68 | +``` |
0 commit comments