// Iterators of Code 2026 — Day 15: Billable Minutes // Challenge: Summarize (minutes, billable) entries as (total minutes, entry count) // for billable work only. A zero-minute billable entry still counts. // Refactor to compute both totals in a single pass. Totals fit in u64. fn billing_summary(entries: &[(u32, bool)]) -> (u64, usize) { let mut total_minutes = 0; let mut entry_count = 0; for &(minutes, billable) in entries { if billable { total_minutes += u64::from(minutes); entry_count += 1; } } (total_minutes, entry_count) } fn main() { assert_eq!( billing_summary(&[(30, true), (15, false), (45, true), (0, true)]), (75, 3) ); assert_eq!(billing_summary(&[(0, true)]), (0, 1)); assert_eq!(billing_summary(&[(20, false), (0, false)]), (0, 0)); assert_eq!(billing_summary(&[]), (0, 0)); assert_eq!( billing_summary(&[(u32::MAX, true), (1, true)]), (u64::from(u32::MAX) + 1, 2) ); }