Skip to main content
deleted 2 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrixlist into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rowsrow as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s (the gaps) Ë # Check if all remaining values are the same, so we have a single island 
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rows as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s (the gaps) Ë # Check if all remaining values are the same, so we have a single island 
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the list into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle row as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s (the gaps) Ë # Check if all remaining values are the same, so we have a single island 
deleted 284 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

05AB1E, 7171 69 bytes

ø«ε0¡ε€Sø€ËàyD¢P*]˜þPI˜áD¢4‹PIa©˜ƶIgäΔ2Fø0δø«ε0¡ε€Sø€ËàyD¢*]˜PI˜áD¢4‹PIa©˜ƶIgäΔ2Fø0δ.ø}2Fø€ü3}®*εεÅsyøÅs«à]˜0KËP 

Try it onlineTry it online or verify all test casesverify all test cases.

ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get maxthe maximum, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each portionpiece occurs * P # TakeMultiply the product of these counts * earlier check #to each count Multiplyin the two checks togetherlist ] # Close the nested maps ˜ # Flatten the list of list of list of checks þ # Remove all empty strings by only keeping numbers # (occurs for leading/trailing gaps or two adjacent gaps in a row/column)   P  # Check if everything was truthy by taking the product 

Try just this first step onlineTry just this first step online or verify it for all test casesverify it for all test cases.

I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås #  Pop and push its middle row y #  Push the 3x3 block again ø #  Zip/transpose; swapping rows/columns Ås #  Pop and push its middle rows as well (the middle column) « #  Merge the middle row and column together to a single list à #  Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s (the gaps) Ë # Check if all remaining values are the same, so we have a single island 

Step 4: Combine all three checks of the previous stepsteps, and output the result:

05AB1E, 71 bytes

ø«ε0¡ε€Sø€ËàyD¢P*]˜þPI˜áD¢4‹PIa©˜ƶIgäΔ2Fø0δ.ø}2Fø€ü3}®*εεÅsyøÅs«à]˜0KËP 

Try it online or verify all test cases.

ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get max, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each portion occurs P # Take the product of these counts *  # Multiply the two checks together ] # Close the nested maps ˜ # Flatten the list of list of list of checks þ # Remove all empty strings by only keeping numbers # (occurs for leading/trailing gaps or two adjacent gaps in a row/column)   P # Check if everything was truthy by taking the product 

Try just this first step online or verify it for all test cases.

I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rows as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s Ë # Check if all remaining values are the same, so we have a single island 

Step 4: Combine all three checks of the previous step, and output the result:

05AB1E, 71 69 bytes

ø«ε0¡ε€Sø€ËàyD¢*]˜PI˜áD¢4‹PIa©˜ƶIgäΔ2Fø0δ.ø}2Fø€ü3}®*εεÅsyøÅs«à]˜0KËP 

Try it online or verify all test cases.

ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get the maximum, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each piece occurs * # Multiply the earlier check to each count in the list ] # Close the nested maps ˜ # Flatten the list of list of list of checks P  # Check if everything was truthy by taking the product 

Try just this first step online or verify it for all test cases.

I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each # 3x3 block: εε # Nested map over each 3x3 block: Ås #  Pop and push its middle row y #  Push the 3x3 block again ø #  Zip/transpose; swapping rows/columns Ås #  Pop and push its middle rows as well (the middle column) « #  Merge the middle row and column together to a single list à #  Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s (the gaps) Ë # Check if all remaining values are the same, so we have a single island 

Step 4: Combine all three checks of the previous steps, and output the result:

added 4 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get max, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each portion occurs P # Take the product of these counts * # Multiply the two checks together ] # Close the nested maps ˜ # Flatten the list of list of list of checks þ # Remove all empty strings by only keeping numbers # (occurs for leading/trailing gaps or two adjacent gaps in a row/column) P # And checkCheck if everything was truthy by taking the product 
I # Push the input-matrix again ˜ # Flatten it á # Remove all gaps by only keeping the letters D # Duplicate it ¢ # Pop both, and count how many times each piece occurs 4‹ # Check for each that it's smaller than 4 P # And checkCheck if everything was truthy by taking the product 
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply each inner 3x3 block by thethis valuematrix atof that3x3 positionblocks ofand matrix `®` together, # so all 3x3 blocks at the 0-positions will become 0a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each  # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rows as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum   ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s Ë # And checkCheck if all remaining values are the same, so we have a single island 
ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get max, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each portion occurs P # Take the product of these counts * # Multiply the two checks together ] # Close the nested maps ˜ # Flatten the list of list of list of checks þ # Remove all empty strings by only keeping numbers # (occurs for leading/trailing gaps or two adjacent gaps in a row/column) P # And check if everything was truthy by taking the product 
I # Push the input-matrix again ˜ # Flatten it á # Remove all gaps by only keeping the letters D # Duplicate it ¢ # Pop both, and count how many times each piece occurs 4‹ # Check for each that it's smaller than 4 P # And check if everything was truthy by taking the product 
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply each inner 3x3 block by the value at that position of matrix `®`, # so all 3x3 blocks at the 0-positions will become 0 εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rows as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum   ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s Ë # And check if all remaining values are the same, so we have a single island 
ø # Zip/transpose; swapping rows/columns of the (implicit) input-matrix « # Merge this list of columns to the (implicit) input-list of rows ε # Map over each inner row/column: 0¡ # Split it on 0s (the gaps) ε # Map over each connected portion: €S # Split each 2-char string to a pair of characters ø # Zip/transpose; swapping rows/columns €Ë # Check for each inner list whether they're all the same à # Pop and get max, to check if this is truthy for either y # Push the current connected portion again D # Duplicate it ¢ # Pop both, and count how many times each portion occurs P # Take the product of these counts * # Multiply the two checks together ] # Close the nested maps ˜ # Flatten the list of list of list of checks þ # Remove all empty strings by only keeping numbers # (occurs for leading/trailing gaps or two adjacent gaps in a row/column) P # Check if everything was truthy by taking the product 
I # Push the input-matrix again ˜ # Flatten it á # Remove all gaps by only keeping the letters D # Duplicate it ¢ # Pop both, and count how many times each piece occurs 4‹ # Check for each that it's smaller than 4 P # Check if everything was truthy by taking the product 
I # Push the input-matrix yet again a # Convert all pieces to 1s with the is_alphabetic builtin © # Store this matrix of 1s/0s in variable `®` (without popping) ˜ # Flatten it ƶ # Multiply each value by its 1-based index Igä # Mold it back to a matrix matching the input: I # Push the input g # Pop and push the length (the amount of rows) ä # Split the matrix into that many equal-sized parts Δ # Loop until the result no longer changes: 2Fø0δ.ø} # Add a border of 0s around the matrix: 2F } # Loop 2 times: ø # Zip/transpose; swapping rows/columns δ # Map over each inner list: 0 .ø # Surround it with both a leading and trailing 0 2Fø€ü3} # Then split it into overlapping 3x3 blocks: 2F # Loop 2 times again: ø # Zip/transpose; swapping rows/columns again € # Map over each inner list again: ü3 # Split this list into overlapping triplets ®* # Multiply this matrix of 3x3 blocks and matrix `®` together, # so all 3x3 blocks at the 0-positions will become a block of 0s εεÅsyøÅs«à # Get the largest value from the horizontal/vertical cross of each  # 3x3 block: εε # Nested map over each 3x3 block: Ås # Pop and push its middle row y # Push the 3x3 block again ø # Zip/transpose; swapping rows/columns Ås # Pop and push its middle rows as well (the middle column) « # Merge the middle row and column together to a single list à # Pop and push its maximum ] # Close the nested maps and flood-fill loop ˜ # Flatten the resulting flood-filled matrix 0K # Remove all 0s Ë # Check if all remaining values are the same, so we have a single island 
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading