Skip to content

Instantly share code, notes, and snippets.

@lastforkbender
Created February 10, 2024 11:50
Show Gist options
  • Select an option

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

Select an option

Save lastforkbender/bf31842561097176a8ea82f261cdfa49 to your computer and use it in GitHub Desktop.
Collective class return for pkm validations
# ⟔ {○S%◒⇄◓,...
# n(◐ₓ⇒◐Lm←⍜ⁿ) < {9999,999,99,9,...
# S⇿◐ₜⅆ-⅓●÷⟔|◒>6174
# rcttcr5@gmail.com
# ■■■■■□□□□□□□■■■■■
# ■■■■■□□□□□□□■■■■■
# □□□□□■■■■■■■□□□□□
# □□□□□■■■■■■■□□□□□
# □□□□□■■■■■■■□□□□□
# □□□□□■■■■■■■□□□□□
# □□□□□■■■■■■■□□□□□
# ■■■■■■■■■■■■■■■■■
# ■■■■■■■■■■■■■■■■■
# (6174÷7)+(6174÷9)=1568
# 2×3×4×5=120
# 1×5×6×8=240
# 3×4×5×6=360
# (2345+1568+3456)÷ℼ=~2345.
# -------------------------------------------------------------
# 5432-2345=3087
# 8651-1568=7083
# 6543-3456=3087
# {3, 0, 8, 7{7, 0, 8, 3}3, 0, 8, 7}
# 6174=3087×2
# 7083-6174=909 ← 0
# -------------------------------------------------------------
# List:
# x{y-m, m, z} ⇒ (◐3) ← ◒𝆑 + ⅟ < ⅆ
class PKM():
def __init__(self, values: list, prevalue, l, q, r):
self.values = values
self.pre_val = prevalue
self.junction_values = None
self.cached_list = None
self._l = l
self._q = q
self._r = r
#___________________________________________________________________________________
def _fnd_jncn_vls(self):
self.junction_values = [
next((x for x in self.values if 0 <= x <= 360), None),
next((x for x in self.values if 0 <= x - 90 <= 360), None),
next((x for x in self.values if 0 <= x - 180 <= 360), None),
next((x for x in self.values if 0 <= x - 270 <= 360), None),
]
#___________________________________________________________________________________
def _fnd_pkm(self, prevalence, limit_return=self._l):
if self.prev_val is not None: bumper_else_val = self.prev_val
else: bumper_else_val = 0
self._fnd_jncn_vls()
if not all(junction_value is not None for junction_value in self.junction_values):
raise ValueError("Invalid input list")
self.cached_list = sorted(self.values, reverse=True)
for i in range(len(self.cached_list)):
if self.cached_list[i] == self.junction_values[prevalence]:
if i > 0 and self.cached_list[i-1] == bumper_else_val:
continue
self.cached_list[i] = 0
if i < len(self.cached_list) - 1 and self.cached_list[i+1] == bumper_else_val:
continue
for j in range(i+1, len(self.cached_list)):
if self.cached_list[j] == self.junction_values[(prevalence+1) % self._q]:
self.cached_list[j] = 0
break
self.prev_val = bumper_else_val
if limit_return > 0:
return self.cached_list[-limit_return:]
else:
return sum(self.cached_list[-self._r:])
#___________________________________________________________________________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment