Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advent of Code Day 18 recursion for flood fill #2

Open
iglesias opened this issue Dec 26, 2022 · 1 comment
Open

Advent of Code Day 18 recursion for flood fill #2

iglesias opened this issue Dec 26, 2022 · 1 comment

Comments

@iglesias
Copy link
Owner

1 deltas = {{+1,0,0}, {0,+1,0}, {0,0,+1}};
1 for(int x{0}; x<N; x++)
2 for(int y{0}; y<N; y++)
3 flood(x,y,0);
4
5 for(int y{0}; y<N; y++)
6 for(int z{0}; z<N; z++)
7 flood(0,y,z);
8
9 for(int x{0}; x<N; x++)
10 for(int z{0}; z<N; z++)
11 flood(x,0,z);
12
13
14
15 for(int x{0}; x<N; x++)
16 for(int y{0}; y<N; y++)
17 {
18 flood(x,y,0, ::p(0,0,+1));
19 flood(x,y,N-1,::p(0,0,-1));
20
21 flood(x,y,0, ::p(+1,0,0));
22 flood(x,y,0, ::p(0,+1,0));
23 }
24
25 for(int y{0}; y<N; y++)
26 for(int z{0}; z<N; z++)
27 {
28 flood(0,y,z, ::p(+1,0,0));
29 flood(N-1,y,z,::p(-1,0,0));
30
31 flood(0,y,z, ::p(0,+1,0));
32 flood(0,y,z, ::p(0,0,+1));
33 }
34
35 for(int x{0}; x<N; x++)
36 for(int z{0}; z<N; z++)
37 {
38 flood(x,0,z, ::p(0,+1,0));
39 flood(x,N-1,z,::p(0,-1,0));
40
41 flood(x,0,z, ::p(+1,0,0));
42 flood(x,0,z, ::p(0,0,+1));
43 }

@iglesias
Copy link
Owner Author

Compare the first recursion to the second one.

iglesias added a commit that referenced this issue Jul 11, 2024
iglesias added a commit that referenced this issue Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant