Your question is Algorithm Limitations in Code. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
Gentex's auto-dimming mirrors decide when to dim based on smoothed readings from a glare sensor. Here's a simplified version of the decision logic used on the bench.
def should_dim(readings, threshold=0.6, window=5):
smoothed = []
for i in range(len(readings)):
window_vals = readings[max(0, i - window):i + 1]
avg = sum(window_vals) / window
smoothed.append(avg)
dim_decisions = []
for value in smoothed:
dim_decisions.append(value > threshold)
return dim_decisions
def glare_score(rear_sensor, cabin_sensor):
ratio = rear_sensor / cabin_sensor
return ratio
What are the limitations of this algorithm for deciding when the mirror should dim, and how would each one actually misbehave on the road? Answer in writing.