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

Comments on Label a hinged tetromino

Post

Label a hinged tetromino

+3
−0

Given a hinged tetromino, give it a unique, consistent label independent of location, rotation, and reflection.

Tetrominoes

A tetromino is a connected subset of the square tiling, composed of 4 squares, where connection can only be edge connection.

Here are the 5 tetrominoes:

the 5 tetrominoes

Hinged tetrominoes

A hinged tetromino is a connected subset of the square tiling, composed of 4 squares, where connection can be edge connection or corner connection.

Here are the 22 hinged tetrominoes:

the 22 hinged tetrominoes

Equivalence

The following 8 shapes are all considered to be the same hinged tetromino. They are equivalent because any one can be reached from any other by some combination of rotation, reflection, and translation:

8 equivalent hinged tetrominoes

All 8 of these rotated and reflected versions must have the same label. Translating, rotating, or reflecting a hinged tetromino must not change its label.

Input

  • A 4 by 4 grid containing a hinged tetromino.
  • Apart from the 4 squares of the hinged tetromino, all other squares are empty.
  • You may take input in any convenient format that does not include full or partial precalculation. For example:
    • A string or sequence of strings.
    • A 1 or 2 dimensional list/array/vector.
    • A sequence of coordinates (even a sequence of X coordinates and a separate sequence of Y coordinates if you wish).
    • A 16 bit variable where each 1 bit represents part of the hinged tetromino and each 0 bit represents part of the background.
    • A variable with more than 16 bits where only 16 of the bits are used would also be acceptable.

Output

  • A label for the hinged tetromino.
  • The label for each hinged tetromino can be anything you choose, including nothing (no output).
  • Each label must be unique (it must not be the label for any other hinged tetromino).
  • Each label must be consistent (a given hinged tetromino must always result in the same label, regardless of rotation, reflection, or translation).

Scoring

This is a code golf challenge. Your score is the number of bytes in your code.

Explanations are optional, but I'm more likely to upvote answers that have one.

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Question about inputs (8 comments)
Clarification on rotations, etc. (2 comments)
Question about inputs

Suppose we have a set of coordinates (like you said), would it be fine to group all the X coordinates to one set and the Y coordinates to another for the input? Does that count as partial precalculation? Just asking, not saying I'll use this 🙂

trichoplax‭ wrote 11 months ago

Interesting thought. I can't see any way that this would count as precalculation - the X and Y coordinates are ordered whether they are received as pairs or as separate sequences of X and Y.

I'll edit the question shortly to explicitly allow this.

trichoplax‭ wrote 11 months ago · edited 11 months ago

One pedantic point:
I've used the word "sequence" rather than "set", to avoid potential confusion with the mathematical meaning of "set", which includes being unordered (which would make the input impossible to interpret).

Alright, thanks for the clarification! Will give it a shot, though might not work haha.

trichoplax‭ wrote 11 months ago

You're welcome. Good luck!

Fun fact (after 6 days): I haven't given up yet, and will probably post an (unoptimized) answer soon. It's that some tetrominoes are almost indistinguishable, which is really really annoying. Cool challenge though 🙂

trichoplax‭ wrote 11 months ago

I almost chose the pentominoes...

Thank you for changing your mind, haha (I'd be impressed if anyone can do the pentominoes, though!)