-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0951c03
commit cdd3922
Showing
2 changed files
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import math | ||
|
||
|
||
def guess_the_label_size(path_size: int, combination_size: int): | ||
if path_size == 0: | ||
return 1 | ||
|
||
# The theoritical limit for this at the time of writing is 2_538_557_185_841_324_496 (python 3.12.2) | ||
calculated_path_size = 0 | ||
# The theoritical limit for this at the time of writing is 32 (python 3.12.2) | ||
label_size = 0 | ||
|
||
# THIS IS AN VERY IMPORTANT CHECK | ||
last = 0 | ||
|
||
while True: | ||
possible_cominations = math.comb(combination_size, label_size) | ||
if last > possible_cominations: | ||
raise ValueError("We approached the limit of `math.comb`") | ||
|
||
last = possible_cominations | ||
calculated_path_size += possible_cominations | ||
|
||
if calculated_path_size > path_size: | ||
break | ||
|
||
label_size += 1 | ||
|
||
return label_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters