From 3a13c94b78bf8a318de99583b407daf19d78f2ec Mon Sep 17 00:00:00 2001 From: Emmanuel Di Pretoro Date: Thu, 9 Jul 2026 17:00:44 +0200 Subject: [PATCH] First iteration of a working initcounters method --- noid.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/noid.py b/noid.py index c5f9fb4..c7a8a0c 100644 --- a/noid.py +++ b/noid.py @@ -17,6 +17,7 @@ class Minter(): oacounter: int = 0 oatop: int = 0 + percounter: int = 0 template: str = "" prefix: str = "" mask: str = "" @@ -97,11 +98,11 @@ class Minter(): # 10. return the noid return "" - def initcounters() -> None: - # 1. Initialize oacounter to 0 - # 2. Set up a maxcounters variable to 293 - # 3. Set up a percounter variable to int(total / maxcounters + 1) - # 4. Divides $total into sub-counters of size $pctr, stores this + def initcounters(self) -> None: + # 1. [X] Initialize oacounter to 0 + # 2. [X] Set up a maxcounters variable to 293 + # 3. [X] Set up a percounter variable to int(total / maxcounters + 1) + # 4. [X] Divides $total into sub-counters of size $pctr, stores this # distribution in $noid, and prepares the structure to generate # IDs in a balanced manner. # - copy the value of total to the variable t @@ -113,8 +114,14 @@ class Minter(): # - set value of this counter to 0 # - add the counter to saclist # - 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__": import doctest