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 Determine if a polyomino is "prime"

Post

Determine if a polyomino is "prime"

+2
−0

An $n$-polyomino is a connected subset of the square tiling consisting of $n$ squares. We will not require that polyominos be simply connected, that is they can have holes.

We will say a $n$-polyomino is prime if it cannot be disected into disjoint $k$-polyominos for any 1<$k$<$n$. For example this square 4-polyomino:

XX
XX

can be dissected into two 2-polyominos, but this "T"-shaped 4-polyomino cannot:

XXX
 X

The $k$-polyominos do not need to be equal for example:

XXXXX
 X XX

This 8-polyomino can be subdivided into the two polyominos shown in the last examples. They are not equal but they are both 4-polyominos so the example is not prime.

Naturally if $n$ is a prime number all $n$-polyominos are prime, however as shown above there are prime $n$-polyominos where $n$ is not prime. Here are examples for the next couple composite numbers

6

 X
XXXX
 X

8

  X
XXXXX
 X X

9

XXXXXXXX
  X

10

XXXXXX
 X
 XXX

12

XXXXXXXXX
 X X
   X

14

XXXXXXXXXXXX
 X   X

15

XXX
X X X
XXXXXX
X X
  X

Challenge

Given a polyomino as input output one consistent value if it is prime and another consistent distinct value if it is not prime.

This is code-golf the goal being to minimize the size of your source code as measured in bytes.

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

3 comment threads

Holes and test cases (3 comments)
Can the polynominos be mirrored? (5 comments)
Can I take the number of Xs in the input as an extra input? (2 comments)
Can the polynominos be mirrored?
mousetail‭ wrote 11 months ago

Can the polynominos be mirrored?

WheatWizard‭ wrote 11 months ago

I'm not sure what you mean. There's no canonical way to select an enantiomorph, so yes it is possible for to mirror images to be inputs, if that's what you are asking. No part of this question involves determining if two polyominos are equal so it shouldn't matter whether you consider chiral pairs to be equal if that's what you are asking.

mousetail‭ wrote 11 months ago

The idea is that you find N polynominos so they can be rearanged into one larger shape right? But the question is how are you allowed to re-arange them. Would something like this:

XXXX
  XXXX

Be valid when subdivided into 2x

XX
 XX

What about

XX  XX
 XXXX

?

WheatWizard‭ wrote 11 months ago · edited 11 months ago

Ah I think you are misunderstanding, the you are dividing it into k-polyominos. There are no additional requirements on these polyominos. So

 X XX
XXXXX

can be subdivided into a T-tetramino and a O-tetramino. It doesn't matter that these are not the same 4-polyomino. You just need to be able to divide the 8-polyomino into 4-polyominos.

trichoplax‭ wrote 11 months ago

I think that this misunderstanding (that all the smaller polyominoes need to be the same shape) could make an interesting separate challenge. Either that they all need to be identical, or that they need to be identical up to rotation and/or reflection.