You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

  1. #!/usr/bin/env python3
  2. def SDict(nim="160000000"):
  3. """ generate dictionary customised for each nim.\n
  4. dictionary generation took only < 0.01s so it is
  5. better to customise for each nim, instead of
  6. creating big dictionary at once """
  7. nim = str(nim)
  8. start_year = int(nim[:2]) + 81
  9. end_year = int(nim[:2]) + 84
  10. dictionary = []
  11. for yy in range(start_year, end_year):
  12. for mm in range(1, 13):
  13. for dd in range(1, 32):
  14. if mm == 2 and dd > 29:
  15. continue
  16. if mm in [4, 6, 9, 11] and dd > 30:
  17. continue
  18. date = {
  19. 'dd': str(dd).zfill(2),
  20. 'mm': str(mm).zfill(2),
  21. 'yy': str(yy)[-2:]
  22. }
  23. dictionary.append("{dd}{mm}{yy}".format(**date))
  24. dictionary.append("{yy}{mm}{dd}".format(**date))
  25. for n in range(1000):
  26. t = str(n)
  27. dictionary.append(t * int(6 / len(t)))
  28. for i in range(10):
  29. dictionary.append(str(i).zfill(2)*3)
  30. dictionary.append(str(i).zfill(3)*2)
  31. # put extra values here
  32. dictionary += [
  33. "123456",
  34. "654321",
  35. ]
  36. dictionary = sorted(list(set(dictionary)))
  37. return dictionary
  38. if __name__ == "__main__":
  39. import argparse
  40. parser = argparse.ArgumentParser()
  41. parser.add_argument("nim", help="NIM to seed dictionary")
  42. args = parser.parse_args()
  43. data = SDict(args.nim)
  44. print("\n".join(data))
  45. print("Dictionary generated {} values".format(len(data)))