From 282a68b8d34ba2c22c153b74761763f4fb2eea34 Mon Sep 17 00:00:00 2001 From: George Dorn Date: Tue, 11 Jul 2023 12:52:54 -0700 Subject: [PATCH] Only rotate newly-found polycubes, not every candidate --- cubes.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cubes.py b/cubes.py index 18e6fb5..c8e5b9e 100644 --- a/cubes.py +++ b/cubes.py @@ -135,7 +135,8 @@ def generate_polycubes(n, use_cache=False): for new_cube in expand_cube(base_cube): if not cube_exists_rle(new_cube, polycubes_rle): polycubes.append(new_cube) - polycubes_rle.add(rle(new_cube)) + for cube_rotation in all_rotations(new_cube): + polycubes_rle.add(rle(cube_rotation)) if (idx % 100 == 0): perc = round((idx / len(base_cubes)) * 100,2) @@ -200,9 +201,8 @@ def cube_exists_rle(polycube, polycubes_rle): boolean: True if polycube is already present in the set of all cubes so far. """ - for cube_rotation in all_rotations(polycube): - if rle(cube_rotation) in polycubes_rle: - return True + if rle(polycube) in polycubes_rle: + return True return False