I've been trying to bug fix a system that I wrote a few years ago - the system needs rewriting but that's a big job so I'm currently keeping the 'current' version staggering on. The system gives the 'answers' for staff and this one 'simple' one has been giving me problems.
One problem was minor(ish) and required a 'median' calculation and a bit of messing that was soon done. This showed up another problem - one calculation wasn't working correctly. Each 'part' of the answer has 2 calculations done 8 times (16 calculations on 2 different formulas).
The first '8' were fixed by the first fix (just a 'mean' calculation in truth)
The second 8 were confusing. 2 seemed to work, but the other 4 didn't. After much head scratching (most of the day) I asked the person who gave me the calculation for help. Who was confused too - 15 minutes later we had fixed the 'total columns' which left us with 4 calculations.
Actually it was 2 that were wrong, but confusingly all 4 of these calculations used the exact same routine. Another hour of confusion and it became clear. I cleared the 'running total' for each calculation but not the array I stored the information in. Because this time we had uneven numbers (not 5 items for each calculation) - there was old data left in the array from an earlier calculation.
Oh well, thats one down, I have only to repair the Chi-Square calculation tomorrow..................
Time to leave, go food shopping, go home and collapse.