mikepound / cubes

This code calculates all the variations of 3D polycubes for any size (time permitting!)
MIT License
163 stars 43 forks source link

Find the polycube in crop_cube to remove padding #11

Closed ana-096 closed 1 year ago

ana-096 commented 1 year ago

Avoids the extremely slow usage of while loops by finding where the polycube is rather than where it isn't. I haven't extensively tested it to ensure it is working correctly.

cubes.py --no-cache 9
Generating polycubes n=3: 100%
Generating polycubes n=4: 100%
Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Generating polycubes n=9: 100%
Found 48311 unique polycubes
Elapsed time: 84.735s

With faster crop:

cubes.py --no-cache 9
Generating polycubes n=3: 100%
Generating polycubes n=4: 100%
Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Generating polycubes n=9: 100%
Found 48311 unique polycubes
Elapsed time: 76.839s

With bertie2 and georgedorn optimisations:

python cubes.py --no-cache 9
Generating polycubes n=3: 100%
Generating polycubes n=4: 100%
Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Generating polycubes n=9: 100%
Found 48311 unique polycubes
Elapsed time: 35.043s

With bertie2 and georgedorn optimisations and faster crop:

python cubes.py --no-cache 9
Generating polycubes n=3: 100%
Generating polycubes n=4: 100%
Generating polycubes n=5: 100%
Generating polycubes n=6: 100%
Generating polycubes n=7: 100%
Generating polycubes n=8: 100%
Generating polycubes n=9: 100%
Found 48311 unique polycubes
Elapsed time: 26.828s
mikepound commented 1 year ago

This looks great :) Because of the sudden interest in the repo I've created a new one for these kinds of pull requests:

https://github.com/mikepound/opencubes

This way this one can be fixed to reflect how it was in the video, but many more people can start contributing.