Here's the steps for a test program:
start with c
get d, e, and f
calc (f-1)/8
calc SQRT((f-1)/8) = base T2
define base T1 as T2-1 = T1
T1 + T2 = potential u value
iterate potential u value looking for lock using rm(2d-1) formula, basically looking for a perfect square.
hopefully find a lock for the correct (x+n)^2 value.
Basically the correct u value should be a multiple of the combined bases of T2 and T1. Remainders may need to be accounted for as well, not sure yet.