From 0b65799555c93b3a2c9f28193ea67471b2286388 Mon Sep 17 00:00:00 2001 From: Tom Paoletti Date: Sun, 31 May 2026 08:33:52 -0700 Subject: [PATCH] 5_text_stats: adjust expected average word length --- examples/16_word_frequencies/5_text_stats.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/16_word_frequencies/5_text_stats.rs b/examples/16_word_frequencies/5_text_stats.rs index 0c3802e..e7c6896 100644 --- a/examples/16_word_frequencies/5_text_stats.rs +++ b/examples/16_word_frequencies/5_text_stats.rs @@ -23,9 +23,9 @@ fn test_text_stats() { let (total, unique, avg_len) = text_stats(text); assert_eq!(total, 3); assert_eq!(unique, 3); - assert!((avg_len - 4.33).abs() < 0.1); // Average length ≈ 4.33 + assert!((avg_len - 4.66).abs() < 0.01); // Average length ≈ 4.66 // Side note: floats don't compare exactly (the value here is - // really 13/3 = 4.333...), so we check that we're close enough + // really 14/3 = 4.666...), so we check that we're close enough // by taking the absolute difference and comparing to a tolerance. // Direct `==` on `f64` is almost always the wrong thing. }