I am trying to solve the usaco problem combination lock where you are given a two lock combinations. The locks have a margin of error of +- 2 so if you had a combination lock of 1-3-5, the combination 3-1-7 would still solve it. 

You are also given a dial. For example, the dial starts at 1 and ends at the given number. So if the dial was 50, it would start at 1 and end at 50. Since the beginning of the dial is adjacent to the end of the dial, the combination 49-1-3 would also solve the combination lock of 1-3-5. 

In this program, you have to output the number of distinct solutions to the two lock combinations. For the record, the combination 3-2-1 and 1-2-3 are considered distinct, but the combination 2-2-2 and 2-2-2 is not. 

I have tried creating two functions, one to check whether three numbers match the constraints of the first combination lock and another to check whether three numbers match the constraints of the second combination lock. 

```
a,b,c = 1,2,3
d,e,f = 5,6,7
dial = 50

def check(i,j,k):
    i = (i+dial) % dial
    j = (j+dial) % dial
    k = (k+dial) % dial
    if abs(a-i) <= 2 and abs(b-j) <= 2 and abs(c-k) <= 2:
        return True
    return False

def check1(i,j,k):
    i = (i+dial) % dial
    j = (j+dial) % dial
    k = (k+dial) % dial
    if abs(d-i) <= 2 and abs(e-j) <= 2 and abs(f-k) <= 2:
        return True
    return False

res = []
count = 0
for i in range(1,dial+1):
    for j in range(1,dial+1):
        for k in range(1,dial+1):
            if check(i,j,k):
                count += 1
                res.append([i,j,k])
            if check1(i,j,k):
                count += 1
                res.append([i,j,k])

print(sorted(res))
print(count)

```

The dial is 50 and the first combination is 1-2-3 and the second combination is 5-6-7.

The program should output 249 as the count, but it instead outputs 225. I am not really sure why this is happening. I have added the array for display purposes only. Any help would be greatly appreciated!