mapFolding 0.14.1__py3-none-any.whl → 0.15.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. mapFolding/__init__.py +2 -1
  2. mapFolding/_oeisFormulas/A000682.py +2 -2
  3. mapFolding/_oeisFormulas/A001010.py +18 -0
  4. mapFolding/_oeisFormulas/Z0Z_aOFn.py +7 -4
  5. mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +7 -0
  6. mapFolding/_oeisFormulas/matrixMeanders.py +122 -75
  7. mapFolding/_oeisFormulas/matrixMeandersAnnex.py +66 -66
  8. mapFolding/_theSSOT.py +9 -3
  9. mapFolding/_theTypes.py +34 -130
  10. mapFolding/basecamp.py +90 -10
  11. mapFolding/beDRY.py +5 -21
  12. mapFolding/daoOfMapFolding.py +2 -1
  13. mapFolding/dataBaskets.py +8 -3
  14. mapFolding/oeis.py +10 -16
  15. mapFolding/reference/A005316optimized128bit.py +19 -19
  16. mapFolding/reference/A005316primitiveOptimized.py +25 -25
  17. mapFolding/reference/A005316redis.py +19 -19
  18. mapFolding/reference/A005316write2disk.py +19 -19
  19. mapFolding/reference/jaxCount.py +1 -1
  20. mapFolding/reference/matrixMeandersBaseline.py +20 -20
  21. mapFolding/reference/matrixMeandersBaselineAnnex.py +4 -4
  22. mapFolding/reference/matrixMeandersSimpleQueue.py +90 -0
  23. mapFolding/reference/matrixMeandersSlicePop.py +104 -0
  24. mapFolding/reference/rotatedEntryPoint.py +1 -1
  25. mapFolding/someAssemblyRequired/A007822rawMaterials.py +46 -0
  26. mapFolding/someAssemblyRequired/_toolkitContainers.py +1 -1
  27. mapFolding/someAssemblyRequired/makeAllModules.py +192 -199
  28. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +3 -3
  29. mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +3 -3
  30. mapFolding/syntheticModules/algorithmA007822.py +166 -0
  31. mapFolding/syntheticModules/algorithmA007822Numba.py +95 -0
  32. mapFolding/syntheticModules/{countParallel.py → countParallelNumba.py} +5 -4
  33. mapFolding/syntheticModules/{daoOfMapFolding.py → daoOfMapFoldingNumba.py} +5 -4
  34. mapFolding/syntheticModules/dataPacking.py +4 -3
  35. mapFolding/syntheticModules/{initializeCount.py → initializeState.py} +1 -1
  36. mapFolding/syntheticModules/initializeStateA007822.py +69 -0
  37. mapFolding/syntheticModules/theorem2.py +2 -1
  38. mapFolding/syntheticModules/theorem2A007822.py +70 -0
  39. mapFolding/syntheticModules/theorem2A007822Numba.py +67 -0
  40. mapFolding/syntheticModules/theorem2A007822Trimmed.py +64 -0
  41. mapFolding/syntheticModules/theorem2Numba.py +6 -4
  42. mapFolding/syntheticModules/theorem2Trimmed.py +2 -1
  43. mapFolding/tests/test_computations.py +29 -4
  44. {mapfolding-0.14.1.dist-info → mapfolding-0.15.1.dist-info}/METADATA +2 -2
  45. mapfolding-0.15.1.dist-info/RECORD +86 -0
  46. mapfolding-0.14.1.dist-info/RECORD +0 -76
  47. {mapfolding-0.14.1.dist-info → mapfolding-0.15.1.dist-info}/WHEEL +0 -0
  48. {mapfolding-0.14.1.dist-info → mapfolding-0.15.1.dist-info}/entry_points.txt +0 -0
  49. {mapfolding-0.14.1.dist-info → mapfolding-0.15.1.dist-info}/licenses/LICENSE +0 -0
  50. {mapfolding-0.14.1.dist-info → mapfolding-0.15.1.dist-info}/top_level.txt +0 -0
mapFolding/__init__.py CHANGED
@@ -46,7 +46,7 @@ from mapFolding._theTypes import (
46
46
  Array1DElephino as Array1DElephino,
47
47
  Array1DFoldsTotal as Array1DFoldsTotal,
48
48
  Array1DLeavesTotal as Array1DLeavesTotal,
49
- Array3D as Array3D,
49
+ Array3DLeavesTotal as Array3DLeavesTotal,
50
50
  DatatypeElephino as DatatypeElephino,
51
51
  DatatypeFoldsTotal as DatatypeFoldsTotal,
52
52
  DatatypeLeavesTotal as DatatypeLeavesTotal,
@@ -85,4 +85,5 @@ from mapFolding.oeis import (
85
85
  getOEISids as getOEISids,
86
86
  OEIS_for_n as OEIS_for_n,
87
87
  oeisIDfor_n as oeisIDfor_n,
88
+ dictionaryOEIS as dictionaryOEIS,
88
89
  )
@@ -1,7 +1,7 @@
1
- from mapFolding._oeisFormulas.matrixMeanders import count, curveMaximum
1
+ from mapFolding._oeisFormulas.matrixMeanders import count
2
2
 
3
3
  def initializeA000682(n: int) -> dict[int, int]:
4
- curveLocationsMAXIMUM = curveMaximum[n].curveLocationsMAXIMUM
4
+ curveLocationsMAXIMUM = 1 << (2 * n + 4)
5
5
 
6
6
  curveSeed: int = 5 - (n & 0b1) * 4
7
7
  listCurveLocations = [(curveSeed << 1) | curveSeed]
@@ -0,0 +1,18 @@
1
+ from mapFolding._oeisFormulas.A000682 import A000682
2
+ from mapFolding.oeis import oeisIDfor_n
3
+
4
+ def A001010(Z0Z_n: int) -> tuple[int, int]:
5
+ """Complicated.
6
+
7
+ a(2n+1) = 2*A007822(n)
8
+ a(2n) = 2*A000682(n+2)
9
+ """
10
+ if Z0Z_n & 0b1:
11
+ foldsTotal = 2 * oeisIDfor_n('A007822', Z0Z_n)
12
+ A001010n = 2 * Z0Z_n + 1
13
+ else:
14
+ foldsTotal = 2 * A000682(Z0Z_n + 2)
15
+ A001010n = 2 * Z0Z_n
16
+
17
+ return (A001010n, foldsTotal)
18
+
@@ -1,4 +1,6 @@
1
1
  from mapFolding._oeisFormulas.A000136 import A000136
2
+ from mapFolding._oeisFormulas.A000682 import A000682
3
+ from mapFolding._oeisFormulas.Z0Z_oeisMeanders import dictionaryOEISMeanders
2
4
  from mapFolding.oeis import dictionaryOEIS
3
5
  import sys
4
6
  import time
@@ -7,12 +9,13 @@ import time
7
9
 
8
10
  if __name__ == '__main__':
9
11
  oeisID = 'A000136'
10
- for n in range(3,30):
12
+ oeisID = 'A000682'
13
+ for n in range(3, 13):
11
14
 
12
- # print(n)
15
+ # sys.stdout.write(f"{n = }\n")
13
16
 
14
17
  timeStart = time.perf_counter()
15
- foldsTotal = A000136(n)
18
+ foldsTotal = eval(oeisID)(n)
16
19
  # sys.stdout.write(f"{n} {foldsTotal} {time.perf_counter() - timeStart:.2f}\n")
17
- sys.stdout.write(f"{foldsTotal == dictionaryOEIS[oeisID]['valuesKnown'][n]} {n} {foldsTotal} {time.perf_counter() - timeStart:.2f}\n")
20
+ sys.stdout.write(f"{foldsTotal == dictionaryOEISMeanders[oeisID]['valuesKnown'][n]} {n} {foldsTotal} {time.perf_counter() - timeStart:.2f}\n") # pyright: ignore[reportIndexIssue]
18
21
 
@@ -1,5 +1,6 @@
1
1
  from mapFolding._oeisFormulas.A000560 import A000560
2
2
  from mapFolding._oeisFormulas.A000682 import A000682
3
+ from mapFolding._oeisFormulas.A001010 import A001010
3
4
  from mapFolding._oeisFormulas.A005315 import A005315
4
5
  from mapFolding._oeisFormulas.A005316 import A005316
5
6
  from mapFolding._oeisFormulas.A223094 import A223094
@@ -8,9 +9,13 @@ from mapFolding._oeisFormulas.A301620 import A301620
8
9
  from mapFolding.oeis import getOEISidInformation, getOEISidValues
9
10
  import sys
10
11
 
12
+ 'A001011'
13
+ # a(n) = (A001010(n) + A000136(n)) / 4
14
+
11
15
  oeisIDsMeanders: list[str] = [
12
16
  'A000560',
13
17
  'A000682',
18
+ 'A001010',
14
19
  'A005315',
15
20
  'A005316',
16
21
  'A223094',
@@ -39,6 +44,8 @@ if __name__ == '__main__':
39
44
  assert A000560for_n == dictionaryOEISMeanders['A000560']['valuesKnown'][n]
40
45
  A000682for_n = A000682(n)
41
46
  assert A000682for_n == dictionaryOEISMeanders['A000682']['valuesKnown'][n]
47
+ nComputed, foldsTotal = A001010(n)
48
+ assert foldsTotal == dictionaryOEISMeanders['A001010']['valuesKnown'][nComputed]
42
49
  A005315for_n = A005315(n)
43
50
  assert A005315for_n == dictionaryOEISMeanders['A005315']['valuesKnown'][n]
44
51
  A005316for_n = A005316(n)
@@ -1,79 +1,126 @@
1
- from mapFolding._oeisFormulas.matrixMeandersAnnex import curveMaximum as curveMaximum
2
- from typing import NamedTuple
3
-
4
- class BifurcatedCurves(NamedTuple):
5
- bifurcationEven: int
6
- bifurcationOdd: int
7
- distinctCrossings: int
8
- curveLocationsMAXIMUM: int
9
-
10
- dictionaryCurveLocations: dict[int, list[int]] = {}
11
-
12
- def getCurveLocations(bridges: int) -> list[BifurcatedCurves]:
13
- global dictionaryCurveLocations # noqa: PLW0603
14
- curveLocationsMAXIMUM, bifurcationEvenLocator, bifurcationOddLocator = curveMaximum[bridges]
15
- listBifurcatedCurves: list[BifurcatedCurves] = []
16
- # TODO This is ready for concurrency and/or vectorization.
17
- for curveLocations, listDistinctCrossings in dictionaryCurveLocations.items():
18
- bifurcationEven = (curveLocations & bifurcationEvenLocator) >> 1
19
- bifurcationOdd = (curveLocations & bifurcationOddLocator)
20
- distinctCrossings = sum(listDistinctCrossings)
21
- listBifurcatedCurves.append(BifurcatedCurves(bifurcationEven, bifurcationOdd, distinctCrossings, curveLocationsMAXIMUM))
22
- dictionaryCurveLocations = {}
23
- return listBifurcatedCurves
24
-
25
- def recordAnalysis(curveLocationAnalysis: int, curveLocationsMAXIMUM: int, distinctCrossings: int) -> None:
26
- if curveLocationAnalysis < curveLocationsMAXIMUM:
27
- dictionaryCurveLocations.setdefault(curveLocationAnalysis, []).append(distinctCrossings)
28
-
29
- def analyzeCurve(bifurcationEven: int, bifurcationOdd: int, distinctCrossings: int, curveLocationsMAXIMUM: int) -> None:
30
- bifurcationEvenFinalZero = (bifurcationEven & 0b1) == 0
31
- bifurcationEvenHasCurves = bifurcationEven != 1
32
- bifurcationOddFinalZero = (bifurcationOdd & 0b1) == 0
33
- bifurcationOddHasCurves = bifurcationOdd != 1
34
-
35
- if bifurcationEvenHasCurves:
36
- curveLocationAnalysis = (bifurcationEven >> 1) | (bifurcationOdd << 2) | bifurcationEvenFinalZero
37
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
38
-
39
- if bifurcationOddHasCurves:
40
- curveLocationAnalysis = (bifurcationOdd >> 2) | (bifurcationEven << 3) | (bifurcationOddFinalZero << 1)
41
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
42
-
43
- curveLocationAnalysis = ((bifurcationOdd | (bifurcationEven << 1)) << 2) | 3
44
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
45
-
46
- if bifurcationEvenHasCurves and bifurcationOddHasCurves and (bifurcationEvenFinalZero or bifurcationOddFinalZero):
47
- XOrHere2makePair = 0b1
48
- findUnpairedBinary1 = 0
49
-
50
- if bifurcationEvenFinalZero and not bifurcationOddFinalZero:
51
- while findUnpairedBinary1 >= 0:
52
- XOrHere2makePair <<= 2
53
- findUnpairedBinary1 += 1 if (bifurcationEven & XOrHere2makePair) == 0 else -1
54
- bifurcationEven ^= XOrHere2makePair
55
-
56
- elif bifurcationOddFinalZero and not bifurcationEvenFinalZero:
57
- while findUnpairedBinary1 >= 0:
58
- XOrHere2makePair <<= 2
59
- findUnpairedBinary1 += 1 if (bifurcationOdd & XOrHere2makePair) == 0 else -1
60
- bifurcationOdd ^= XOrHere2makePair
61
-
62
- curveLocationAnalysis = ((bifurcationEven >> 2) << 1) | (bifurcationOdd >> 2)
63
- recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
64
-
65
- def initializeCurveLocations(startingCurveLocations: dict[int, int]) -> None:
66
- global dictionaryCurveLocations # noqa: PLW0603
67
- dictionaryCurveLocations = {curve: [distinctCrossings] for curve, distinctCrossings in startingCurveLocations.items()}
68
-
69
1
  def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
70
- initializeCurveLocations(startingCurveLocations)
71
-
2
+ listCurveMaximums: list[tuple[int, int, int]] = [
3
+ (0x15, 0x2a, 0x10),
4
+ (0x55, 0xaa, 0x40),
5
+ (0x155, 0x2aa, 0x100),
6
+ (0x555, 0xaaa, 0x400),
7
+ (0x1555, 0x2aaa, 0x1000),
8
+ (0x5555, 0xaaaa, 0x4000),
9
+ (0x15555, 0x2aaaa, 0x10000),
10
+ (0x55555, 0xaaaaa, 0x40000),
11
+ (0x155555, 0x2aaaaa, 0x100000),
12
+ (0x555555, 0xaaaaaa, 0x400000),
13
+ (0x1555555, 0x2aaaaaa, 0x1000000),
14
+ (0x5555555, 0xaaaaaaa, 0x4000000),
15
+ (0x15555555, 0x2aaaaaaa, 0x10000000),
16
+ (0x55555555, 0xaaaaaaaa, 0x40000000),
17
+ (0x155555555, 0x2aaaaaaaa, 0x100000000),
18
+ (0x555555555, 0xaaaaaaaaa, 0x400000000),
19
+ (0x1555555555, 0x2aaaaaaaaa, 0x1000000000),
20
+ (0x5555555555, 0xaaaaaaaaaa, 0x4000000000),
21
+ (0x15555555555, 0x2aaaaaaaaaa, 0x10000000000),
22
+ (0x55555555555, 0xaaaaaaaaaaa, 0x40000000000),
23
+ (0x155555555555, 0x2aaaaaaaaaaa, 0x100000000000),
24
+ (0x555555555555, 0xaaaaaaaaaaaa, 0x400000000000),
25
+ (0x1555555555555, 0x2aaaaaaaaaaaa, 0x1000000000000),
26
+ (0x5555555555555, 0xaaaaaaaaaaaaa, 0x4000000000000),
27
+ (0x15555555555555, 0x2aaaaaaaaaaaaa, 0x10000000000000),
28
+ (0x55555555555555, 0xaaaaaaaaaaaaaa, 0x40000000000000),
29
+ (0x155555555555555, 0x2aaaaaaaaaaaaaa, 0x100000000000000),
30
+ (0x555555555555555, 0xaaaaaaaaaaaaaaa, 0x400000000000000),
31
+ (0x1555555555555555, 0x2aaaaaaaaaaaaaaa, 0x1000000000000000),
32
+ (0x5555555555555555, 0xaaaaaaaaaaaaaaaa, 0x4000000000000000),
33
+ (0x15555555555555555, 0x2aaaaaaaaaaaaaaaa, 0x10000000000000000),
34
+ (0x55555555555555555, 0xaaaaaaaaaaaaaaaaa, 0x40000000000000000),
35
+ (0x155555555555555555, 0x2aaaaaaaaaaaaaaaaa, 0x100000000000000000),
36
+ (0x555555555555555555, 0xaaaaaaaaaaaaaaaaaa, 0x400000000000000000),
37
+ (0x1555555555555555555, 0x2aaaaaaaaaaaaaaaaaa, 0x1000000000000000000),
38
+ (0x5555555555555555555, 0xaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000),
39
+ (0x15555555555555555555, 0x2aaaaaaaaaaaaaaaaaaa, 0x10000000000000000000),
40
+ (0x55555555555555555555, 0xaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000),
41
+ (0x155555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000),
42
+ (0x555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000),
43
+ (0x1555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000),
44
+ (0x5555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000),
45
+ (0x15555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000),
46
+ (0x55555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000),
47
+ (0x155555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000),
48
+ (0x555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000),
49
+ (0x1555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000),
50
+ (0x5555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000),
51
+ (0x15555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000),
52
+ (0x55555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000),
53
+ (0x155555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000000),
54
+ (0x555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000000),
55
+ (0x1555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000000),
56
+ (0x5555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000000),
57
+ (0x15555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000000),
58
+ (0x55555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000000),
59
+ (0x155555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000000000),
60
+ (0x555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000000000),
61
+ (0x1555555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000000000),
62
+ (0x5555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000000000),
63
+ (0x15555555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000000000),
64
+ (0x55555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000000000),
65
+ ]
66
+ listCurveMaximums = listCurveMaximums[0:bridges]
67
+
68
+ dictionaryCurveLocations: dict[int, int] = {}
72
69
  while bridges > 0:
73
70
  bridges -= 1
74
71
 
75
- # TODO This could be parallelized when `recordAnalysis` is thread-safe
76
- for bifurcatedCurve in getCurveLocations(bridges):
77
- analyzeCurve(*bifurcatedCurve)
78
-
79
- return getCurveLocations(bridges)[0].distinctCrossings
72
+ bifurcationAlphaLocator, bifurcationZuluLocator, curveLocationsMAXIMUM = listCurveMaximums[bridges]
73
+ for curveLocations, distinctCrossings in startingCurveLocations.items():
74
+ bifurcationAlpha = (curveLocations & bifurcationAlphaLocator)
75
+ bifurcationZulu = (curveLocations & bifurcationZuluLocator) >> 1
76
+
77
+ bifurcationAlphaHasCurves = bifurcationAlpha != 1
78
+ bifurcationZuluHasCurves = bifurcationZulu != 1
79
+
80
+ # Curve location analysis
81
+ curveLocationAnalysis = ((bifurcationAlpha | (bifurcationZulu << 1)) << 2) | 3
82
+ if curveLocationAnalysis < curveLocationsMAXIMUM:
83
+ dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
84
+
85
+ # Curve location analysis, conditional
86
+ if bifurcationZuluHasCurves:
87
+ curveLocationAnalysis = (bifurcationZulu >> 1) | (bifurcationAlpha << 2) | (bifurcationZuluIsEven := not (bifurcationZulu & 1))
88
+ if curveLocationAnalysis < curveLocationsMAXIMUM:
89
+ dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
90
+
91
+ # Curve location analysis, conditional
92
+ if bifurcationAlphaHasCurves:
93
+ curveLocationAnalysis = (bifurcationAlphaShiftRight2 := bifurcationAlpha >> 2) | (bifurcationZulu << 3) | ((bifurcationAlphaIsEven := 1 - (bifurcationAlpha & 0b1)) << 1)
94
+ if curveLocationAnalysis < curveLocationsMAXIMUM:
95
+ dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
96
+
97
+ # Curve location analysis, uber-conditional
98
+ if bifurcationZuluHasCurves and bifurcationAlphaHasCurves:
99
+ # One Truth-check to select a code path
100
+ finalZeroCombination = (bifurcationZuluIsEven << 1) | bifurcationAlphaIsEven # pyright: ignore[reportPossiblyUnboundVariable]
101
+
102
+ if finalZeroCombination != 0: # Case 0 (False, False)
103
+ XOrHere2makePair = 0b1
104
+ findUnpairedBinary1 = 0
105
+
106
+ if finalZeroCombination == 1: # Case 1: (False, True)
107
+ while findUnpairedBinary1 >= 0:
108
+ XOrHere2makePair <<= 2
109
+ findUnpairedBinary1 += 1 if (bifurcationAlpha & XOrHere2makePair) == 0 else -1
110
+ bifurcationAlphaShiftRight2 = (bifurcationAlpha ^ XOrHere2makePair) >> 2
111
+ elif finalZeroCombination == 2: # Case 2: (True, False)
112
+ while findUnpairedBinary1 >= 0:
113
+ XOrHere2makePair <<= 2
114
+ findUnpairedBinary1 += 1 if (bifurcationZulu & XOrHere2makePair) == 0 else -1
115
+ bifurcationZulu ^= XOrHere2makePair
116
+
117
+ # Cases 1, 2, and 3 all compute curveLocationAnalysis
118
+ # TODO https://github.com/hunterhogan/mapFolding/issues/19
119
+ curveLocationAnalysis = ((bifurcationZulu >> 2) << 1) | bifurcationAlphaShiftRight2 # pyright: ignore[reportPossiblyUnboundVariable]
120
+ if curveLocationAnalysis < curveLocationsMAXIMUM:
121
+ dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
122
+
123
+ startingCurveLocations = dictionaryCurveLocations.copy()
124
+ dictionaryCurveLocations = {}
125
+
126
+ return sum(startingCurveLocations.values())
@@ -2,81 +2,81 @@ from typing import NamedTuple
2
2
  import sys
3
3
 
4
4
  class limitLocators(NamedTuple):
5
+ bifurcationAlphaLocator: int
6
+ bifurcationZuluLocator: int
5
7
  curveLocationsMAXIMUM: int
6
- bifurcationEvenLocator: int
7
- bifurcationOddLocator: int
8
8
 
9
9
  curveMaximum: dict[int, limitLocators] = {
10
- 0: limitLocators(16, 0x2a, 0x15),
11
- 1: limitLocators(64, 0xaa, 0x55),
12
- 2: limitLocators(256, 0x2aa, 0x155),
13
- 3: limitLocators(1024, 0xaaa, 0x555),
14
- 4: limitLocators(4096, 0x2aaa, 0x1555),
15
- 5: limitLocators(16384, 0xaaaa, 0x5555),
16
- 6: limitLocators(65536, 0x2aaaa, 0x15555),
17
- 7: limitLocators(262144, 0xaaaaa, 0x55555),
18
- 8: limitLocators(1048576, 0x2aaaaa, 0x155555),
19
- 9: limitLocators(4194304, 0xaaaaaa, 0x555555),
20
- 10: limitLocators(16777216, 0x2aaaaaa, 0x1555555),
21
- 11: limitLocators(67108864, 0xaaaaaaa, 0x5555555),
22
- 12: limitLocators(268435456, 0x2aaaaaaa, 0x15555555),
23
- 13: limitLocators(1073741824, 0xaaaaaaaa, 0x55555555),
24
- 14: limitLocators(4294967296, 0x2aaaaaaaa, 0x155555555),
25
- 15: limitLocators(17179869184, 0xaaaaaaaaa, 0x555555555),
26
- 16: limitLocators(68719476736, 0x2aaaaaaaaa, 0x1555555555),
27
- 17: limitLocators(274877906944, 0xaaaaaaaaaa, 0x5555555555),
28
- 18: limitLocators(1099511627776, 0x2aaaaaaaaaa, 0x15555555555),
29
- 19: limitLocators(4398046511104, 0xaaaaaaaaaaa, 0x55555555555),
30
- 20: limitLocators(17592186044416, 0x2aaaaaaaaaaa, 0x155555555555),
31
- 21: limitLocators(70368744177664, 0xaaaaaaaaaaaa, 0x555555555555),
32
- 22: limitLocators(281474976710656, 0x2aaaaaaaaaaaa, 0x1555555555555),
33
- 23: limitLocators(1125899906842624, 0xaaaaaaaaaaaaa, 0x5555555555555),
34
- 24: limitLocators(4503599627370496, 0x2aaaaaaaaaaaaa, 0x15555555555555),
35
- 25: limitLocators(18014398509481984, 0xaaaaaaaaaaaaaa, 0x55555555555555),
36
- 26: limitLocators(72057594037927936, 0x2aaaaaaaaaaaaaa, 0x155555555555555),
37
- 27: limitLocators(288230376151711744, 0xaaaaaaaaaaaaaaa, 0x555555555555555),
38
- 28: limitLocators(1152921504606846976, 0x2aaaaaaaaaaaaaaa, 0x1555555555555555), # 0x2aaaaaaaaaaaaaaa.bit_length() = 62
39
- 29: limitLocators(4611686018427387904, 0xaaaaaaaaaaaaaaaa, 0x5555555555555555),
40
- 30: limitLocators(18446744073709551616, 0x2aaaaaaaaaaaaaaaa, 0x15555555555555555),
41
- 31: limitLocators(73786976294838206464, 0xaaaaaaaaaaaaaaaaa, 0x55555555555555555),
42
- 32: limitLocators(295147905179352825856, 0x2aaaaaaaaaaaaaaaaa, 0x155555555555555555),
43
- 33: limitLocators(1180591620717411303424, 0xaaaaaaaaaaaaaaaaaa, 0x555555555555555555),
44
- 34: limitLocators(4722366482869645213696, 0x2aaaaaaaaaaaaaaaaaa, 0x1555555555555555555),
45
- 35: limitLocators(18889465931478580854784, 0xaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555),
46
- 36: limitLocators(75557863725914323419136, 0x2aaaaaaaaaaaaaaaaaaa, 0x15555555555555555555),
47
- 37: limitLocators(302231454903657293676544, 0xaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555),
48
- 38: limitLocators(1208925819614629174706176, 0x2aaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555),
49
- 39: limitLocators(4835703278458516698824704, 0xaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555),
50
- 40: limitLocators(19342813113834066795298816, 0x2aaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555),
51
- 41: limitLocators(77371252455336267181195264, 0xaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555),
52
- 42: limitLocators(309485009821345068724781056, 0x2aaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555),
53
- 43: limitLocators(1237940039285380274899124224, 0xaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555),
54
- 44: limitLocators(4951760157141521099596496896, 0x2aaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555),
55
- 45: limitLocators(19807040628566084398385987584, 0xaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555),
56
- 46: limitLocators(79228162514264337593543950336, 0x2aaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555),
57
- 47: limitLocators(316912650057057350374175801344, 0xaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555),
58
- 48: limitLocators(1267650600228229401496703205376, 0x2aaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555),
59
- 49: limitLocators(5070602400912917605986812821504, 0xaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555),
60
- 50: limitLocators(20282409603651670423947251286016, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555),
61
- 51: limitLocators(81129638414606681695789005144064, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555),
62
- 52: limitLocators(324518553658426726783156020576256, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555),
63
- 53: limitLocators(1298074214633706907132624082305024, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555),
64
- 54: limitLocators(5192296858534827628530496329220096, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555),
65
- 55: limitLocators(20769187434139310514121985316880384, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555),
66
- 56: limitLocators(83076749736557242056487941267521536, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555555),
67
- 57: limitLocators(332306998946228968225951765070086144, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555555),
68
- 58: limitLocators(1329227995784915872903807060280344576, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555555),
69
- 59: limitLocators(5316911983139663491615228241121378304, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555555),
70
- 60: limitLocators(21267647932558653966460912964485513216, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555555),
71
- 61: limitLocators(85070591730234615865843651857942052864, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555555),
10
+ 0: limitLocators(0x15, 0x2a, 0x10),
11
+ 1: limitLocators(0x55, 0xaa, 0x40),
12
+ 2: limitLocators(0x155, 0x2aa, 0x100),
13
+ 3: limitLocators(0x555, 0xaaa, 0x400),
14
+ 4: limitLocators(0x1555, 0x2aaa, 0x1000),
15
+ 5: limitLocators(0x5555, 0xaaaa, 0x4000),
16
+ 6: limitLocators(0x15555, 0x2aaaa, 0x10000),
17
+ 7: limitLocators(0x55555, 0xaaaaa, 0x40000),
18
+ 8: limitLocators(0x155555, 0x2aaaaa, 0x100000),
19
+ 9: limitLocators(0x555555, 0xaaaaaa, 0x400000),
20
+ 10: limitLocators(0x1555555, 0x2aaaaaa, 0x1000000),
21
+ 11: limitLocators(0x5555555, 0xaaaaaaa, 0x4000000),
22
+ 12: limitLocators(0x15555555, 0x2aaaaaaa, 0x10000000),
23
+ 13: limitLocators(0x55555555, 0xaaaaaaaa, 0x40000000),
24
+ 14: limitLocators(0x155555555, 0x2aaaaaaaa, 0x100000000),
25
+ 15: limitLocators(0x555555555, 0xaaaaaaaaa, 0x400000000),
26
+ 16: limitLocators(0x1555555555, 0x2aaaaaaaaa, 0x1000000000),
27
+ 17: limitLocators(0x5555555555, 0xaaaaaaaaaa, 0x4000000000),
28
+ 18: limitLocators(0x15555555555, 0x2aaaaaaaaaa, 0x10000000000),
29
+ 19: limitLocators(0x55555555555, 0xaaaaaaaaaaa, 0x40000000000),
30
+ 20: limitLocators(0x155555555555, 0x2aaaaaaaaaaa, 0x100000000000),
31
+ 21: limitLocators(0x555555555555, 0xaaaaaaaaaaaa, 0x400000000000),
32
+ 22: limitLocators(0x1555555555555, 0x2aaaaaaaaaaaa, 0x1000000000000),
33
+ 23: limitLocators(0x5555555555555, 0xaaaaaaaaaaaaa, 0x4000000000000),
34
+ 24: limitLocators(0x15555555555555, 0x2aaaaaaaaaaaaa, 0x10000000000000),
35
+ 25: limitLocators(0x55555555555555, 0xaaaaaaaaaaaaaa, 0x40000000000000),
36
+ 26: limitLocators(0x155555555555555, 0x2aaaaaaaaaaaaaa, 0x100000000000000),
37
+ 27: limitLocators(0x555555555555555, 0xaaaaaaaaaaaaaaa, 0x400000000000000),
38
+ 28: limitLocators(0x1555555555555555, 0x2aaaaaaaaaaaaaaa, 0x1000000000000000), # 0x2aaaaaaaaaaaaaaa.bit_length() = 62
39
+ 29: limitLocators(0x5555555555555555, 0xaaaaaaaaaaaaaaaa, 0x4000000000000000),
40
+ 30: limitLocators(0x15555555555555555, 0x2aaaaaaaaaaaaaaaa, 0x10000000000000000),
41
+ 31: limitLocators(0x55555555555555555, 0xaaaaaaaaaaaaaaaaa, 0x40000000000000000),
42
+ 32: limitLocators(0x155555555555555555, 0x2aaaaaaaaaaaaaaaaa, 0x100000000000000000),
43
+ 33: limitLocators(0x555555555555555555, 0xaaaaaaaaaaaaaaaaaa, 0x400000000000000000),
44
+ 34: limitLocators(0x1555555555555555555, 0x2aaaaaaaaaaaaaaaaaa, 0x1000000000000000000),
45
+ 35: limitLocators(0x5555555555555555555, 0xaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000),
46
+ 36: limitLocators(0x15555555555555555555, 0x2aaaaaaaaaaaaaaaaaaa, 0x10000000000000000000),
47
+ 37: limitLocators(0x55555555555555555555, 0xaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000),
48
+ 38: limitLocators(0x155555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000),
49
+ 39: limitLocators(0x555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000),
50
+ 40: limitLocators(0x1555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000),
51
+ 41: limitLocators(0x5555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000),
52
+ 42: limitLocators(0x15555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000),
53
+ 43: limitLocators(0x55555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000),
54
+ 44: limitLocators(0x155555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000),
55
+ 45: limitLocators(0x555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000),
56
+ 46: limitLocators(0x1555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000),
57
+ 47: limitLocators(0x5555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000),
58
+ 48: limitLocators(0x15555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000),
59
+ 49: limitLocators(0x55555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000),
60
+ 50: limitLocators(0x155555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000000),
61
+ 51: limitLocators(0x555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000000),
62
+ 52: limitLocators(0x1555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000000),
63
+ 53: limitLocators(0x5555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000000),
64
+ 54: limitLocators(0x15555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000000),
65
+ 55: limitLocators(0x55555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000000),
66
+ 56: limitLocators(0x155555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x100000000000000000000000000000),
67
+ 57: limitLocators(0x555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x400000000000000000000000000000),
68
+ 58: limitLocators(0x1555555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1000000000000000000000000000000),
69
+ 59: limitLocators(0x5555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x4000000000000000000000000000000),
70
+ 60: limitLocators(0x15555555555555555555555555555555, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x10000000000000000000000000000000),
71
+ 61: limitLocators(0x55555555555555555555555555555555, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x40000000000000000000000000000000),
72
72
  }
73
73
 
74
74
  def makeCurveMaximum() -> None:
75
75
  sys.stdout.write("curveMaximum: dict[int, limitLocators] = {\n")
76
76
  for n in range(62):
77
77
  curveLocationsMAXIMUM = 1 << (2 * n + 4)
78
- bifurcationOddLocator = int('01' * ((curveLocationsMAXIMUM.bit_length() + 1) // 2), 2)
79
- sys.stdout.write(f"{n}: limitLocators({curveLocationsMAXIMUM}, {hex(bifurcationOddLocator << 1)}, {hex(bifurcationOddLocator)}),\n")
78
+ bifurcationAlphaLocator = int('01' * ((curveLocationsMAXIMUM.bit_length() + 1) // 2), 2)
79
+ sys.stdout.write(f"{n}: limitLocators({hex(bifurcationAlphaLocator)}, {hex(bifurcationAlphaLocator << 1)}, {hex(curveLocationsMAXIMUM)}),\n")
80
80
  sys.stdout.write("}\n")
81
81
 
82
82
  if __name__ == '__main__':
mapFolding/_theSSOT.py CHANGED
@@ -76,19 +76,19 @@ concurrencyPackage = concurrencyPackageHARDCODED
76
76
  # TODO I made a `TypedDict` before I knew how to make dataclasses and classes. Think about other data structures.
77
77
  settingsOEISManuallySelected: dict[str, MetadataOEISidManuallySet] = {
78
78
  'A000136': {
79
- 'getMapShape': lambda n: tuple(sorted([1, n])),
79
+ 'getMapShape': lambda n: (1, n),
80
80
  'valuesBenchmark': [14],
81
81
  'valuesTestParallelization': [*range(3, 7)],
82
82
  'valuesTestValidation': [random.randint(2, 9)], # noqa: S311
83
83
  },
84
84
  'A001415': {
85
- 'getMapShape': lambda n: tuple(sorted([2, n])),
85
+ 'getMapShape': lambda n: (2, n),
86
86
  'valuesBenchmark': [14],
87
87
  'valuesTestParallelization': [*range(3, 7)],
88
88
  'valuesTestValidation': [random.randint(2, 9)], # noqa: S311
89
89
  },
90
90
  'A001416': {
91
- 'getMapShape': lambda n: tuple(sorted([3, n])),
91
+ 'getMapShape': lambda n: (3, n),
92
92
  'valuesBenchmark': [9],
93
93
  'valuesTestParallelization': [*range(3, 5)],
94
94
  'valuesTestValidation': [random.randint(2, 6)], # noqa: S311
@@ -111,6 +111,12 @@ settingsOEISManuallySelected: dict[str, MetadataOEISidManuallySet] = {
111
111
  'valuesTestParallelization': [*range(2, 4)],
112
112
  'valuesTestValidation': [random.randint(2, 4)], # noqa: S311
113
113
  },
114
+ 'A007822': {
115
+ 'getMapShape': lambda n: (1, 2 * n),
116
+ 'valuesBenchmark': [7],
117
+ 'valuesTestParallelization': [*range(2, 4)],
118
+ 'valuesTestValidation': [random.randint(2, 4)], # noqa: S311
119
+ },
114
120
  }
115
121
 
116
122
  packageSettings = mapFoldingPackageSettings(