Skip to main content
Fix explanations
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (JDK), 126 bytes

n->{int s=1,H[][]=new int[n+=Math.pow(3,n)-n][n],x;for(;s<n;s*=3)for(x=n*n;x-->0;)H[x/n][x%n]|=~(x/n/s%3)&x%n/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Mathint s=1, // size of the carvings. H[][]=new int[n+=Math.pow(3,n)-n;n][n],   // change n to 3^n, through +=...-n to avoid an explicit cast   int s=1,  // size of the carvings.  H[][]=new int[n][n], //  and create the 2D array to return, filled with 0s x; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n*n;x-->0;) // for each cell H[x/n][x%n] |= // assign 1 to a cell of the array if... ~(x/n/s%3) // it is located in the "holes" of the H &x%n/s%3 // &1; // return H; // return the array } // end the lambda 

Credits

Java (JDK), 126 bytes

n->{int s=1,H[][]=new int[n+=Math.pow(3,n)-n][n],x;for(;s<n;s*=3)for(x=n*n;x-->0;)H[x/n][x%n]|=~(x/n/s%3)&x%n/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to 3^n, through +=...-n to avoid an explicit cast   int s=1,  // size of the carvings.  H[][]=new int[n][n], // the 2D array to return, filled with 0s x; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n*n;x-->0;) // for each cell H[x/n][x%n] |= // assign 1 to a cell of the array if... ~(x/n/s%3) // it is located in the "holes" of the H &x%n/s%3 // &1; // return H; // return the array } // end the lambda 

Credits

Java (JDK), 126 bytes

n->{int s=1,H[][]=new int[n+=Math.pow(3,n)-n][n],x;for(;s<n;s*=3)for(x=n*n;x-->0;)H[x/n][x%n]|=~(x/n/s%3)&x%n/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function int s=1, // size of the carvings. H[][]=new int[n+=Math.pow(3,n)-n][n],   // change n to 3^n, through +=...-n to avoid an explicit cast //  and create the 2D array to return, filled with 0s x; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n*n;x-->0;) // for each cell H[x/n][x%n] |= // assign 1 to a cell of the array if... ~(x/n/s%3) // it is located in the "holes" of the H &x%n/s%3 // &1; // return H; // return the array } // end the lambda 

Credits

deleted 171 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (OpenJDK 9)Java (JDK), 135126 bytes

n->{n+=Mathint s=1,H[][]=new int[n+=Math.pow(3,n)-n;int s=1,H[][]=new int[n][n],xn][n],y;forx;for(;s<n;s*=3)for(x=n;x-->0;)for(y=n;yx=n*n;x-->0;)H[x][y]|=~H[x/n][x%n]|=~(x/n/s%3)&y&x%n/s%3&1;return H;} 

Try it online!Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to 3^n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s   x,  // counter for the 2D array y;x; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n;xx=n*n;x-->0;)  // for each rowcell for(y=n;y-->0;) /H[x/ for each column H[x][y]n][x%n] |=  // assign 1 to a cell of the array if...   ~(x/n/s%3)  // it is located in the "holes" of the H   &y&x%n/s%3 // &1; &1; // return H; // return the array } // end the lambda 

Credits

Java (OpenJDK 9), 135 bytes

n->{n+=Math.pow(3,n)-n;int s=1,H[][]=new int[n][n],x,y;for(;s<n;s*=3)for(x=n;x-->0;)for(y=n;y-->0;)H[x][y]|=~(x/s%3)&y/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to 3^n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s   x,  // counter for the 2D array y; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n;x-->0;)  // for each row for(y=n;y-->0;) // for each column H[x][y] |=  // assign 1 to a cell of the array if...   ~(x/s%3) // it is located in the "holes" of the H   &y/s%3 // &1; // return H; // return the array } // end the lambda 

Java (JDK), 126 bytes

n->{int s=1,H[][]=new int[n+=Math.pow(3,n)-n][n],x;for(;s<n;s*=3)for(x=n*n;x-->0;)H[x/n][x%n]|=~(x/n/s%3)&x%n/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to 3^n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s x; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n*n;x-->0;) // for each cell H[x/n][x%n] |= // assign 1 to a cell of the array if... ~(x/n/s%3)  // it is located in the "holes" of the H &x%n/s%3 // &1; // return H; // return the array } // end the lambda 

Credits

added 1 character in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56

Java (OpenJDK 9), 135 bytes

n->{n+=Math.pow(3,n)-n;int s=1,H[][]=new int[n][n],x,y;for(;s<n;s*=3)for(x=n;x-->0;)for(y=n;y-->0;)H[x][y]|=~(x/s%3)&y/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to n3^n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s x, // counter for the 2D array y; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n;x-->0;) // for each row for(y=n;y-->0;) // for each column H[x][y] |= // assign 1 to a cell of the array if... ~(x/s%3) // it is located in the "holes" of the H &y/s%3 // &1; // return H; // return the array } // end the lambda 

Java (OpenJDK 9), 135 bytes

n->{n+=Math.pow(3,n)-n;int s=1,H[][]=new int[n][n],x,y;for(;s<n;s*=3)for(x=n;x-->0;)for(y=n;y-->0;)H[x][y]|=~(x/s%3)&y/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change  to n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s x, // counter for the 2D array y; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n;x-->0;) // for each row for(y=n;y-->0;) // for each column H[x][y] |= // assign 1 to a cell of the array if... ~(x/s%3) // it is located in the "holes" of the H &y/s%3 // &1; // return H; // return the array } // end the lambda 

Java (OpenJDK 9), 135 bytes

n->{n+=Math.pow(3,n)-n;int s=1,H[][]=new int[n][n],x,y;for(;s<n;s*=3)for(x=n;x-->0;)for(y=n;y-->0;)H[x][y]|=~(x/s%3)&y/s%3&1;return H;} 

Try it online!

Returns an int[][] with 0 for H and 1 for space. This actually "carves" a wall of H's instead of "piling" H's.

Explanations

n->{ // An int to int[][] lambda function n+=Math.pow(3,n)-n; // change n to 3^n, through +=...-n to avoid an explicit cast int s=1, // size of the carvings. H[][]=new int[n][n], // the 2D array to return, filled with 0s x, // counter for the 2D array y; // counter for the 2D array for(;s<n;s*=3) // for each size for(x=n;x-->0;) // for each row for(y=n;y-->0;) // for each column H[x][y] |= // assign 1 to a cell of the array if... ~(x/s%3) // it is located in the "holes" of the H &y/s%3 // &1; // return H; // return the array } // end the lambda 
added 942 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 2 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 4 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 9 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 119 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 1 character in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 53 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
added 70 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
deleted 4 characters in body
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading
Source Link
Olivier Grégoire
  • 14.5k
  • 3
  • 33
  • 56
Loading