mapFolding 0.15.1__tar.gz → 0.15.3__tar.gz
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.
- {mapfolding-0.15.1 → mapfolding-0.15.3}/PKG-INFO +3 -2
- mapfolding-0.15.3/mapFolding/_oeisFormulas/A000682.py +85 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/A001010.py +19 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/A001011.py +5 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/Z0Z_aOFn.py +34 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/Z0Z_notes.py +16 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +74 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/Z0Z_symmetry.py +131 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/matrixMeanders.py +134 -0
- mapfolding-0.15.3/mapFolding/_oeisFormulas/matrixMeanders64.py +152 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/matrixMeandersAnnex.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_theSSOT.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_theTypes.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/basecamp.py +52 -66
- mapfolding-0.15.1/mapFolding/_oeisFormulas/matrixMeanders.py → mapfolding-0.15.3/mapFolding/reference/matrixMeandersBaselineV2.py +28 -21
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/A007822rawMaterials.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/makeAllModules.py +4 -15
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +5 -4
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/algorithmA007822.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/algorithmA007822Numba.py +1 -1
- mapfolding-0.15.3/mapFolding/syntheticModules/dataPackingA007822.py +26 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/initializeStateA007822.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2A007822.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2A007822Numba.py +3 -4
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2A007822Trimmed.py +1 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2Numba.py +2 -3
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/conftest.py +2 -1
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/test_computations.py +48 -41
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/PKG-INFO +3 -2
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/SOURCES.txt +6 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/requires.txt +3 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/pyproject.toml +10 -7
- mapfolding-0.15.1/mapFolding/_oeisFormulas/A000682.py +0 -17
- mapfolding-0.15.1/mapFolding/_oeisFormulas/A001010.py +0 -18
- mapfolding-0.15.1/mapFolding/_oeisFormulas/Z0Z_aOFn.py +0 -21
- mapfolding-0.15.1/mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +0 -60
- {mapfolding-0.15.1 → mapfolding-0.15.3}/LICENSE +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/README.md +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A000136.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A000560.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A005315.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A005316.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A223094.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A259702.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/A301620.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/_oeisFormulas/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/beDRY.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/daoOfMapFolding.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/dataBaskets.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/filesystemToolkit.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/oeis.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/py.typed +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316JavaPort.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316imperative.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316intOptimized.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316optimized128bit.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316primitiveOptimized.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316redis.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/A005316write2disk.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/flattened.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/hunterNumba.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/irvineJavaPort.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/jaxCount.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/jobsCompleted/[2x19]/p2x19.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/jobsCompleted/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/jobsCompleted/p2x19/p2x19.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/lunnonNumpy.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/lunnonWhile.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/matrixMeandersBaseline.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/matrixMeandersBaselineAnnex.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/matrixMeandersSimpleQueue.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/matrixMeandersSlicePop.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/rotatedEntryPoint.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/reference/total_countPlus1vsPlusN.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/RecipeJob.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/_toolIfThis.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/_toolkitContainers.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/getLLVMforNoReason.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/infoBooth.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/toolkitNumba.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/someAssemblyRequired/transformationTools.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/countParallelNumba.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/daoOfMapFoldingNumba.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/dataPacking.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/initializeState.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/syntheticModules/theorem2Trimmed.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/__init__.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/test_filesystem.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/test_oeis.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/test_other.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding/tests/test_tasks.py +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/dependency_links.txt +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/entry_points.txt +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/mapFolding.egg-info/top_level.txt +0 -0
- {mapfolding-0.15.1 → mapfolding-0.15.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mapFolding
|
|
3
|
-
Version: 0.15.
|
|
3
|
+
Version: 0.15.3
|
|
4
4
|
Summary: Map folding, meanders, stamp folding, semi-meanders. Experiment with algorithm transformations and code optimization.
|
|
5
5
|
Author-email: Hunter Hogan <HunterHogan@pm.me>
|
|
6
6
|
License: CC-BY-NC-4.0
|
|
@@ -8,7 +8,7 @@ Project-URL: Donate, https://www.patreon.com/integrated
|
|
|
8
8
|
Project-URL: Homepage, https://github.com/hunterhogan/mapFolding
|
|
9
9
|
Project-URL: Issues, https://github.com/hunterhogan/mapFolding/issues
|
|
10
10
|
Project-URL: Repository, https://github.com/hunterhogan/mapFolding.git
|
|
11
|
-
Keywords: A000136,A000560,A000682,A001415,A001416,A001417,A001418,A005315,A005316,A007822,A195646,A223094,A259702,A301620,abstract syntax tree,algorithmic combinatorics,algorithmic optimization,arch configurations,
|
|
11
|
+
Keywords: A000136,A000560,A000682,A001010,A001011,A001415,A001416,A001417,A001418,A005315,A005316,A007822,A195646,A223094,A259702,A301620,AST manipulation,GPU acceleration,JIT compilation,Numba optimization,OEIS,Python optimization,abstract syntax tree,algorithmic combinatorics,algorithmic optimization,arch configurations,automated code generation,bit-packed arrays,bitwise state machines,cache-efficient algorithms,closed meandric numbers,code generation,code optimization,code synthesis,code transformation,codon optimization,combinatorial computing,combinatorial enumeration,combinatorial geometry,combinatorial mathematics,combinatorial problem solver,combinatorics,computational combinatorics,computational geometry,crossing patterns,curve crossings,dataclass transformation,discrete mathematics,dynamic compilation,enumerative combinatorics,folding pattern enumeration,folding problems,high-performance computing,integer sequences,just-in-time compilation,kernel optimization,labeled stamp folding,low-level computation,map folding,mapFolding,mathematical algorithms,mathematical modeling,mathematical optimization,mathematical patterns,mathematical software,mathematical tool,mathematical visualization,meander enumeration,meanders,meandric systems,memory-efficient enumeration,metaprogramming,numerical algorithms,numerical computation,open meandric systems,paper folding mathematics,parallel computing,pattern recognition,performance optimization,permutation patterns,permutations,post-setup optimization,pyproject,scientific computing,semi-meanders,sequence analysis,sequence calculator,sequence enumeration,sequence explorer,sequence generation,source code analysis,stamp folding,symbolic computation,symmetric foldings,topological combinatorics,topological patterns,typed Python
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Environment :: Console
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
@@ -39,6 +39,7 @@ Requires-Dist: hunterMakesPy
|
|
|
39
39
|
Requires-Dist: numpy
|
|
40
40
|
Requires-Dist: platformdirs
|
|
41
41
|
Provides-Extra: development
|
|
42
|
+
Requires-Dist: memray; sys_platform == "linux" and extra == "development"
|
|
42
43
|
Requires-Dist: mypy; extra == "development"
|
|
43
44
|
Requires-Dist: pyupgrade; extra == "development"
|
|
44
45
|
Requires-Dist: py-spy; extra == "development"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Semi-meanders.
|
|
2
|
+
|
|
3
|
+
n = 3 `startingCurveLocations` keys = 3
|
|
4
|
+
n = 4 `startingCurveLocations` keys = 4
|
|
5
|
+
n = 5 `startingCurveLocations` keys = 4
|
|
6
|
+
n = 6 `startingCurveLocations` keys = 5
|
|
7
|
+
n = 7 `startingCurveLocations` keys = 5
|
|
8
|
+
n = 8 `startingCurveLocations` keys = 6
|
|
9
|
+
n = 9 `startingCurveLocations` keys = 6
|
|
10
|
+
n = 10 `startingCurveLocations` keys = 7
|
|
11
|
+
n = 11 `startingCurveLocations` keys = 7
|
|
12
|
+
n = 12 `startingCurveLocations` keys = 8
|
|
13
|
+
n = 13 `startingCurveLocations` keys = 8
|
|
14
|
+
n = 14 `startingCurveLocations` keys = 9
|
|
15
|
+
n = 15 `startingCurveLocations` keys = 9
|
|
16
|
+
n = 16 `startingCurveLocations` keys = 10
|
|
17
|
+
n = 17 `startingCurveLocations` keys = 10
|
|
18
|
+
n = 18 `startingCurveLocations` keys = 11
|
|
19
|
+
n = 19 `startingCurveLocations` keys = 11
|
|
20
|
+
n = 20 `startingCurveLocations` keys = 12
|
|
21
|
+
n = 21 `startingCurveLocations` keys = 12
|
|
22
|
+
n = 22 `startingCurveLocations` keys = 13
|
|
23
|
+
n = 23 `startingCurveLocations` keys = 13
|
|
24
|
+
n = 24 `startingCurveLocations` keys = 14
|
|
25
|
+
n = 25 `startingCurveLocations` keys = 14
|
|
26
|
+
n = 26 `startingCurveLocations` keys = 15
|
|
27
|
+
n = 27 `startingCurveLocations` keys = 15
|
|
28
|
+
n = 28 `startingCurveLocations` keys = 16
|
|
29
|
+
n = 29 `startingCurveLocations` keys = 16
|
|
30
|
+
n = 30 `startingCurveLocations` keys = 17
|
|
31
|
+
n = 31 `startingCurveLocations` keys = 17
|
|
32
|
+
n = 32 `startingCurveLocations` keys = 18
|
|
33
|
+
n = 33 `startingCurveLocations` keys = 18
|
|
34
|
+
n = 34 `startingCurveLocations` keys = 19
|
|
35
|
+
n = 35 `startingCurveLocations` keys = 19
|
|
36
|
+
n = 36 `startingCurveLocations` keys = 20
|
|
37
|
+
n = 37 `startingCurveLocations` keys = 20
|
|
38
|
+
n = 38 `startingCurveLocations` keys = 21
|
|
39
|
+
n = 39 `startingCurveLocations` keys = 21
|
|
40
|
+
n = 40 `startingCurveLocations` keys = 22
|
|
41
|
+
n = 41 `startingCurveLocations` keys = 22
|
|
42
|
+
n = 42 `startingCurveLocations` keys = 23
|
|
43
|
+
n = 43 `startingCurveLocations` keys = 23
|
|
44
|
+
n = 44 `startingCurveLocations` keys = 24
|
|
45
|
+
n = 45 `startingCurveLocations` keys = 24
|
|
46
|
+
n = 46 `startingCurveLocations` keys = 25
|
|
47
|
+
n = 47 `startingCurveLocations` keys = 25
|
|
48
|
+
n = 48 `startingCurveLocations` keys = 26
|
|
49
|
+
n = 49 `startingCurveLocations` keys = 26
|
|
50
|
+
n = 50 `startingCurveLocations` keys = 27
|
|
51
|
+
n = 51 `startingCurveLocations` keys = 27
|
|
52
|
+
n = 52 `startingCurveLocations` keys = 28
|
|
53
|
+
n = 53 `startingCurveLocations` keys = 28
|
|
54
|
+
n = 54 `startingCurveLocations` keys = 29
|
|
55
|
+
n = 55 `startingCurveLocations` keys = 29
|
|
56
|
+
n = 56 `startingCurveLocations` keys = 30
|
|
57
|
+
n = 57 `startingCurveLocations` keys = 30
|
|
58
|
+
n = 58 `startingCurveLocations` keys = 31
|
|
59
|
+
n = 59 `startingCurveLocations` keys = 31
|
|
60
|
+
n = 60 `startingCurveLocations` keys = 32
|
|
61
|
+
n = 61 `startingCurveLocations` keys = 32
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
# TODO figure out how to call the correct module
|
|
65
|
+
# In other situations, I use a so-called dispatcher amd that has helped make code transformation easier, too.
|
|
66
|
+
from mapFolding._oeisFormulas.matrixMeanders import count # noqa: ERA001
|
|
67
|
+
from mapFolding._oeisFormulas.matrixMeanders64 import count as count64
|
|
68
|
+
|
|
69
|
+
def initializeA000682(n: int) -> dict[int, int]:
|
|
70
|
+
curveLocationsMAXIMUM = 1 << (2 * n + 4)
|
|
71
|
+
|
|
72
|
+
curveSeed: int = 5 - (n & 0b1) * 4
|
|
73
|
+
listCurveLocations = [(curveSeed << 1) | curveSeed]
|
|
74
|
+
|
|
75
|
+
while listCurveLocations[-1] < curveLocationsMAXIMUM:
|
|
76
|
+
curveSeed = (curveSeed << 4) | 0b101
|
|
77
|
+
listCurveLocations.append((curveSeed << 1) | curveSeed)
|
|
78
|
+
|
|
79
|
+
return dict.fromkeys(listCurveLocations, 1)
|
|
80
|
+
|
|
81
|
+
def A000682(n: int) -> int:
|
|
82
|
+
# count64(n - 1, initializeA000682(n - 1))
|
|
83
|
+
# print()
|
|
84
|
+
return count(n - 1, initializeA000682(n - 1))
|
|
85
|
+
# return count64(n - 1, initializeA000682(n - 1))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from mapFolding import countFolds
|
|
2
|
+
from mapFolding._oeisFormulas.A000682 import A000682
|
|
3
|
+
|
|
4
|
+
def A001010(n: int) -> int:
|
|
5
|
+
"""Complicated.
|
|
6
|
+
|
|
7
|
+
a(2n-1) = 2*A007822(n)
|
|
8
|
+
OddQ[n], 2*A007822[[(n - 1)/2 + 1]]]
|
|
9
|
+
|
|
10
|
+
a(2n) = 2*A000682(n+1)
|
|
11
|
+
EvenQ[n], 2*A000682[[n/2 + 1]]
|
|
12
|
+
"""
|
|
13
|
+
if n & 0b1:
|
|
14
|
+
foldsTotal = 2 * countFolds(oeisID='A007822', oeis_n=(n - 1)//2 + 1, flow='theorem2Numba')
|
|
15
|
+
else:
|
|
16
|
+
foldsTotal = 2 * A000682(n // 2 + 1)
|
|
17
|
+
|
|
18
|
+
return foldsTotal
|
|
19
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# pyright: reportUnusedImport=false
|
|
2
|
+
from mapFolding._oeisFormulas.A000136 import A000136
|
|
3
|
+
from mapFolding._oeisFormulas.A000682 import A000682
|
|
4
|
+
from mapFolding._oeisFormulas.A001010 import A001010
|
|
5
|
+
from mapFolding._oeisFormulas.Z0Z_oeisMeanders import dictionaryOEISMeanders
|
|
6
|
+
from mapFolding.oeis import dictionaryOEIS
|
|
7
|
+
import sys
|
|
8
|
+
import time
|
|
9
|
+
|
|
10
|
+
# ruff: noqa: ERA001
|
|
11
|
+
|
|
12
|
+
if __name__ == '__main__':
|
|
13
|
+
def _write() -> None:
|
|
14
|
+
sys.stdout.write(
|
|
15
|
+
f"{(booleanColor:=(foldsTotal == dictionaryOEISMeanders[oeisID]['valuesKnown'][n]))}\t" # pyright: ignore[reportIndexIssue, reportUnknownVariableType]
|
|
16
|
+
f"\033[{(not booleanColor)*91}m"
|
|
17
|
+
f"{n}\t"
|
|
18
|
+
f"{foldsTotal}\t"
|
|
19
|
+
# f"{dictionaryOEISMeanders[oeisID]['valuesKnown'][n]=}\t"
|
|
20
|
+
f"{time.perf_counter() - timeStart:.2f}\t"
|
|
21
|
+
# f"{description}\t"
|
|
22
|
+
"\033[0m\n"
|
|
23
|
+
)
|
|
24
|
+
oeisID = 'A001010'
|
|
25
|
+
oeisID = 'A000136'
|
|
26
|
+
oeisID = 'A000682'
|
|
27
|
+
for n in range(3,17):
|
|
28
|
+
|
|
29
|
+
# sys.stdout.write(f"{n = }\n")
|
|
30
|
+
|
|
31
|
+
timeStart = time.perf_counter()
|
|
32
|
+
foldsTotal = eval(oeisID)(n) # noqa: S307
|
|
33
|
+
# sys.stdout.write(f"{n} {foldsTotal} {time.perf_counter() - timeStart:.2f}\n")
|
|
34
|
+
_write()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Half-formed thoughts.
|
|
2
|
+
|
|
3
|
+
I have unintentionally made `bridges -= 1` almost meaningless.
|
|
4
|
+
|
|
5
|
+
Unlike multidimensional map folding, the computation of curveLocations_sub_i for bridges=p does not need to happen during the
|
|
6
|
+
series of computation for bridges=p. Each curveLocations_sub_i produces between no curveLocations, curveLocations_sub_q,
|
|
7
|
+
curveLocations_sub_r, curveLocations_sub_s, and curveLocations_sub_t, which are recorded as keys in dictionaryCurveLocations.
|
|
8
|
+
|
|
9
|
+
`while bridges > 0: bridges -= 1` tacitly attaches metadata to each key in dictionaryCurveLocations: specifically the value of
|
|
10
|
+
`bridges`. The computation is not complete until the `bridges` value of each key reaches 0.
|
|
11
|
+
|
|
12
|
+
Therefore, it is hypothetically possible to use one dictionary and to explicitly track the `bridges` value for each key. In
|
|
13
|
+
that scenario, the dictionary is effectively a list of jobs. And instead of being at the mercy of the amount of resources
|
|
14
|
+
needed by each decrement, bridges -= 1, we can use well-researched techniques to manage resources and the order of
|
|
15
|
+
execution.
|
|
16
|
+
"""
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from mapFolding._oeisFormulas.A000560 import A000560
|
|
2
|
+
from mapFolding._oeisFormulas.A000682 import A000682
|
|
3
|
+
from mapFolding._oeisFormulas.A001010 import A001010
|
|
4
|
+
from mapFolding._oeisFormulas.A001011 import A001011
|
|
5
|
+
from mapFolding._oeisFormulas.A005315 import A005315
|
|
6
|
+
from mapFolding._oeisFormulas.A005316 import A005316
|
|
7
|
+
from mapFolding._oeisFormulas.A223094 import A223094
|
|
8
|
+
from mapFolding._oeisFormulas.A259702 import A259702
|
|
9
|
+
from mapFolding._oeisFormulas.A301620 import A301620
|
|
10
|
+
from mapFolding.oeis import getOEISidInformation, getOEISidValues
|
|
11
|
+
from typing import TypedDict
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
oeisIDsMeanders: list[str] = [
|
|
15
|
+
'A000560',
|
|
16
|
+
'A000682',
|
|
17
|
+
'A001010',
|
|
18
|
+
'A001011',
|
|
19
|
+
'A005315',
|
|
20
|
+
'A005316',
|
|
21
|
+
'A223094',
|
|
22
|
+
'A259702',
|
|
23
|
+
'A301620',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
# ruff: noqa: ERA001
|
|
27
|
+
class MetadataOEISidMeanders(TypedDict):
|
|
28
|
+
"""Settings for an implemented OEIS sequence."""
|
|
29
|
+
|
|
30
|
+
description: str
|
|
31
|
+
"""The OEIS.org description of the integer sequence."""
|
|
32
|
+
# getMapShape: Callable[[int], tuple[int, ...]]
|
|
33
|
+
"""Function to convert the OEIS sequence index, 'n', to its `mapShape` tuple."""
|
|
34
|
+
offset: int
|
|
35
|
+
"""The starting index, 'n', of the sequence, typically 0 or 1."""
|
|
36
|
+
# valuesBenchmark: list[int]
|
|
37
|
+
"""List of index values, 'n', to use when benchmarking the algorithm performance."""
|
|
38
|
+
valuesKnown: dict[int, int]
|
|
39
|
+
"""Dictionary of sequence indices, 'n', to their known values, `foldsTotal`."""
|
|
40
|
+
# valuesTestParallelization: list[int]
|
|
41
|
+
"""List of index values, 'n', to use when testing parallelization performance."""
|
|
42
|
+
# valuesTestValidation: list[int]
|
|
43
|
+
"""List of index values, 'n', to use when testing validation performance."""
|
|
44
|
+
# valueUnknown: int
|
|
45
|
+
"""The smallest value of 'n' for for which `foldsTotal` is unknown."""
|
|
46
|
+
|
|
47
|
+
dictionaryOEISMeanders: dict[str, MetadataOEISidMeanders] = {
|
|
48
|
+
oeisID: {
|
|
49
|
+
'description': getOEISidInformation(oeisID)[0],
|
|
50
|
+
'offset': getOEISidInformation(oeisID)[1],
|
|
51
|
+
'valuesKnown': getOEISidValues(oeisID),
|
|
52
|
+
}
|
|
53
|
+
for oeisID in oeisIDsMeanders
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# ruff: noqa: S101
|
|
57
|
+
# pyright: reportIndexIssue=false
|
|
58
|
+
|
|
59
|
+
rangeTest = range(5, 13)
|
|
60
|
+
|
|
61
|
+
if __name__ == '__main__':
|
|
62
|
+
for n in rangeTest:
|
|
63
|
+
|
|
64
|
+
assert A000560(n) == dictionaryOEISMeanders['A000560']['valuesKnown'][n]
|
|
65
|
+
assert A000682(n) == dictionaryOEISMeanders['A000682']['valuesKnown'][n]
|
|
66
|
+
assert A001010(n) == dictionaryOEISMeanders['A001010']['valuesKnown'][n]
|
|
67
|
+
assert A001011(n) == dictionaryOEISMeanders['A001011']['valuesKnown'][n]
|
|
68
|
+
assert A005315(n) == dictionaryOEISMeanders['A005315']['valuesKnown'][n]
|
|
69
|
+
assert A005316(n) == dictionaryOEISMeanders['A005316']['valuesKnown'][n]
|
|
70
|
+
assert A223094(n) == dictionaryOEISMeanders['A223094']['valuesKnown'][n]
|
|
71
|
+
assert A259702(n) == dictionaryOEISMeanders['A259702']['valuesKnown'][n]
|
|
72
|
+
assert A301620(n) == dictionaryOEISMeanders['A301620']['valuesKnown'][n]
|
|
73
|
+
|
|
74
|
+
sys.stdout.write(f"\nTrue for {str(rangeTest)}\n")
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
from mapFolding._oeisFormulas.A000682 import A000682
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
How to A000682:
|
|
6
|
+
- Start A000682 for n.
|
|
7
|
+
- Find A000560(n-1) in dictionaryCurveLocationsKnown or dictionaryCurveLocationsDiscovered.
|
|
8
|
+
- STOP computing.
|
|
9
|
+
- Double the total.
|
|
10
|
+
That is A000682.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
How to A259703:
|
|
14
|
+
- Start A000682 for n.
|
|
15
|
+
- Find n-1 keys in dictionaryCurveLocationsKnown or dictionaryCurveLocationsDiscovered.
|
|
16
|
+
- Descending sort.
|
|
17
|
+
That is a A259703 row.
|
|
18
|
+
|
|
19
|
+
https://oeis.org/A259703
|
|
20
|
+
|
|
21
|
+
SYMMETRY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
22
|
+
|
|
23
|
+
1;
|
|
24
|
+
1, 1;
|
|
25
|
+
2, 1, 1;
|
|
26
|
+
5, 2, 2, 1;
|
|
27
|
+
12, 5, 4, 2, 1;
|
|
28
|
+
33, 13, 12, 4, 3, 1;
|
|
29
|
+
87, 35, 30, 12, 6, 3, 1;
|
|
30
|
+
252, 98, 90, 32, 21, 6, 4, 1;
|
|
31
|
+
703, 278, 243, 94, 54, 21, 8, 4, 1;
|
|
32
|
+
2105, 812, 745, 270, 175, 57, 32, 8, 5, 1;
|
|
33
|
+
6099, 2385, 2108, 808, 485, 181, 84, 32, 10, 5, 1;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
n+1
|
|
37
|
+
Row sums are A000682. First column is A000560.
|
|
38
|
+
Row sums are A000682. First column is A000560.
|
|
39
|
+
Row sums are A000682. First column is A000560.
|
|
40
|
+
Row sums are A000682. First column is A000560.
|
|
41
|
+
Row sums are A000682. First column is A000560.
|
|
42
|
+
Row sums are A000682. First column is A000560.
|
|
43
|
+
Row sums are A000682. First column is A000560.
|
|
44
|
+
Row sums are A000682. First column is A000560.
|
|
45
|
+
|
|
46
|
+
n/a;
|
|
47
|
+
1= 1;
|
|
48
|
+
2= 1+ 1;
|
|
49
|
+
5= 2+ 2+ 1;
|
|
50
|
+
12= 5+ 4+ 2+ 1;
|
|
51
|
+
33= 13+ 12+ 4+ 3+ 1;
|
|
52
|
+
87= 35+ 30+ 12+ 6+ 3+ 1;
|
|
53
|
+
252= 98+ 90+ 32+ 21+ 6+ 4+ 1;
|
|
54
|
+
703= 278+ 243+ 94+ 54+ 21+ 8+ 4+ 1;
|
|
55
|
+
2105= 812+ 745+ 270+ 175+ 57+ 32+ 8+ 5+ 1;
|
|
56
|
+
6099= 2385+ 2108+ 808+ 485+ 181+ 84+ 32+ 10+ 5+ 1;
|
|
57
|
+
|
|
58
|
+
print(1== 1)
|
|
59
|
+
print(2== 1+ 1)
|
|
60
|
+
print(5== 2+ 2+ 1)
|
|
61
|
+
print(12== 5+ 4+ 2+ 1)
|
|
62
|
+
print(33== 13+ 12+ 4+ 3+ 1)
|
|
63
|
+
print(87== 35+ 30+ 12+ 6+ 3+ 1)
|
|
64
|
+
print(252== 98+ 90+ 32+ 21+ 6+ 4+ 1)
|
|
65
|
+
print(703== 278+ 243+ 94+ 54+ 21+ 8+ 4+ 1)
|
|
66
|
+
print(2105== 812+ 745+ 270+ 175+ 57+ 32+ 8+ 5+ 1)
|
|
67
|
+
print(6099== 2385+ 2108+ 808+ 485+ 181+ 84+ 32+ 10+ 5+ 1)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
listA259703rowTerms = [1, 1]
|
|
73
|
+
n = len(listA259703rowTerms) + 1
|
|
74
|
+
rowSum = sum(listA259703rowTerms)
|
|
75
|
+
A000682for_n = A000682(n)
|
|
76
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
77
|
+
|
|
78
|
+
listA259703rowTerms = [2, 1, 1]
|
|
79
|
+
n = len(listA259703rowTerms) + 1
|
|
80
|
+
rowSum = sum(listA259703rowTerms)
|
|
81
|
+
A000682for_n = A000682(n)
|
|
82
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
83
|
+
|
|
84
|
+
listA259703rowTerms = [5, 2, 2, 1]
|
|
85
|
+
n = len(listA259703rowTerms) + 1
|
|
86
|
+
rowSum = sum(listA259703rowTerms)
|
|
87
|
+
A000682for_n = A000682(n)
|
|
88
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
89
|
+
|
|
90
|
+
listA259703rowTerms = [12, 5, 4, 2, 1]
|
|
91
|
+
n = len(listA259703rowTerms) + 1
|
|
92
|
+
rowSum = sum(listA259703rowTerms)
|
|
93
|
+
A000682for_n = A000682(n)
|
|
94
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
95
|
+
|
|
96
|
+
listA259703rowTerms = [33, 13, 12, 4, 3, 1]
|
|
97
|
+
n = len(listA259703rowTerms) + 1
|
|
98
|
+
rowSum = sum(listA259703rowTerms)
|
|
99
|
+
A000682for_n = A000682(n)
|
|
100
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
101
|
+
|
|
102
|
+
listA259703rowTerms = [87, 35, 30, 12, 6, 3, 1]
|
|
103
|
+
n = len(listA259703rowTerms) + 1
|
|
104
|
+
rowSum = sum(listA259703rowTerms)
|
|
105
|
+
A000682for_n = A000682(n)
|
|
106
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
107
|
+
|
|
108
|
+
listA259703rowTerms = [252, 98, 90, 32, 21, 6, 4, 1]
|
|
109
|
+
n = len(listA259703rowTerms) + 1
|
|
110
|
+
rowSum = sum(listA259703rowTerms)
|
|
111
|
+
A000682for_n = A000682(n)
|
|
112
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
113
|
+
|
|
114
|
+
listA259703rowTerms = [703, 278, 243, 94, 54, 21, 8, 4, 1]
|
|
115
|
+
n = len(listA259703rowTerms) + 1
|
|
116
|
+
rowSum = sum(listA259703rowTerms)
|
|
117
|
+
A000682for_n = A000682(n)
|
|
118
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
119
|
+
|
|
120
|
+
listA259703rowTerms = [2105, 812, 745, 270, 175, 57, 32, 8, 5, 1]
|
|
121
|
+
n = len(listA259703rowTerms) + 1
|
|
122
|
+
rowSum = sum(listA259703rowTerms)
|
|
123
|
+
A000682for_n = A000682(n)
|
|
124
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
125
|
+
|
|
126
|
+
listA259703rowTerms = [6099, 2385, 2108, 808, 485, 181, 84, 32, 10, 5, 1]
|
|
127
|
+
n = len(listA259703rowTerms) + 1
|
|
128
|
+
rowSum = sum(listA259703rowTerms)
|
|
129
|
+
A000682for_n = A000682(n)
|
|
130
|
+
print(rowSum == A000682for_n, f"{n = }, {A000682for_n = }, {rowSum = }")
|
|
131
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
|
|
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), # `bridges = 13`, 0xaaaaaaaa.bit_length() = 32
|
|
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), # 0x5000000000000000.bit_length() = 63; 0xaaaaaaaaaaaaaaaa.bit_length() = 64; 0x5555555555555555.bit_length() = 63
|
|
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
|
+
"""`bridges = 29`
|
|
67
|
+
0x5000000000000000.bit_length() = 63;
|
|
68
|
+
0xaaaaaaaaaaaaaaaa.bit_length() = 64;
|
|
69
|
+
0x5555555555555555.bit_length() = 63"""
|
|
70
|
+
|
|
71
|
+
listCurveMaximums = listCurveMaximums[0:bridges]
|
|
72
|
+
|
|
73
|
+
dictionaryCurveLocations: dict[int, int] = {}
|
|
74
|
+
while bridges > 0:
|
|
75
|
+
bridges -= 1
|
|
76
|
+
|
|
77
|
+
bifurcationAlphaLocator, bifurcationZuluLocator, curveLocationsMAXIMUM = listCurveMaximums[bridges]
|
|
78
|
+
|
|
79
|
+
for curveLocations, distinctCrossings in startingCurveLocations.items():
|
|
80
|
+
bifurcationAlpha = (curveLocations & bifurcationAlphaLocator)
|
|
81
|
+
bifurcationZulu = (curveLocations & bifurcationZuluLocator) >> 1
|
|
82
|
+
|
|
83
|
+
bifurcationAlphaHasCurves = bifurcationAlpha != 1
|
|
84
|
+
bifurcationZuluHasCurves = bifurcationZulu != 1
|
|
85
|
+
|
|
86
|
+
# Z0Z_simpleBridges
|
|
87
|
+
curveLocationAnalysis = ((bifurcationAlpha | (bifurcationZulu << 1)) << 2) | 3
|
|
88
|
+
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
89
|
+
dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
90
|
+
|
|
91
|
+
# bifurcationAlphaCurves
|
|
92
|
+
if bifurcationAlphaHasCurves:
|
|
93
|
+
curveLocationAnalysis = (bifurcationAlpha >> 2) | (bifurcationZulu << 3) | ((bifurcationAlphaIsEven := 1 - (bifurcationAlpha & 0b1)) << 1)
|
|
94
|
+
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
95
|
+
dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
96
|
+
|
|
97
|
+
# bifurcationZuluCurves
|
|
98
|
+
if bifurcationZuluHasCurves:
|
|
99
|
+
curveLocationAnalysis = (bifurcationZulu >> 1) | (bifurcationAlpha << 2) | (bifurcationZuluIsEven := 1 - (bifurcationZulu & 1))
|
|
100
|
+
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
101
|
+
dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
102
|
+
|
|
103
|
+
# Z0Z_alignedBridges
|
|
104
|
+
if bifurcationZuluHasCurves and bifurcationAlphaHasCurves:
|
|
105
|
+
# One Truth-check to select a code path
|
|
106
|
+
bifurcationsCanBePairedTogether = (bifurcationZuluIsEven << 1) | bifurcationAlphaIsEven # pyright: ignore[reportPossiblyUnboundVariable]
|
|
107
|
+
|
|
108
|
+
if bifurcationsCanBePairedTogether != 0: # Case 0 (False, False)
|
|
109
|
+
XOrHere2makePair = 0b1
|
|
110
|
+
findUnpaired_0b1 = 0
|
|
111
|
+
|
|
112
|
+
if bifurcationsCanBePairedTogether == 1: # Case 1: (False, True)
|
|
113
|
+
while findUnpaired_0b1 >= 0:
|
|
114
|
+
XOrHere2makePair <<= 2
|
|
115
|
+
findUnpaired_0b1 += 1 if (bifurcationAlpha & XOrHere2makePair) == 0 else -1
|
|
116
|
+
bifurcationAlpha ^= XOrHere2makePair
|
|
117
|
+
elif bifurcationsCanBePairedTogether == 2: # Case 2: (True, False)
|
|
118
|
+
while findUnpaired_0b1 >= 0:
|
|
119
|
+
XOrHere2makePair <<= 2
|
|
120
|
+
findUnpaired_0b1 += 1 if (bifurcationZulu & XOrHere2makePair) == 0 else -1
|
|
121
|
+
bifurcationZulu ^= XOrHere2makePair
|
|
122
|
+
|
|
123
|
+
# Cases 1, 2, and 3 all compute curveLocationAnalysis
|
|
124
|
+
# TODO https://github.com/hunterhogan/mapFolding/issues/19
|
|
125
|
+
curveLocationAnalysis = ((bifurcationZulu >> 2) << 1) | (bifurcationAlpha >> 2)
|
|
126
|
+
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
127
|
+
dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
128
|
+
|
|
129
|
+
startingCurveLocations.clear()
|
|
130
|
+
startingCurveLocations, dictionaryCurveLocations = dictionaryCurveLocations, startingCurveLocations
|
|
131
|
+
|
|
132
|
+
# print(sum(startingCurveLocations.values()))
|
|
133
|
+
return sum(startingCurveLocations.values())
|
|
134
|
+
|