Skip to content

Instantly share code, notes, and snippets.

@lastforkbender
Created July 16, 2024 11:51
Show Gist options
  • Select an option

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

Select an option

Save lastforkbender/fdf5269bacb5dae337e73eac8140aef7 to your computer and use it in GitHub Desktop.
A dimensional retained array count recycle repeater
from collections import deque
import math
import time
class Watch_MDial:
def __init__(self):
self.units={}
self.cycles={}
self.laments={}
self.constants={}
self.menorah_array={}
#__________________________________________________________________________________________________________________________________________________
def add_event(self, event, axis):
self.units[event] = deque()
self.laments[axis].append(event)
#__________________________________________________________________________________________________________________________________________________
def observed_axis(self, axis, expanse):
for event in self.laments[axis]:
if axis == 'X': event[0]+=expanse
elif axis == 'Y': event[1]+=expanse
elif axis == 'Z': event[2]+=expanse
elif axis == 'M': event[3]+=expanse
#__________________________________________________________________________________________________________________________________________________
def retained_cycles(self):
for axis, deque in self.laments.items():
self.cycles[axis] = 0
for r in range(1, len(deque)):
if deque[r][0] == deque[r-1][1] or deque[r][1] == deque[r-1][0] or deque[r][2] == deque[r-1][3] or deque[r][3] == deque[r-1][2]: self.cycles[axis]+=1
#__________________________________________________________________________________________________________________________________________________
def observe_cycle_length(self, axis, observed_distance, spawn):
while True:
observer = list(self.laments[axis])[-observed_distance:]
min_pass = min(min(event) for event in observer)
max_pass = max(max(event) for event in observer)
constant = (min_pass + max_pass)/2
menorah_nearest = self.find_menorah_nearest(constant)
self.constants[axis] = {'constant': constant, 'menorah_nearest': menorah_nearest}
time.sleep(spawn)
#__________________________________________________________________________________________________________________________________________________
def find_menorah_nearest(self, num):
def is_initial(n):
return str(n) == str(n)[::-1]
min_h = max_h = num
while True:
if is_initial(min_h):
return min_h
if is_initial(max_h):
return max_h
min_h-=1
max_h+=1
#__________________________________________________________________________________________________________________________________________________
def get_units(self):
return self.units.keys()
#__________________________________________________________________________________________________________________________________________________
def get_region(self, axis):
return self.laments[axis]
#__________________________________________________________________________________________________________________________________________________
def get_constants(self):
return self.constants
#__________________________________________________________________________________________________________________________________________________
def get_menorah_array(self, constants):
self.menorah_array = [[[0 for S in range(3)] for S in range(3)] for S in range(3)]
keys = list(constants.keys())
q_cycles = [constants[pattern]['menorah_nearest'] for pattern in keys]
q_cycles.sort()
m = 1
for t, initial in enumerate(q_cycles):
x, y, z = self.scroll_position(t, m)
self.menorah_array[x][y][z] = initial
return self.menorah_array
#__________________________________________________________________________________________________________________________________________________
def scroll_position(self, l, m):
x = int(((l+m)*(math.pi+l))/(l+1))%3
y = int(((l+m)*(math.pi+l))/(l+2))%3
z = int(((l+m)*(math.pi+l))/(l+3))%3
if ((x+m)*(math.pi+l)/(l+2)) > 2*y: m-=1
else: m+=1
return x, y, z
#__________________________________________________________________________________________________________________________________________________
#__________________________________________________________________________________________________________________________________________________
solid_diamond_fork = Watch_MDial()
solid_diamond_fork.add_event((94037278210483076551,40729486105482648032,53028440062841184329,53927740305118473764), 'X')
solid_diamond_fork.add_event((2,3,4,5), 'X')
solid_diamond_fork.add_event((1,5,6,8), 'Y')
solid_diamond_fork.add_event((3,4,5,6), 'Y')
solid_diamond_fork.observed_axis('X', 11)
solid_diamond_fork.observed_axis('Y', 22)
solid_diamond_fork.retained_cycles()
print(solid_diamond_fork.get_cycles())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment