Skip to content

Instantly share code, notes, and snippets.

@lastforkbender
Last active June 12, 2024 23:45
Show Gist options
  • Select an option

  • Save lastforkbender/55307412d30a44fa705cecf449be892b to your computer and use it in GitHub Desktop.

Select an option

Save lastforkbender/55307412d30a44fa705cecf449be892b to your computer and use it in GitHub Desktop.
RVD Collatz Breaker Slots Class
# This slots performance class will show you how to do rvd calculations on a collatz seq
# and which numbers cause a endless loop(aka magic) with rvd constant totals re-entered.
# Is very important in understanding how one would go about finding other constants to
# set a specific shifting algorithm, where collatz conjecture passes behind loop shifter
# 9 or entangles the next sequence number of 9's by *3 to a new added spanning to +1's.
# With Menorah type rvd constants counts then would only require two unique palindrome
# numbers for each found pair looping, however still require lots of computer power.
from collections import deque
# Sets folder/file path for this modules calculations stacks results.
_CURR_RCRD_PATH = '/my_path/'
class CollatzRvd():
__slots__ = ()
def __init__(self):
pass
#__________________________________________________________________________________
class CollatzBreakRvd(CollatzRvd):
__slots__ = ('_sCltzSeq','_sCltzNum','_sCltzRvd','_sCltzRvdLst','_sCltzPlndrmRvdLst','_sCltzPlndrmRvdInnrLst','_sCltzSeqRcrd','_sPrintRcrd','_pStrA','_pBoolA','_lBoolA','_sStrA','_sLstA','_sIntA','_rLstA','_rLstB','_rLstC','_rStrA','_rStrB','_rIntA','_rIntB','_rIntC','_rIntD','_rIntE','_rIntF','_rIntG','_rBoolA')
def __init__(self):
pass
#__________________________________________________________________________________
def run_rvd_calcs(self, scn: int, ecn: int):
self._sPrintRcrd = deque()
self._sCltzRvdLst = deque()
self._sCltzSeqRcrd = deque()
self._sCltzPlndrmRvdLst = deque()
self._sCltzPlndrmRvdInnrLst = set()
while scn < ecn:
self._sCltzNum = scn
self._sIntA = None
self._rStrA = str(scn)
if self._rStrA == self._rStrA[::-1]:
while True:
self.set_collatz_sequence_list()
if self._sCltzSeq[0] != 19:
self._sCltzSeqRcrd.append(self._sCltzSeq)
self.set_collatz_rvd_constants_list_19()
self._sCltzNum = sum(self._sCltzRvd)
if self._sIntA == self._sCltzNum:
self._sStrA = str(scn)
if self._sStrA == self._sStrA[::-1]:
self._sCltzPlndrmRvdLst.append(scn)
self.print_record(False, f'___|: Number *{scn}* is a palindrome rvd collatz number')
self.print_record(False, '\n')
print(f'___|: Number *{scn}* is a palindrome rvd collatz number')
self.print_record(False, f'_______|: starting deep menorah palindrome analysis')
self.print_record(False, '\n')
print(f'_______|: starting deep menorah palindrome analysis')
self.set_central_inner_rvd_palindromes()
if self._sLstA != None:
for self._rIntA in range(len(self._sLstA)):
self._sCltzPlndrmRvdInnrLst.add(self._sLstA[self._rIntA])
self.run_inner_palindromes_collatz_seq_scan()
self._sCltzSeqRcrd = deque()
else:
print(f'___|: Number ({scn}) is a rvd collatz number')
self._sCltzRvdLst.append(str(scn))
self._sCltzSeqRcrd = deque()
break
else: self._sIntA = self._sCltzNum
if self._sIntA == 0:
self._sCltzSeqRcrd = deque()
print(f'___|: Number ({scn}) is not a rvd collatz number')
break
scn += 1
self.print_record(True, None)
self.reset_slots(True)
#__________________________________________________________________________________
def set_collatz_sequence_list(self):
self._sCltzSeq = deque()
self._sCltzSeq.append(self._sCltzNum)
while self._sCltzNum != 1:
if self._sCltzNum % 2 == 0: self._sCltzNum = self._sCltzNum // 2
else: self._sCltzNum = 3 * self._sCltzNum + 1
self._sCltzSeq.append(self._sCltzNum)
#__________________________________________________________________________________
def set_collatz_rvd_constants_list_9(self):
# Is pure Base10 rvd count, magic rvd numbers will endless loop @ 9 with a
# _sCltzRvd total. This adds magic rvd numbers happening three in a row or
# is much faster, however the faster in this case of later calcs not good.
# Rvd numbers happening three in a row means large exponent involvements.
# **This method here by example only, can be used by other conjectures.**
self._sCltzRvd = deque()
self._rIntB = len(self._sCltzSeq)
for self._rIntA in range(self._rIntB):
self._rIntE = 0
self._rLstA = deque()
self._rStrB = str(self._sCltzSeq[self._rIntA])
for self._rStrA in self._rStrB: self._rLstA.append(int(self._rStrA))
if len(self._rLstA) > 1:
self._rIntC = 0
self._rIntD = len(self._rLstA) - 1
while self._rIntC < self._rIntD:
if self._rLstA[self._rIntC] > self._rLstA[self._rIntC + 1]:
self._rIntE += 1
elif self._rLstA[self._rIntC] == 9 and self._rLstA[self._rIntC + 1] == 9:
self._rIntE += 2
elif self._rLstA[self._rIntC] == 9 or self._rLstA[self._rIntC + 1] == 9:
self._rIntE += 1
self._rIntC += 1
elif self._rLstA[0] == 9: self._rIntE += 1
if self._rIntE > 0:
if self._rIntA == 0 or self._rIntA == self._rIntB - 1:
self._sCltzRvd.append(self._rIntE)
else: self._sCltzRvd.append(self._rIntE * 2)
#__________________________________________________________________________________
def set_collatz_rvd_constants_list_19(self):
# Is Menorah palindrome based count, spans entire distance of Base10 before
# loop; magic rvd numbers will endless loop @ 19 on sum(_sCltzRvd). Though
# is slower... is faster, magic rvd numbers will not occur three in a row.
# Here, if _sCltzRvd list ends of five trailing loops(zeros) then is a true
# conversion or merge count; and if not then not, is false. Must be odds or
# a even balance 2's to 1 for proper conversion rvd counts with Menorah-3HL.
self._sCltzRvd = deque()
self._rIntB = len(self._sCltzSeq) - 1
for self._rIntA in range(self._rIntB):
self._rIntF = 0
for self._rIntC in range(2):
if self._rIntC == 0: self._rStrA = str(self._sCltzSeq[self._rIntA])
else: self._rStrA = str(self._sCltzSeq[self._rIntA + 1])
if len(self._rStrA) > 1:
self._rIntE = None
for self._rStrB in self._rStrA:
if self._rIntE != None:
self._rIntD = int(self._rStrB)
if self._rIntD != 9 and self._rIntE != 9:
while True:
if self._rIntE == 9:
self._rIntF += 1
break
self._rIntE += 1
if self._rIntE == self._rIntD:
break
else:
if self._rIntD == 9 and self._rIntE == 9:
self._rIntF += 2
else: self._rIntF += 1
self._rIntE = int(self._rStrB)
elif self._rStrA == '9': self._rIntF += 1
self._sCltzRvd.append(self._rIntF)
#__________________________________________________________________________________
def run_inner_palindromes_collatz_seq_scan(self):
# This to be considered of pairing orders to palindrome half-loop distances.
# Whereof... if number 141 does not appear in a match, is suitable to do --
# cluster ratios on where the other, 848, aligned where and when previously.
# However... this also heavily depending on the probabilty of frequent pairs
# within the nested scope >5 palindromes because of the rvd method set to 19.
# Such enumerations not applied & need an extreme amount of processing power.
self.print_record(False, f'_________|: comparing collatz seqs shifts+adds to any inner rvd-palindromes')
self.print_record(False, '\n')
print(f'_________|: comparing collatz seqs shifts+adds to any inner rvd-palindromes')
self._sLstA = deque()
for self._rIntA, sublist in enumerate(self._sCltzSeqRcrd):
self._rIntB = len(self._sCltzSeqRcrd[self._rIntA]) - 1
self._rIntD = self._rIntB + 1
while self._rIntB > -1:
for self._rIntC in range(self._rIntD):
if self._rIntC != self._rIntB:
self._rStrA = str(self._sCltzSeqRcrd[self._rIntA][self._rIntB] + self._sCltzSeqRcrd[self._rIntA][self._rIntC])
if len(self._rStrA) > 2 and self._rStrA == self._rStrA[::-1]:
self._rBoolA = True
self._rIntE = int(self._rStrA)
for self._sIntA in range(len(self._sLstA)):
if self._sLstA[self._sIntA] == self._rIntE:
self._rBoolA = False
break
if self._rBoolA:
self._sLstA.append(self._rIntE)
print(f'___________|: found a shift+add collatz seq palindrome ({self._rStrA})')
self._rBoolA = False
self._rIntF = len(self._sCltzPlndrmRvdLst) - 1
while self._rIntF > -1:
if self._rIntE == self._sCltzPlndrmRvdLst[self._rIntF]:
self.print_record(False, f'___________|: icpn number ({self._rStrA}) matches a inner rvd-palindrome')
self.print_record(False, '\n')
print(f'___________|: icpn number ({self._rStrA}) matches a inner rvd-palindrome')
self._rBoolA = True
break
self._rIntF -=1
if not self._rBoolA:
print(f'___________|: no match found to any inner rvd-palindrome...')
self._rIntB -= 1
#__________________________________________________________________________________
def set_central_inner_rvd_palindromes(self):
# Cross section adding of all current rvd palindrome numbers found in slots
# list _sCltzPlndrmRvdLst for central-inner palindrome matches. Stored, if
# any sums found to slots list _sLstA; sorted order is largest to smallest.
# This is about the basis of palindrome tolerance loops viable and would be
# much more involved in a Menorah base calculations, where of each rvd ----
# palindrome number would be merged of a previous or next before shift+add,
# because 'decimal' in Menorah base = half-loop merges/non-static loop seq.
self._rIntA = len(self._sCltzPlndrmRvdLst)
self._rIntC = self._rIntA
self._sLstA = set()
if self._rIntA > 1:
self.print_record(False, f'_______|: ({self._rIntA}) rvd palindromes for shift+add match search')
self.print_record(False, '\n')
print(f'_______|: ({self._rIntA}) rvd palindromes for shift+add match search')
self.print_record(False, f'_______|: performing rvd type shift+add palindrome find(s)')
self.print_record(False, '\n')
print(f'_______|: performing rvd type shift+add palindrome find(s)')
self._rIntA -= 1
while self._rIntA > -1:
for self._rIntB in range(self._rIntC):
if self._rIntB != self._rIntA:
self._rStrA = str(self._sCltzPlndrmRvdLst[self._rIntB] + self._sCltzPlndrmRvdLst[self._rIntA])
if self._rStrA == self._rStrA[::-1]: self._sLstA.add(int(self._rStrA))
self._rIntA -= 1
self._rIntB = len(self._sLstA)
if self._rIntB > 0:
self._sLstA = list(self._sLstA)
self._sLstA.sort(reverse=True)
self.print_record(False, f'_______|: found ({self._rIntB}) central-inner shift+add rvd palindrome(s)')
self.print_record(False, '\n')
print(f'_______|: found ({self._rIntB}) central-inner shift+add rvd palindrome(s)')
for self._rIntA in range(self._rIntB):
self.print_record(False, f'_________| irvdp_{self._rIntA+1}: {self._sLstA[self._rIntA]}')
self.print_record(False, '\n')
print(f'_________| irvdp_{self._rIntA+1}: {self._sLstA[self._rIntA]}')
else:
self._sLstA = None
self.print_record(False, '_______|: no found inner shift+add rvd palindrome(s)')
self.print_record(False, '\n')
print('_______|: no found inner shift+add rvd palindrome(s)')
else:
self._sLstA = None
self.print_record(False, '_______|: only (1) found rvd palindrome currently in list')
self.print_record(False, '\n')
print('_______|: only (1) found rvd palindrome currently in list')
self.print_record(False, '_______|: no shift+add rvd palindromes searching done')
self.print_record(False, '\n')
print('_______|: no shift+add rvd palindromes searching done')
#__________________________________________________________________________________
def print_record(self, mWrt: bool, txt: str):
if len(_CURR_RCRD_PATH) > 0:
self._pBoolA = False
if not mWrt: self._sPrintRcrd.append(txt)
else:
if len(self._sPrintRcrd) < 1: self._pBoolA = True
if len(self._sPrintRcrd) > 999 or mWrt:
if not self._pBoolA:
with open(_CURR_RCRD_PATH, 'r') as fObjRdr:
self._pStrA = fObjRdr.read()
with open(_CURR_RCRD_PATH, 'w') as fObjWrt:
fObjWrt.write(f'{self._pStrA}{"".join(self._sPrintRcrd)}')
self._sPrintRcrd = deque()
#__________________________________________________________________________________
def reset_slots(self, sRst: bool):
if sRst:
self._sCltzSeq = None
self._sCltzNum = None
self._sCltzRvd = None
self._sCltzPlndrmRvdLst = None
self._sCltzPlndrmRvdInnrLst = None
self._sCltzSeqRcrd = None
self._sCltzRvdLst = None
self._sPrintRcrd = None
self._pStrA = None
self._pBoolA = None
self._sLstA = None
self._sStrA = None
self._sIntA = None
self._rLstA = None
self._rLstB = None
self._rLstC = None
self._rStrA = None
self._rStrB = None
self._rIntA = None
self._rIntB = None
self._rIntC = None
self._rIntD = None
self._rIntE = None
self._rIntF = None
self._rIntG = None
self._rBoolA = None
#__________________________________________________________________________________
def runRvdCollatz():
cls = CollatzBreakRvd()
cls.run_rvd_calcs(1, 2000001)
runRvdCollatz()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment