Add 2021-22 in... OpenSCAD and Blender?!

This commit is contained in:
akp 2021-12-22 21:03:53 +00:00
parent 82c9b97508
commit 72364791bf
No known key found for this signature in database
GPG key ID: AA5726202C8879B7
6 changed files with 2211 additions and 1 deletions

View file

@ -1,2 +1,16 @@
# [Day 22: Reactor Reboot](https://adventofcode.com/2021/day/22) # [Day 22: Reactor Reboot](https://adventofcode.com/2021/day/22)
Today's solution is a little weird...
I solved part one using the easy, store every point method. However, for part two, I didn't want to go to the trouble of writing code to work out the intersections of all the cubes. Instead, I chose to do the following:
* Wrote some Python code (`openscad-generate.py`) to generate some [OpenSCAD](http://openscad.org/) code based on the challenge input
* This made liberal use of nested `union()`, `difference()`, `translate()` and `cube()` functions
* Ran this code in OpenSCAD and exported the resultant model as an STL
* Imported this STL file into Blender and used the 3D-Print Toolbox addon to calculate the total volume of the object
* Typed this number into the AoC website
* Obtained the 2nd star ★ :D
![openscad](openscad-part-2.png)
![blender](blender-part-2.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

View file

@ -0,0 +1,98 @@
union() {
difference() {
union() {
difference() {
union() {
difference() {
union() {
difference() {
union() {
difference() {
union() {
union() {
union() {
union() {
union() {
union() {
union() {
union() {
union() {
translate([-40, -3, -48]) {
cube([48, 53, 55], center=false);
};
translate([-38, -11, -30]) {
cube([49, 49, 50], center=false);
};
};
translate([-43, -16, -38]) {
cube([45, 47, 52], center=false);
};
};
translate([-10, -8, -41]) {
cube([55, 55, 46], center=false);
};
};
translate([-27, -2, -33]) {
cube([47, 48, 46], center=false);
};
};
translate([-41, -18, -34]) {
cube([46, 51, 54], center=false);
};
};
translate([-43, -20, -34]) {
cube([53, 48, 55], center=false);
};
};
translate([-47, -5, -20]) {
cube([46, 55, 53], center=false);
};
};
translate([-20, -40, -16]) {
cube([54, 47, 50], center=false);
};
};
translate([-25, -47, -46]) {
cube([50, 46, 53], center=false);
};
};
translate([-28, -6, 22]) {
cube([20, 11, 16], center=false);
};
};
translate([-34, -16, -43]) {
cube([49, 49, 47], center=false);
};
};
translate([-36, -44, 5]) {
cube([19, 12, 12], center=false);
};
};
translate([-23, -34, -38]) {
cube([46, 46, 51], center=false);
};
};
translate([-24, 26, -18]) {
cube([10, 14, 10], center=false);
};
};
translate([-23, -31, -38]) {
cube([46, 52, 52], center=false);
};
};
translate([-16, 7, -44]) {
cube([11, 13, 15], center=false);
};
};
translate([-8, -18, -27]) {
cube([54, 47, 46], center=false);
};
};
translate([-24, -3, 33]) {
cube([17, 11, 13], center=false);
};
};
translate([-28, -15, -18]) {
cube([47, 55, 54], center=false);
};
};

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,7 @@ Solutions to the [2021 Advent of Code](https://adventofcode.com/2021).
| 19 - Beacon Scanner | Unattempted | | | | 19 - Beacon Scanner | Unattempted | | |
| 20 - Trench Map \* | ★ ★ | [Python](20-trenchMap/py), [Nim](20-trenchMap/nim) | Took a moment to realise that the infinite grid alternates between lit and unlit, and even then I had to look at someone else's solution to realise it. | | 20 - Trench Map \* | ★ ★ | [Python](20-trenchMap/py), [Nim](20-trenchMap/nim) | Took a moment to realise that the infinite grid alternates between lit and unlit, and even then I had to look at someone else's solution to realise it. |
| 21 - Dirac Dice | ★ ☆ | [Python](21-diracDice/py) | Couldn't be bothered with part two - I've got too much going on at the moment to spend a lot of time thinking about it. | | 21 - Dirac Dice | ★ ☆ | [Python](21-diracDice/py) | Couldn't be bothered with part two - I've got too much going on at the moment to spend a lot of time thinking about it. |
| 22 - Reactor Reboot | ★ ☆ | [Python](22-reactorReboot/py) | Once again - couldn't be bothered with part two. | | 22 - Reactor Reboot | ★ ★ | [Python, OpenSCAD and Blender](22-reactorReboot/) | I did not expect to end up using 3D CAD software to complete AoC... |
<!-- PARSE END --> <!-- PARSE END -->