"""Original LCENJ educational calculation, CC0-1.0. Python3.10+ standard library.
No RF transmission, device access or measured input.
"""
from math import pi,degrees
c=3e8; df=1e6; R=3; phase=4*pi*df*R/c; period=c/(2*df)
code=[1,1,-1,1]; delay=2; echo=[code[(n-delay)%4]for n in range(4)]
corr=[sum(echo[n]*code[(n-k)%4]for n in range(4))for k in range(4)]
assert abs(degrees(phase)-7.2)<1e-12 and period==150 and corr==[0,0,4,0]
assert (delay*10e-9)*c/2==3
print(f"FSK phase={degrees(phase):g} deg; ambiguity period={period:g} m")
print(f"toy circular correlations={corr}; peak at {corr.index(max(corr))} chips -> 3 m")
print("Calculated hypothetical examples only; no hardware, RF or measured-data test.")
