Sliding-Window Mean With IEEE-754 Infinities and NaNs
Medium · Software Engineering Fundamentals · Data Scientist · Online Assessment
Problem Statement
Telemetry and financial signal streams often interleave ordinary floating-point readings with IEEE-754 special markers: NaN (missing or corrupt sample), +inf (positive saturation), and -inf (negative saturation). Updating a naive rolling sum with total += incoming - outgoing breaks as soon as a special value slides through, because NaN - NaN and inf - inf both evaluate to NaN and corrupt every window that follows.
Implement sliding_window_mean(nums, k) to return the arithmetic mean of every contiguous subarray nums[s : s + k] of length k (for 0 <= s <= len(nums) - k; return an empty sequence if k <= 0 or k > len(nums)).
Python signature (used by the test runner):
def sliding_window_mean(nums: List[float], k: int) -> List[float]:
Equivalent C++ signature:
std::vector<float> sliding_window_mean(const std::vector<float>& nums, int k);
Evaluate each window of length k using the following strict precedence order:
NaNdominance: If one or more elements inside the window areNaN, the window's result isNaN(even when infinities are also present).- Opposing infinities: If the window contains no
NaN, at least one+inf, and at least one-inf, the sum has an indeterminate sign, so the window's result isNaN. - Positive infinity: If the window contains
+infand neitherNaNnor-inf, the window's result is+inf. - Negative infinity: If the window contains
-infand neitherNaNnor+inf, the window's result is-inf. - All finite entries: When all
kelements are finite, return(nums[s] + ... + nums[s + k - 1]) / kwithout losing precision to earlier large-magnitude values. - Zero residual corruption: Once any
NaN,+inf,-inf, or extreme finite spike slides out of the window, later windows must compute clean, uncorrupted results.
Examples
Example 1
Input: nums = [3.0, NaN, 6.0, 9.0, 12.0], k = 3
Output: [NaN, NaN, 9.0]
Walk-through:
- nums[0:3] = [3.0, NaN, 6.0] contains NaN, producing NaN.
- nums[1:4] = [NaN, 6.0, 9.0] still contains NaN, producing NaN.
- nums[2:5] = [6.0, 9.0, 12.0] has evicted NaN; all three values are finite, so the mean is (6.0 + 9.0 + 12.0) / 3 = 9.0.
Example 2
Input: nums = [5.0, inf, -inf, 2.0, 6.0], k = 2
Output: [inf, NaN, -inf, 4.0]
Walk-through:
- nums[0:2] = [5.0, inf] holds +inf with no NaN or -inf, producing inf.
- nums[1:3] = [inf, -inf] holds both +inf and -inf, producing NaN.
- nums[2:4] = [-inf, 2.0] holds only -inf plus a finite value, producing -inf.
- nums[3:5] = [2.0, 6.0] is purely finite after -inf leaves, producing (2.0 + 6.0) / 2 = 4.0.
Example 3
Input: nums = [NaN, inf, 10.0, 20.0], k = 2
Output: [NaN, inf, 15.0]
Walk-through: In nums[0:2] = [NaN, inf], NaN outranks +inf to yield NaN. Once NaN exits, nums[1:3] = [inf, 10.0] yields inf, and once inf exits, nums[2:4] = [10.0, 20.0] yields 15.0.
Constraints
1 <= k <= len(nums) <= 1,000,000- Elements are IEEE-754 floating-point values (
32-bitfloatin C++,floatin Python), including finite values,+inf,-inf, andNaN - Time complexity:
O(n)wheren = len(nums) - Auxiliary space complexity:
O(1)beyond the returned output array/list
Step-by-step walkthrough
Restate the precedence rules and complexity targets
We are given an array
numsofnfloating-point numbers (1 <= k <= n <= 1,000,000) encoded in IEEE-754 (the universal hardware standard that defines binary floating-point numbers plus special values+inf,-inf, andNaNmeaning"Not a Number"). We need to returnn - k + 1window means inO(n)time andO(1)extra memory, checking each windownums[s : s + k]in this exact priority order:Priority 1: at least one NaN present -> NaN Priority 2: both +inf and -inf present -> NaN (because +inf + (-inf) is undefined) Priority 3: +inf present (no NaN, no -inf) -> +inf Priority 4: -inf present (no NaN, no +inf) -> -inf Priority 5: all k values are finite -> (sum of the k values) / kBecause this coding sandbox executes Python, we build and test the exact algorithm in Python first and also provide the equivalent production C++17 implementation below.
Why a naive running sum gets permanently poisoned
Summing
kelements from scratch for every window takesO(n * k)additions—around2.5 * 10^11operations whenn = 1,000,000andk = 500,000, which is far too slow.The textbook
O(n)sliding-window shortcut maintains a single running sum (running_sum += entering - leaving). Unfortunately, IEEE-754 special values cannot be subtracted back out:running_sum = 3.0 + NaN enters: 3.0 + NaN = NaN - NaN leaves: NaN - NaN = NaN <-- stuck as NaN forever! running_sum = 5.0 + inf enters: 5.0 + inf = inf - inf leaves: inf - inf = NaN <-- also turns into NaN forever!Once a single
NaNorinftouchesrunning_sum, every future window outputsNaNeven after the rest of the stream is completely clean. That is the poisoning bug forbidden by our eviction requirement.Separate exact integer counters from the finite sum
To keep the floating-point sum clean, never add
NaN,+inf, or-infto the sum. Instead, track how many of each special value currently sit inside the window using three plain integers:nan_count,pos_inf_count, andneg_inf_count.When an element enters (
direction = +1) we increment its counter; when it slides out (direction = -1) we decrement its counter. Because integer addition and subtraction are exact, each counter returns cleanly to0the instant the last special value exits! Only ordinary finite numbers are sent to the floating-point accumulator:import math class _WindowState: """Tracks special-value counts and a compensated finite sum for the active window.""" def __init__(self) -> None: self.nan_count = 0 self.pos_inf_count = 0 self.neg_inf_count = 0 self.total = 0.0 self.comp = 0.0 def add_finite(self, x: float) -> None: self.total += x # upgraded to compensated addition in the next step def update(self, x: float, direction: int) -> None: """Update window state: `direction` is +1 when `x` enters and -1 when `x` leaves.""" if math.isnan(x): self.nan_count += direction elif x == math.inf: self.pos_inf_count += direction elif x == -math.inf: self.neg_inf_count += direction else: self.add_finite(direction * x) def mean(self, k: int) -> float: """Evaluate the window mean following IEEE-754 precedence rules 1 through 5.""" if self.nan_count > 0: return math.nan if self.pos_inf_count > 0 and self.neg_inf_count > 0: return math.nan if self.pos_inf_count > 0: return math.inf if self.neg_inf_count > 0: return -math.inf return (self.total + self.comp) / kPrevent precision loss with double precision and Neumaier summation
Even when all values are finite, a naive running sum suffers two numerical bugs:
- Overflow and narrow precision in 32-bit
float: Every floating-point format stores a fixed number of significant binary digits, called its significand (24bits, or ~7 decimal digits, for C++float;53bits, or ~16 decimal digits, for 64-bitdouble, which Pythonfloatuses natively). Summing10^6large finitefloatvalues near3.4e38overflows a 32-bitfloattoinf. Accumulating in 64-bitdoubleprevents overflow completely because10^6 * 3.4e38 = 3.4e44, far belowdouble's ceiling of1.8e308. - Catastrophic cancellation: Catastrophic cancellation happens when adding a tiny number to a huge number rounds the tiny number away completely, so subtracting the huge number later leaves zero behind instead of the tiny number:
Nums = [2^100, 1.0, 1.0], k = 2 (using plain 64-bit double): Window 0 [2^100, 1.0]: 2^100 + 1.0 rounds to 2^100 (the +1.0 is lost!) Slide to [1.0, 1.0]: subtract 2^100 -> 0.0, then add 1.0 -> 1.0 Computed mean = 1.0 / 2 = 0.5 (WRONG! True mean of [1.0, 1.0] is 1.0)We fix this with Neumaier's compensated summation, an improvement on Kahan summation that keeps a second
doublevariablecompholding the low-order bits shaved off by rounding. Whenever we computenew_total = total + x, subtracting whichever input had the larger magnitude fromnew_totalis guaranteed to have zero rounding error in IEEE-754 arithmetic; adding the smaller input back recovers the exact rounding error:Same example [2^100, 1.0, 1.0], k = 2 with Neumaier (total, comp): + 2^100 enters: total = 2^100, comp = 0.0 + 1.0 enters: new_total = 2^100; error = (2^100 - 2^100) + 1.0 = +1.0 -> comp = 1.0 - 2^100 leaves: new_total = 0.0; error = (2^100 - 0.0) - 2^100 = 0.0 -> total = 0.0, comp = 1.0 + 1.0 enters: new_total = 1.0; error = (1.0 - 1.0) + 0.0 = 0.0 -> total = 1.0, comp = 1.0 Mean = (total + comp) / 2 = (1.0 + 1.0) / 2 = 1.0 (EXACT!)- Overflow and narrow precision in 32-bit
Bound long-term drift by rebuilding every k slides
Why isn't Neumaier compensation alone the end of the story? Because
totalandcompare two 53-bitdoubles, together they hold roughly106bits of precision—not infinite precision. If an array contains three wildly separated scales like[2^120, 2^60, 1.0, 1.0, ...],2^120pushes2^60intocomp, and2^60insidecompstill rounds away1.0!To guarantee that no past spike can corrupt the stream forever while keeping
O(1)extra space, we recompute(total, comp)directly from the current windownums[start : start + k]once everykslides (start % k == 0):from typing import List def rebuild_example_loop(nums: List[float], k: int) -> int: """Count how many finite element reads all periodic rebuilds perform across n items.""" # Rebuilds fire at start = k, 2k, 3k, ... — at most (n - k) // k times. # Each rebuild inspects k elements, totaling at most n - k reads overall: O(n)! work = 0 for start in range(1, len(nums) - k + 1): if start % k == 0: work += k return workBecause
O(k)rebuild work happens only once everykwindows, the amortized cost is at most one extra addition per element (O(n)total time andO(1)extra space), and rounding error can never accumulate across more than3koperations.Walk through Example 2 step by step
Let's trace
nums = [5.0, inf, -inf, 2.0, 6.0]withk = 2(and verify howNaNbehaves in Example 3 as well):start window nan +inf -inf total+comp rebuild? output reason -------------------------------------------------------------------------------------------- 0 [5.0, inf] 0 1 0 5.0 no +inf only +inf (Rule 3) 1 [inf, -inf] 0 1 1 0.0 no NaN +inf and -inf (Rule 2) 2 [-inf, 2.0] 0 0 1 2.0 yes -inf only -inf (Rule 4) 3 [2.0, 6.0] 0 0 0 8.0 no 4.0 8.0 / 2 (Rule 5)Notice how
+infand-infeach dominate while inside the window, cancel cleanly to0in their integer counters as soon as they leave, and leave window3([2.0, 6.0] -> 4.0) completely uncorrupted. Likewise, in Example 3 ([NaN, inf, 10.0, 20.0],k = 2),nan_count = 1in window0overridespos_inf_count = 1to emitNaNbefore recovering toinfand15.0.Production C++17 implementation
Here is the exact same
O(n)time,O(1)auxiliary space algorithm written for the C++ signature. Input elements arrive as 32-bitfloat, finite sums accumulate in 64-bitdouble, and each window's mean is cast back tofloat:#include <cmath> #include <cstddef> #include <limits> #include <vector> struct WindowState { long long nan_count = 0; long long pos_inf_count = 0; long long neg_inf_count = 0; double total = 0.0; // finite running sum in 64-bit double double comp = 0.0; // Neumaier compensation for lost low-order bits void add_finite(double x) { double new_total = total + x; if (std::fabs(total) >= std::fabs(x)) { comp += (total - new_total) + x; } else { comp += (x - new_total) + total; } total = new_total; } void update(float v, int direction) { // +1 on enter, -1 on exit if (std::isnan(v)) { nan_count += direction; } else if (std::isinf(v)) { if (v > 0) pos_inf_count += direction; else neg_inf_count += direction; } else { add_finite(direction * static_cast<double>(v)); } } void rebuild_sum(const std::vector<float>& nums, std::size_t start, std::size_t end) { total = 0.0; comp = 0.0; for (std::size_t i = start; i < end; ++i) { if (std::isfinite(nums[i])) { add_finite(static_cast<double>(nums[i])); } } } float mean(int k) const { if (nan_count > 0) return std::numeric_limits<float>::quiet_NaN(); if (pos_inf_count > 0 && neg_inf_count > 0) return std::numeric_limits<float>::quiet_NaN(); if (pos_inf_count > 0) return std::numeric_limits<float>::infinity(); if (neg_inf_count > 0) return -std::numeric_limits<float>::infinity(); return static_cast<float>((total + comp) / k); } }; std::vector<float> sliding_window_mean(const std::vector<float>& nums, int k) { if (k <= 0 || static_cast<std::size_t>(k) > nums.size()) return {}; const std::size_t n = nums.size(); const std::size_t w = static_cast<std::size_t>(k); std::vector<float> result; result.reserve(n - w + 1); WindowState state; for (std::size_t i = 0; i < w; ++i) state.update(nums[i], +1); result.push_back(state.mean(k)); for (std::size_t start = 1; start + w <= n; ++start) { state.update(nums[start - 1], -1); state.update(nums[start + w - 1], +1); if (start % w == 0) state.rebuild_sum(nums, start, start + w); result.push_back(state.mean(k)); } return result; }Never compile this translation unit with
-ffast-mathor-Ofast: those flags let the compiler assumeNaNandinfnever occur and algebraically simplify(total - new_total) + xto0.0, destroying both special-value checks and Neumaier compensation.Complete Python solution
from typing import List import math class _WindowState: """Tracks special-value counts and a compensated finite sum for the active window.""" def __init__(self) -> None: # Exact integer counts of non-finite IEEE-754 values currently inside the window. self.nan_count = 0 self.pos_inf_count = 0 self.neg_inf_count = 0 # Neumaier compensated pair: (total + comp) approximates the exact finite sum. self.total = 0.0 self.comp = 0.0 def add_finite(self, x: float) -> None: """Add finite float `x` using Neumaier's compensated summation.""" new_total = self.total + x # Subtract the larger-magnitude value from `new_total` first so that subtraction # is exact in IEEE-754 arithmetic, then add the smaller value to recover lost bits. if abs(self.total) >= abs(x): self.comp += (self.total - new_total) + x else: self.comp += (x - new_total) + self.total self.total = new_total def update(self, x: float, direction: int) -> None: """Update window state: `direction` is +1 when `x` enters and -1 when `x` leaves.""" # Route non-finite values to integer counters so `total` is never poisoned by NaN/inf. if math.isnan(x): self.nan_count += direction elif x == math.inf: self.pos_inf_count += direction elif x == -math.inf: self.neg_inf_count += direction else: self.add_finite(direction * x) def rebuild_sum(self, nums: List[float], start: int, end: int) -> None: """Recompute the finite sum of nums[start:end] from scratch to clear old drift.""" self.total = 0.0 self.comp = 0.0 for i in range(start, end): if math.isfinite(nums[i]): self.add_finite(nums[i]) def mean(self, k: int) -> float: """Evaluate the window mean following IEEE-754 precedence rules 1 through 5.""" # Rule 1: any NaN dominates everything, including infinities. if self.nan_count > 0: return math.nan # Rule 2: (+inf) + (-inf) has an indeterminate sign, producing NaN. if self.pos_inf_count > 0 and self.neg_inf_count > 0: return math.nan # Rules 3 & 4: single-sided infinity dominates any finite sum. if self.pos_inf_count > 0: return math.inf if self.neg_inf_count > 0: return -math.inf # Rule 5: all k entries are finite, so return their compensated arithmetic mean. return (self.total + self.comp) / k def sliding_window_mean(nums: List[float], k: int) -> List[float]: """Return the mean of every contiguous window nums[s:s+k] in O(n) time and O(1) extra space.""" n = len(nums) if k <= 0 or k > n: return [] # Phase 1: populate the initial window nums[0:k]. state = _WindowState() for i in range(k): state.update(nums[i], +1) result = [state.mean(k)] # Phase 2: slide one position at a time, evicting `nums[start - 1]` and adding `nums[start + k - 1]`. for start in range(1, n - k + 1): state.update(nums[start - 1], -1) state.update(nums[start + k - 1], +1) # Every k slides, rebuild the finite sum in O(k) time (amortized O(1) per slide) # so rounding error can never accumulate across more than ~3k additions. if start % k == 0: state.rebuild_sum(nums, start, start + k) result.append(state.mean(k)) return result✅ Submit now — all tests should pass.
Intuition & how it works
Imagine tracking the average weight of boxes currently riding on a 2-slot conveyor belt while occasional "BROKEN SENSOR" (NaN), "OVERLOAD+" (+inf), and "UNDERFLOW-" (-inf) tags pass through. If you type "BROKEN SENSOR" into a pocket calculator's running total, the display locks onto ERROR forever even after that bad box drops off the belt; instead, you click three separate integer tally counters for the special tags and only feed ordinary finite weights into your calculator.
Both obvious baselines fail in production. Re-summing all k elements from scratch at every step takes O(n * k) work, which stalls on million-element streams, while a naive sum += enter - leave running total turns permanently into NaN the first time NaN or inf is subtracted (NaN - NaN = NaN and inf - inf = NaN). Even on purely finite data, adding a huge spike to a plain float sum rounds away small neighbors (catastrophic cancellation—losing small values completely when added to and later subtracted from a much larger number), so we combine 64-bit double Neumaier compensated summation (tracking lost rounding bits in a second variable comp) with a periodic O(k) rebuild every k slides.
Walk through Example 2 (nums = [5.0, inf, -inf, 2.0, 6.0], k = 2):
- Window 0 [5.0, inf]: pos_inf_count = 1, finite sum = 5.0 -> pos_inf_count == 1 outputs +inf.
- Window 1 [inf, -inf]: 5.0 exits (finite sum = 0.0), -inf enters (neg_inf_count = 1) -> both infinity counters are positive, outputting NaN.
- Window 2 [-inf, 2.0]: +inf exits (pos_inf_count = 0), 2.0 enters (finite sum = 2.0) -> neg_inf_count == 1 outputs -inf.
- Window 3 [2.0, 6.0]: -inf exits (neg_inf_count = 0), 6.0 enters (finite sum = 8.0) -> all special counters are 0, outputting 8.0 / 2 = 4.0 with zero poisoning!
Complexity
- Time:
O(n). Every element enters the window at most once and exits at most once, doingO(1)counter or arithmetic work per step (~2nupdates). Rebuilding the finite sum toucheskelements once everykslides (start = k, 2k, 3k, ...), adding at mostn - kelement reads across the entire run, so total work stays strictly below3nconstant-time operations. - Space:
O(1)auxiliary space beyond the returned output list of lengthn - k + 1._WindowStatestores only three integers (nan_count,pos_inf_count,neg_inf_count) and two 64-bit floats (total,comp), andrebuild_sumreadsnumsin place without allocating buffers.
Edge cases
k = 1andk = n:k = 1outputs a copy of each element's IEEE-754 value;k = noutputs a single 1-element list without entering the sliding loop.NaNmixed with+infor-inf:nan_count > 0is checked first, soNaNalways wins (as in Example 3's[NaN, inf] -> NaN).+infand-infin the same window: Both counters are positive, returningNaNeven when finite numbers are also inside the window.- Large finite 32-bit floats near
FLT_MAX(~3.4e38): Summing up to10^6such values reaches~3.4e44, which would overflow a 32-bitfloattoinfbut fits comfortably inside a 64-bitdouble(<= 1.8e308) before dividing byk. - Subnormal floats: Subnormal floats (tiny numbers smaller than
2^-126down to2^-149that trade leading precision bits to represent values very close to zero) convert to normal 64-bitdoublevalues with zero loss of bits. - Extreme multi-scale finite spikes: Because
(total, comp)carries ~106 bits of precision (two 53-bitdoubles), three simultaneous scales separated by more than2^106(such as2^120,2^60, and1.0) can still drop1.0until the nextstart % k == 0rebuild wipes out the error within at mostkwindows.
Common mistakes
- Putting
NaNor+/-infinto the floating-point running sum, permanently poisoning all subsequent windows withNaN. - Checking
x == float("nan")instead ofmath.isnan(x)orstd::isnan(x)—by IEEE-754 definition,NaN == NaNalways evaluates toFalse. - Returning
+infor-infwhen both+infand-infsit inside the window at the same time instead of returningNaN. - Accumulating finite values in 32-bit
floatrather than 64-bitdouble, causing premature overflow on large finite inputs and severe rounding drift on long arrays. - Using basic Kahan summation instead of Neumaier summation: standard Kahan fails when the incoming value
xhas a larger magnitude than the currenttotal(such astotal = 1.0followed byx = 2^100), whereas Neumaier'sabs(total) >= abs(x)branch handles both orders symmetrically. - Forgetting to decrement
nan_count,pos_inf_count, orneg_inf_countwhen elements slide out of the left edge of the window.
Alternative approaches
- Recompute every window with
math.fsum: Evaluates each window independently with exact rounding, but takesO(n * k)time, violating theO(n)constraint for largek. - Two-stack subtraction-free sliding window: A two-stack queue (maintaining a front stack and back stack of partial finite sums so every window sum is computed by adding
front_sum + back_sumwith zero floating-point subtractions) completely prevents departed huge spikes from canceling current small numbers and still runs in amortizedO(n)time, but usesO(k)auxiliary memory instead ofO(1). - Exact 320-bit fixed-point integer accumulator: Scaling every finite
float32into an exact integer multiple of2^-149gives zero drift withO(1)extra space and no periodic rebuilds, at the cost of a small 5-word (5 x uint64_t) integer helper in C++.
Follow-up questions
- Why do aggressive compiler flags such as -ffast-math or -Ofast break IEEE-754 predicates and compensated summation, and how do you protect this code in production?
-ffast-math(which-Ofastenables alongside-O3) turns on-ffinite-math-only—allowing the compiler to optimize under the assumption thatNaNandinfnever exist at runtime, foldingstd::isnan(x)tofalseand treating returnedquiet_NaN()/infinity()constants as undefined—and-fassociative-math, which lets the optimizer rewrite(total - new_total) + xto0.0, silently deleting Neumaier compensation! To safeguard production C++ code, isolate this module in a translation unit compiled without fast-math (or pass-fno-finite-math-only -fno-associative-math), inspect input bit patterns directly viastd::memcpyintouint32_t(exponent bits0x7F800000all 1s with non-zero mantissa forNaN, zero mantissa forinf),static_assert(std::numeric_limits<float>::is_iec559), and run unit tests containingNaN,+/-inf, and[2^100, 1.0, 1.0]under exact release compiler flags in CI. - Suppose the stream exceeds 10^9 elements spanning extreme magnitude gaps—how can you eliminate subtraction drift in O(1) space without ever rescanning the window? Use an exact fixed-point representation—converting every finite
float32into an exact integer multiple of the smallest possible subnormal unit2^-149. Because every finitefloat32has magnitude< 2^128and spacing>= 2^-149, multiplyingxby2^149yields an exact integer< 2^277; summing up to2^42(~4.4 * 10^12) elements stays< 2^319, which fits with a sign bit inside five 64-bit integers (320bits =40bytes,O(1)space!). Because integer+and-have zero rounding error, the running sum never drifts over billions or trillions of updates without ever resetting or rereading past elements (in Python,intis already arbitrary-precision: scale by2**149viax.as_integer_ratio()and dividetotal_fixed / (k << 149)once per window). - How would you redesign the window state if windows were defined over a trailing time interval and live events could arrive out of timestamp order? Because integer special-value counts and exact fixed-point sums are commutative and invertible (addition order does not change the result), a window
(t - W, t]only depends on which events fall inside its time range. Store active events in a timestamp-ordered min-heap or ring buffer of fine time buckets (say,1 mssub-aggregates holding their own counts and sums) so expired entries evict cleanly astadvances, and divide by the dynamic window event countm(0 / 0 -> NaNwhen empty). To handle out-of-order network arrivals, hold back window emission using a watermark—a progress timestampmax_seen_event_time - allowed_lateness—emitting the mean for timetonce the watermark passest, while routing rarer ultra-late events to a correction stream or dead-letter queue.
Follow-up questions
- Why do aggressive compiler flags such as -ffast-math or -Ofast break IEEE-754 predicates and compensated summation, and how do you protect this code in production?
- Suppose the stream exceeds 10^9 elements spanning extreme magnitude gaps—how can you eliminate subtraction drift in O(1) space without ever rescanning the window?
- How would you redesign the window state if windows were defined over a trailing time interval and live events could arrive out of timestamp order?
Similar questions
- Exact Binomial Tail Test Across Unequal Sample Sizes
- Orthogonal OLS Precision, Live Sharpe Decay, and L1 Optimal Prediction
- How K-Fold Cross-Validation Affects Bias, Variance, and Test Errors
- Dynamic Dynasty Succession Without an Initial Monarch
- DOM Button Click Listener and Event Target
- Catalog Search, Filtering, and Pagination