Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Label a hinged tetromino

Dyalog APL, 89 bytes {1∊∘∊¨⍷¨∘⍵¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍤⍉e←{⍵/⍨×+⌿⍵})¨4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16} Requires IO to be zero. Thanks Adám for -8 bytes! Ungolfed version: { remove...

posted 10mo ago by RubenVerg‭  ·  edited 10mo ago by RubenVerg‭

Answer
#4: Post edited by user avatar RubenVerg‭ · 2023-07-17T13:27:48Z (10 months ago)
fix ungolfed
  • # Dyalog APL, 89 bytes
  • ```apl
  • {1∊∘∊¨⍷¨∘⍵¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍤⍉e←{⍵/⍨×+⌿⍵})¨4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16}
  • ```
  • Requires IO to be zero.
  • [Thanks Adám for -8 bytes!](https://chat.stackexchange.com/transcript/message/63992209#63992209)
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨×+⌿⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • all4x4Matrices←4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←1∊∘∊¨⍷¨∘⍵¨ ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats groupMatrices removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • This code can actually uniquely label all subsets of 4x4 grid that have 4 elements, no matter if they satisfy the condition of hinged tetrominos or not. While the code returns an unique sequence of 6110 boolean values for every "sparse tetromino", this table lists instead the indices (0-based) where the list has a `1` (and `0`s everywhere else).
  • ```
  • ┌────┬────────────────┐
  • │○○○○│0 1 2 3 4 │
  • ├────┼────────────────┤
  • │○○○ │0 1 2 3 6 8 │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○○│0 1 2 3 5 7 9 │
  • │○ │ │
  • ├────┼────────────────┤
  • │○○○ │0 1 2 3 6 12 │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○○│0 1 2 5 7 11 13 │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○○ │0 1 2 15 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 2 5 6 16 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 6 17 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 7 19 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○ ○│0 1 5 11 24 │
  • │○ ○ │ │
  • ├────┼────────────────┤
  • │○ ○│0 1 2 5 7 28 │
  • │ ○○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 7 41 │
  • │○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 5 11 46 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 6 7 47 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 7 45 49 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○○ │0 1 2 5 7 60 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 6 61 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ ○│0 1 5 11 59 63 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 7 11 67 │
  • │○ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○ │0 1 2 5 7 11 75 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 6 7 76 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 2 5 7 81 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 7 104 │
  • │ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 11 45 112 │
  • │ ○ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 7 59 128│
  • │ ○○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 59 173 │
  • │○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○│0 1 5 45 59 183 │
  • │ ○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 11 187 │
  • │○ ○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 5 59 213 │
  • │ ○│ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 217 │
  • │○ ○│ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 5 45 773 │
  • │ ○ │ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 801 │
  • │ ○│ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 5 59 1000 │
  • │ ○ │ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 1038 │
  • │ ○│ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 45 1537 │
  • │ ○ │ │
  • │ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 2765 │
  • │ ○│ │
  • │○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 3180 │
  • │○ │ │
  • │ ○│ │
  • │ ○ │ │
  • └────┴────────────────┘
  • ```
  • # Dyalog APL, 89 bytes
  • ```apl
  • {1∊∘∊¨⍷¨∘⍵¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍤⍉e←{⍵/⍨×+⌿⍵})¨4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16}
  • ```
  • Requires IO to be zero.
  • [Thanks Adám for -8 bytes!](https://chat.stackexchange.com/transcript/message/63992209#63992209)
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨×+⌿⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • all4x4Matrices←4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←1∊∘∊¨⍷¨∘⍵¨ ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats groupMatrices removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • This code can actually uniquely label all subsets of 4x4 grid that have 4 elements, no matter if they satisfy the condition of hinged tetrominos or not. While the code returns an unique sequence of 6110 boolean values for every "sparse tetromino", this table lists instead the indices (0-based) where the list has a `1` (and `0`s everywhere else).
  • ```
  • ┌────┬────────────────┐
  • │○○○○│0 1 2 3 4 │
  • ├────┼────────────────┤
  • │○○○ │0 1 2 3 6 8 │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○○│0 1 2 3 5 7 9 │
  • │○ │ │
  • ├────┼────────────────┤
  • │○○○ │0 1 2 3 6 12 │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○○│0 1 2 5 7 11 13 │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○○ │0 1 2 15 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 2 5 6 16 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 6 17 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 7 19 │
  • │○○ │ │
  • ├────┼────────────────┤
  • │ ○ ○│0 1 5 11 24 │
  • │○ ○ │ │
  • ├────┼────────────────┤
  • │○ ○│0 1 2 5 7 28 │
  • │ ○○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 7 41 │
  • │○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 5 11 46 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 6 7 47 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 7 45 49 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○○ │0 1 2 5 7 60 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 6 61 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ ○│0 1 5 11 59 63 │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 7 11 67 │
  • │○ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │○ │0 1 2 5 7 11 75 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 6 7 76 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 2 5 7 81 │
  • │ ○○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○ │0 1 2 5 7 104 │
  • │ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 11 45 112 │
  • │ ○ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 2 5 7 59 128│
  • │ ○○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○○│0 1 2 5 59 173 │
  • │○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○│0 1 5 45 59 183 │
  • │ ○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 11 187 │
  • │○ ○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │○ ○ │0 1 5 59 213 │
  • │ ○│ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 217 │
  • │○ ○│ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 5 45 773 │
  • │ ○ │ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 801 │
  • │ ○│ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○│0 1 5 59 1000 │
  • │ ○ │ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 59 1038 │
  • │ ○│ │
  • │ ○ │ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 45 1537 │
  • │ ○ │ │
  • │ ○│ │
  • │○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 5 2765 │
  • │ ○│ │
  • │○ │ │
  • │ ○ │ │
  • ├────┼────────────────┤
  • │ ○ │0 1 3180 │
  • │○ │ │
  • │ ○│ │
  • │ ○ │ │
  • └────┴────────────────┘
  • ```
#3: Post edited by user avatar RubenVerg‭ · 2023-07-17T13:26:48Z (10 months ago)
-8 bytes (thanks Adám)
  • # Dyalog APL, 97 bytes
  • ```apl
  • {(∨/∊⍤(⍵⍷¨⍨⊢))¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍉)¨(e←{⍵/⍨∨⌿0≠⍵})¨{4 4⍴⍵⊤⍨16/2}¨⍳2*16}
  • ```
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨∨⌿0≠⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • all4x4Matrices←{4 4⍴⍵⊤⍨16/2}¨⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←∨/∊⍤(⍵⍷¨⍨⊢) ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats¨groupMatrices removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • This code can actually uniquely label all subsets of 4x4 grid that have 4 elements, no matter if they satisfy the condition of hinged tetrominos or not. While the code returns an unique sequence of 6110 boolean values for every "sparse tetromino", this table lists instead the indices (1-based) where the list has a `1` (and `0`s everywhere else).
  • ```
  • ┌────┬───────────────────
  • ⎕⎕⎕⎕│1 2 3 4 6110
  • ├────┼───────────────────
  • ⎕⎕⎕ │1 2 3 6 8 6110
  • ├────┼───────────────────
  • ⎕⎕⎕│1 2 3 5 7 9 6110
  • ├────┼───────────────────
  • ⎕⎕⎕ │1 2 3 6 12 6110
  • ├────┼───────────────────
  • ⎕ ⎕⎕│1 2 5 7 11 13 6110
  • ├────┼───────────────────
  • ⎕⎕ │1 2 15 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕ ⎕ │1 2 5 6 16 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕⎕ │1 2 6 17 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕⎕│1 2 5 7 19 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕ ⎕│1 5 11 24 6110
  • ⎕ ⎕
  • ├────┼───────────────────
  • ⎕ ⎕│1 2 5 7 28 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕⎕ │1 2 5 7 41 6110
  • ├────┼───────────────────
  • ⎕ ⎕ │1 5 11 46 6110
  • ├────┼───────────────────
  • ⎕⎕ │1 2 5 6 7 47 6110
  • ├────┼───────────────────
  • ⎕⎕│1 2 5 7 45 49 6110
  • ├────┼───────────────────
  • ⎕⎕ │1 2 5 7 60 6110
  • ├────┼───────────────────
  • ⎕⎕ │1 2 6 61 6110
  • ├────┼───────────────────
  • ⎕ ⎕│1 5 11 59 63 6110
  • ├────┼───────────────────
  • ⎕ │1 2 5 7 11 67 6110
  • ⎕ ⎕
  • ├────┼───────────────────
  • │1 2 5 7 11 75 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕ │1 2 5 6 7 76 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕│1 2 5 7 81 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕⎕ │1 2 5 7 104 6110
  • ├────┼───────────────────
  • ⎕ │1 5 11 45 112 6110
  • ⎕ ⎕
  • ├────┼───────────────────
  • ⎕ │1 2 5 7 59 128 6110
  • ⎕⎕
  • ├────┼───────────────────
  • ⎕⎕│1 2 5 59 173 6110
  • ├────┼───────────────────
  • ⎕ ⎕│1 5 45 59 183 6110
  • ├────┼───────────────────
  • ⎕ │1 5 11 187 6110
  • ⎕ ⎕
  • ├────┼───────────────────
  • ⎕ ⎕ │1 5 59 213 6110
  • ├────┼───────────────────
  • ⎕ │1 5 59 217 6110
  • ⎕ ⎕
  • ├────┼───────────────────
  • ⎕│1 5 45 773 6110
  • ├────┼───────────────────
  • ⎕ │1 5 59 801 6110
  • ├────┼───────────────────
  • ⎕│1 5 59 1000 6110
  • ├────┼───────────────────
  • ⎕ │1 5 59 1038 6110
  • ├────┼───────────────────
  • ⎕ │1 5 45 1537 6110
  • ├────┼───────────────────
  • ⎕ │1 5 2765 6110
  • ├────┼───────────────────
  • ⎕ │1 3180 6110
  • └────┴───────────────────
  • ```
  • # Dyalog APL, 89 bytes
  • ```apl
  • {1∊∘∊¨⍷¨∘⍵¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍤⍉e←{⍵/⍨×+⌿⍵})¨4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16}
  • ```
  • Requires IO to be zero.
  • [Thanks Adám for -8 bytes!](https://chat.stackexchange.com/transcript/message/63992209#63992209)
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨×+⌿⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • all4x4Matrices←4 4∘⍴¨,⌿2⊥⍣¯1⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←1∊∘∊¨⍷¨∘⍵¨ ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats groupMatrices removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • This code can actually uniquely label all subsets of 4x4 grid that have 4 elements, no matter if they satisfy the condition of hinged tetrominos or not. While the code returns an unique sequence of 6110 boolean values for every "sparse tetromino", this table lists instead the indices (0-based) where the list has a `1` (and `0`s everywhere else).
  • ```
  • ┌────┬────────────────┐
  • ○○○○│0 1 2 3 4 │
  • ├────┼────────────────┤
  • ○○○ │0 1 2 3 6 8 │
  • │ │
  • ├────┼────────────────┤
  • ○○○│0 1 2 3 5 7 9 │
  • │ │
  • ├────┼────────────────┤
  • ○○○ │0 1 2 3 6 12 │
  • │ │
  • ├────┼────────────────┤
  • ○ ○○│0 1 2 5 7 11 13 │
  • │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 15 │
  • ○○ │ │
  • ├────┼────────────────┤
  • ○ ○ │0 1 2 5 6 16 │
  • ○○ │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 6 17 │
  • ○○ │ │
  • ├────┼────────────────┤
  • ○○│0 1 2 5 7 19 │
  • ○○ │ │
  • ├────┼────────────────┤
  • ○ ○│0 1 5 11 24 │
  • ○ ○ │ │
  • ├────┼────────────────┤
  • ○ ○│0 1 2 5 7 28 │
  • ○○ │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 5 7 41 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ ○ │0 1 5 11 46 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 5 6 7 47 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○○│0 1 2 5 7 45 49 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 5 7 60 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 6 61 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ ○│0 1 5 11 59 63 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 2 5 7 11 67 │
  • ○ ○ │ │
  • │ │
  • ├────┼────────────────┤
  • 0 1 2 5 7 11 75 │
  • ○○ │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 2 5 6 7 76 │
  • ○○ │ │
  • │ │
  • ├────┼────────────────┤
  • ○│0 1 2 5 7 81 │
  • ○○ │ │
  • │ │
  • ├────┼────────────────┤
  • ○○ │0 1 2 5 7 104 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 11 45 112 │
  • ○ ○│ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 2 5 7 59 128│
  • ○○│ │
  • │ │
  • ├────┼────────────────┤
  • ○○│0 1 2 5 59 173 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ ○│0 1 5 45 59 183 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 11 187 │
  • ○ ○ │ │
  • │ │
  • ├────┼────────────────┤
  • ○ ○ │0 1 5 59 213 │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 59 217 │
  • ○ ○│ │
  • │ │
  • ├────┼────────────────┤
  • ○│0 1 5 45 773 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 59 801 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○│0 1 5 59 1000 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 59 1038 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 45 1537 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 5 2765 │
  • │ │
  • │ │
  • │ │
  • ├────┼────────────────┤
  • ○ │0 1 3180 │
  • │ │
  • │ │
  • │ │
  • └────┴────────────────┘
  • ```
#2: Post edited by user avatar RubenVerg‭ · 2023-07-16T10:15:34Z (10 months ago)
  • # Dyalog APL, 112 bytes
  • ```apl
  • {(∨/∊⍤(⍵⍷¨⍨⊢))¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}{⍵/⍨(4=+/⍤,)¨⍵}(e⍉)¨(e←{⍵/⍨∨⌿0≠⍵})¨{4 4⍴⍵⊤⍨16/2}¨⍳2*16}
  • ```
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨∨⌿0≠⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • filterTetrominoes←{⍵/⍨(4=+/⍤,)¨⍵} ⍝ Filter for matrices that contain 4 ones
  • all4x4Matrices←{4 4⍴⍵⊤⍨16/2}¨⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←∨/∊⍤(⍵⍷¨⍨⊢) ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats¨groupMatrices¨filterTetrominoes¨removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • As soon as I have time I'll add a list of what each tetromino maps to.
  • # Dyalog APL, 97 bytes
  • ```apl
  • {(∨/∊⍤(⍵⍷¨⍨⊢))¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}(e⍉)¨(e←{⍵/⍨∨⌿0≠⍵})¨{4 4⍴⍵⊤⍨16/2}¨⍳2*16}
  • ```
  • Ungolfed version:
  • ```apl
  • {
  • removeEmptyRows←{⍵/⍨∨⌿0≠⍵}
  • removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  • dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
  • ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
  • ⍝ which is equivalent to the classic four rotations and a reflection construction
  • all4x4Matrices←{4 4⍴⍵⊤⍨16/2}¨⍳2*16 ⍝ For every number from 1 to 2*16,
  • ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  • groupMatrices←⍬∘{ ⍝ Takes 4x4 matrices and builds groups out of their D4's
  • 0∊⍴⍵:⍺ ⍝ If there are no matrices to process, we are done, return the accumulator left argument
  • mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
  • (⍺,⊂mats)∇⍵~mats ⍝ Recursively call groupMatrices, storing mats in the accumulator and
  • ⍝ removing all elements of mats from the list
  • }
  • hasSubmats←∨/∊⍤(⍵⍷¨⍨⊢) ⍝ 1 if any of the argument's matrices appears in the input to the function
  • hasSubmats¨groupMatrices removeEmptyCols¨removeEmptyRows¨all4x4Matrices
  • }
  • ```
  • This code can actually uniquely label all subsets of 4x4 grid that have 4 elements, no matter if they satisfy the condition of hinged tetrominos or not. While the code returns an unique sequence of 6110 boolean values for every "sparse tetromino", this table lists instead the indices (1-based) where the list has a `1` (and `0`s everywhere else).
  • ```
  • ┌────┬───────────────────┐
  • │⎕⎕⎕⎕│1 2 3 4 6110 │
  • ├────┼───────────────────┤
  • │⎕⎕⎕ │1 2 3 6 8 6110 │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕⎕│1 2 3 5 7 9 6110 │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │⎕⎕⎕ │1 2 3 6 12 6110 │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕⎕│1 2 5 7 11 13 6110 │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │⎕⎕ │1 2 15 6110 │
  • │⎕⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕ │1 2 5 6 16 6110 │
  • │⎕⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕ │1 2 6 17 6110 │
  • │⎕⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕│1 2 5 7 19 6110 │
  • │⎕⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ ⎕│1 5 11 24 6110 │
  • │⎕ ⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕│1 2 5 7 28 6110 │
  • │ ⎕⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕ │1 2 5 7 41 6110 │
  • │⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕ │1 5 11 46 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕ │1 2 5 6 7 47 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕│1 2 5 7 45 49 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │⎕⎕ │1 2 5 7 60 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕ │1 2 6 61 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ ⎕│1 5 11 59 63 6110 │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 2 5 7 11 67 6110 │
  • │⎕ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ │1 2 5 7 11 75 6110 │
  • │ ⎕⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 2 5 6 7 76 6110 │
  • │ ⎕⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕│1 2 5 7 81 6110 │
  • │ ⎕⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕ │1 2 5 7 104 6110 │
  • │ ⎕│ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 11 45 112 6110 │
  • │ ⎕ ⎕│ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 2 5 7 59 128 6110│
  • │ ⎕⎕│ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕⎕│1 2 5 59 173 6110 │
  • │⎕ │ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕│1 5 45 59 183 6110 │
  • │ ⎕ │ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 11 187 6110 │
  • │⎕ ⎕ │ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │⎕ ⎕ │1 5 59 213 6110 │
  • │ ⎕│ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 59 217 6110 │
  • │⎕ ⎕│ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕│1 5 45 773 6110 │
  • │ ⎕ │ │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 59 801 6110 │
  • │ ⎕│ │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕│1 5 59 1000 6110 │
  • │ ⎕ │ │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 59 1038 6110 │
  • │ ⎕│ │
  • │ ⎕ │ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 45 1537 6110 │
  • │ ⎕ │ │
  • │ ⎕│ │
  • │⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 5 2765 6110 │
  • │ ⎕│ │
  • │⎕ │ │
  • │ ⎕ │ │
  • ├────┼───────────────────┤
  • │ ⎕ │1 3180 6110 │
  • │⎕ │ │
  • │ ⎕│ │
  • │ ⎕ │ │
  • └────┴───────────────────┘
  • ```
#1: Initial revision by user avatar RubenVerg‭ · 2023-07-16T08:03:43Z (10 months ago)
# Dyalog APL, 112 bytes

```apl
{(∨/∊⍤(⍵⍷¨⍨⊢))¨⍬{0∊⍴⍵:⍺⋄(⍺,⊂A)∇⍵~A←(⌽¨,⊢)(⊖¨,⊢)(⍉¨,⊢)⊣/⍵}{⍵/⍨(4=+/⍤,)¨⍵}(e⍉)¨(e←{⍵/⍨∨⌿0≠⍵})¨{4 4⍴⍵⊤⍨16/2}¨⍳2*16}
```

Ungolfed version:

```apl
{
  removeEmptyRows←{⍵/⍨∨⌿0≠⍵}
  removeEmptyCols←removeEmptyRows⍉ ⍝ Transpose, then remove the empty rows
  dihedral4←(⌽¨,⊢)⍤(⊖¨,⊢)⍤(⍉¨,⊢)⍤⊂ ⍝ All rotations + reflections of a matrix:
                                   ⍝ this maps A to the matrices A, ⌽A, ⊖A, ⌽⊖A, ⍉A, ⍉⌽A, ⍉⊖A, ⍉⌽⊖A
                                   ⍝ which is equivalent to the classic four rotations and a reflection construction
  filterTetrominoes←{⍵/⍨(4=+/⍤,)¨⍵} ⍝ Filter for matrices that contain 4 ones
  all4x4Matrices←{4 4⍴⍵⊤⍨16/2}¨⍳2*16 ⍝ For every number from 1 to 2*16,
                                     ⍝ take the first 16 bits and reshape them into a 4x4 matrix
  groupMatrices←⍬∘{   ⍝ Takes 4x4 matrices and builds groups out of their D4's
    0∊⍴⍵:⍺            ⍝ If there are no matrices to process, we are done, return the accumulator left argument
    mats←dihedral4 ⊃⍵ ⍝ D4 the first matrix in the list
    (⍺,⊂mats)∇⍵~mats  ⍝ Recursively call groupMatrices, storing mats in the accumulator and
                      ⍝ removing all elements of mats from the list
  }
  hasSubmats←∨/∊⍤(⍵⍷¨⍨⊢) ⍝ 1 if any of the argument's matrices appears in the input to the function 
  hasSubmats¨groupMatrices¨filterTetrominoes¨removeEmptyCols¨removeEmptyRows¨all4x4Matrices
}
```

As soon as I have time I'll add a list of what each tetromino maps to.