First iteration of a working initcounters method

This commit is contained in:
2026-07-09 17:00:44 +02:00
parent 5c01d319f5
commit 3a13c94b78
+14 -7
View File
@@ -17,6 +17,7 @@ class Minter():
oacounter: int = 0 oacounter: int = 0
oatop: int = 0 oatop: int = 0
percounter: int = 0
template: str = "" template: str = ""
prefix: str = "" prefix: str = ""
mask: str = "" mask: str = ""
@@ -97,11 +98,11 @@ class Minter():
# 10. return the noid # 10. return the noid
return "" return ""
def initcounters() -> None: def initcounters(self) -> None:
# 1. Initialize oacounter to 0 # 1. [X] Initialize oacounter to 0
# 2. Set up a maxcounters variable to 293 # 2. [X] Set up a maxcounters variable to 293
# 3. Set up a percounter variable to int(total / maxcounters + 1) # 3. [X] Set up a percounter variable to int(total / maxcounters + 1)
# 4. Divides $total into sub-counters of size $pctr, stores this # 4. [X] Divides $total into sub-counters of size $pctr, stores this
# distribution in $noid, and prepares the structure to generate # distribution in $noid, and prepares the structure to generate
# IDs in a balanced manner. # IDs in a balanced manner.
# - copy the value of total to the variable t # - copy the value of total to the variable t
@@ -113,8 +114,14 @@ class Minter():
# - set value of this counter to 0 # - set value of this counter to 0
# - add the counter to saclist # - add the counter to saclist
# - substract pctr from t # - substract pctr from t
pass maxcounters = 293
self.percounter = int(self.oatop / maxcounters + 1)
t = self.oatop
while t > 0:
top = self.percounter if t >= self.percounter else t
c = Counter(top=top, value=0)
self.active_counters.append(c)
t -= self.percounter
if __name__ == "__main__": if __name__ == "__main__":
import doctest import doctest