|
@@ -39,16 +39,13 @@ class Serial:
|
|
def __str__(self):
|
|
def __str__(self):
|
|
return f"{int(self):{len(str(self.modulus))}d}"
|
|
return f"{int(self):{len(str(self.modulus))}d}"
|
|
|
|
|
|
-def step(start, finish):
|
|
|
|
|
|
+def find_intermediate(start, finish):
|
|
if start < finish:
|
|
if start < finish:
|
|
- return start, finish
|
|
|
|
|
|
+ return None
|
|
else:
|
|
else:
|
|
- midpoint = start + ((Serial.modulus >> 1) - 2)
|
|
|
|
- assert start < midpoint and midpoint < finish
|
|
|
|
- return start, midpoint, finish
|
|
|
|
-
|
|
|
|
-def show(steps):
|
|
|
|
- print(" => ".join(str(s) for s in steps))
|
|
|
|
|
|
+ wrap = start + ((Serial.modulus >> 1) - 2)
|
|
|
|
+ assert start < wrap and wrap < finish
|
|
|
|
+ return wrap
|
|
|
|
|
|
def main():
|
|
def main():
|
|
from argparse import ArgumentParser
|
|
from argparse import ArgumentParser
|
|
@@ -58,7 +55,16 @@ def main():
|
|
ap.add_argument("finish", type = Serial)
|
|
ap.add_argument("finish", type = Serial)
|
|
args = ap.parse_args()
|
|
args = ap.parse_args()
|
|
|
|
|
|
- show(step(args.start, args.finish))
|
|
|
|
|
|
+ wrap = find_intermediate(args.start, args.finish)
|
|
|
|
+
|
|
|
|
+ print(f"Start at {args.start!s}")
|
|
|
|
+
|
|
|
|
+ if wrap is None:
|
|
|
|
+ print("No step needed")
|
|
|
|
+ else:
|
|
|
|
+ print(f"Step via {wrap!s}")
|
|
|
|
+
|
|
|
|
+ print(f"End at {args.finish!s}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
main()
|
|
main()
|