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

Net​​ or​​ not?

+1
−0

Given a hexomino, indicate whether it is a net of a cube.

Input

  • A 6 by 6 grid containing exactly 6 filled squares.
  • The 6 filled squares will be in a single edge connected set (a hexomino).
  • The topmost row and leftmost column will never be empty (the hexomino will be as far up and left as it can go).
  • The grid is represented as 6 newline separated strings of 6 characters, with # for a filled square and . for an empty square.

Output

  • One of 2 distinct values to indicate whether the hexomino can be folded to give a cube.

The hexominoes

A hexomino is an edge connected subset of the square tiling, composed of exactly 6 squares.

Up to rotation and reflection, there are 35 edge connected hexominoes, 11 of which are nets of a cube.

The 35 hexominoes[1]

The 35 hexominoes

The 11 nets of a cube[2]

The 11 nets of a cube

Your code must also accept inputs that are rotations and reflections of these. There are a total of 216 hexominoes including all rotations by a multiple of 90 degrees and reflections, 64 of which are cube nets. The test cases include all of these.

Test cases

Cube nets

The 64 hexominoes that can be folded into a cube.

#.....
####..
#.....
......
......
......

.#....
.#....
.#....
###...
......
......

...#..
####..
...#..
......
......
......

###...
.#....
.#....
.#....
......
......

.##...
.#....
.#....
##....
......
......

...#..
####..
#.....
......
......
......

##....
.#....
.#....
.##...
......
......

#.....
####..
...#..
......
......
......

##....
.###..
.#....
......
......
......

#.....
###...
.#....
.#....
......
......

..#...
###...
.#....
.#....
......
......

.#....
.###..
##....
......
......
......

.#....
.#....
###...
#.....
......
......

..##..
###...
..#...
......
......
......

.#....
.#....
###...
..#...
......
......

..#...
###...
..##..
......
......
......

##....
.##...
..##..
......
......
......

#.....
##....
.##...
..#...
......
......

..##..
.##...
##....
......
......
......

..#...
.##...
##....
#.....
......
......

###...
..###.
......
......
......
......

..###.
###...
......
......
......
......

#.....
#.....
##....
.#....
.#....
......

.#....
.#....
##....
#.....
#.....
......

.#....
###...
.#....
.#....
......
......

.#....
.#....
###...
.#....
......
......

..#...
####..
..#...
......
......
......

.#....
####..
.#....
......
......
......

.#....
###...
..##..
......
......
......

..#...
.##...
##....
.#....
......
......

##....
.###..
..#...
......
......
......

.#....
.##...
##....
#.....
......
......

#.....
##....
.##...
.#....
......
......

..##..
###...
.#....
......
......
......

..#...
.###..
##....
......
......
......

.#....
##....
.##...
..#...
......
......

#.....
##....
.#....
.##...
......
......

..##..
###...
#.....
......
......
......

##....
.#....
.##...
..#...
......
......

.##...
.#....
##....
#.....
......
......

##....
.###..
...#..
......
......
......

#.....
###...
..##..
......
......
......

..#...
.##...
.#....
##....
......
......

...#..
.###..
##....
......
......
......

...#..
####..
..#...
......
......
......

.##...
##....
.#....
.#....
......
......

##....
.##...
.#....
.#....
......
......

.#....
####..
#.....
......
......
......

#.....
####..
.#....
......
......
......

.#....
.#....
##....
.##...
......
......

.#....
.#....
.##...
##....
......
......

..#...
####..
...#..
......
......
......

.#....
.##...
##....
.#....
......
......

.#....
####..
..#...
......
......
......

..#...
####..
.#....
......
......
......

.#....
##....
.##...
.#....
......
......

.#....
.##...
.#....
##....
......
......

.#....
##....
.#....
.##...
......
......

.##...
.#....
##....
.#....
......
......

##....
.#....
.##...
.#....
......
......

#.....
####..
..#...
......
......
......

..#...
####..
#.....
......
......
......

...#..
####..
.#....
......
......
......

.#....
####..
...#..
......
......
......

Not cube nets

The 152 hexominoes that cannot be folded into a cube.

..#...
#####.
......
......
......
......

#####.
..#...
......
......
......
......

.#....
.#....
##....
.#....
.#....
......

#.....
#.....
##....
#.....
#.....
......

.##...
###...
.#....
......
......
......

##....
###...
.#....
......
......
......

.#....
###...
##....
......
......
......

.#....
###...
.##...
......
......
......

##....
.####.
......
......
......
......

####..
...##.
......
......
......
......

#.....
##....
.#....
.#....
.#....
......

...##.
####..
......
......
......
......

.#....
.#....
.#....
##....
#.....
......

#.....
#.....
#.....
##....
.#....
......

.#....
##....
#.....
#.....
#.....
......

.####.
##....
......
......
......
......

.#....
##....
###...
......
......
......

#.....
###...
##....
......
......
......

###...
##....
.#....
......
......
......

##....
###...
#.....
......
......
......

###...
.##...
.#....
......
......
......

.##...
###...
..#...
......
......
......

..#...
###...
.##...
......
......
......

.#....
.##...
###...
......
......
......

###...
..#...
..##..
......
......
......

..#...
..#...
###...
#.....
......
......

..#...
###...
#.....
#.....
......
......

#.....
###...
..#...
..#...
......
......

.###..
.#....
##....
......
......
......

#.....
#.....
###...
..#...
......
......

..##..
..#...
###...
......
......
......

##....
.#....
.###..
......
......
......

####..
##....
......
......
......
......

.#....
.#....
##....
##....
......
......

..##..
####..
......
......
......
......

#.....
#.....
##....
##....
......
......

##....
##....
.#....
.#....
......
......

##....
####..
......
......
......
......

##....
##....
#.....
#.....
......
......

####..
..##..
......
......
......
......

####..
.#....
.#....
......
......
......

..#...
..#...
####..
......
......
......

..#...
..#...
###...
..#...
......
......

#.....
#.....
###...
#.....
......
......

#.....
###...
#.....
#.....
......
......

####..
..#...
..#...
......
......
......

.#....
.#....
####..
......
......
......

..#...
###...
..#...
..#...
......
......

####..
#.#...
......
......
......
......

.#....
##....
.#....
##....
......
......

#.#...
####..
......
......
......
......

#.....
##....
#.....
##....
......
......

##....
.#....
##....
.#....
......
......

.#.#..
####..
......
......
......
......

####..
.#.#..
......
......
......
......

##....
#.....
##....
#.....
......
......

...#..
...#..
####..
......
......
......

####..
...#..
...#..
......
......
......

..#...
..#...
..#...
###...
......
......

###...
..#...
..#...
..#...
......
......

###...
#.....
#.....
#.....
......
......

#.....
#.....
#.....
###...
......
......

#.....
#.....
####..
......
......
......

####..
#.....
#.....
......
......
......

.##...
##....
.##...
......
......
......

#.#...
###...
.#....
......
......
......

##....
.##...
##....
......
......
......

.#....
###...
#.#...
......
......
......

##....
##....
.##...
......
......
......

#.....
###...
.##...
......
......
......

..#...
###...
##....
......
......
......

.##...
###...
#.....
......
......
......

.##...
##....
##....
......
......
......

##....
.##...
.##...
......
......
......

##....
###...
..#...
......
......
......

.##...
.##...
##....
......
......
......

#.....
##....
###...
......
......
......

..#...
.##...
###...
......
......
......

###...
.##...
..#...
......
......
......

###...
##....
#.....
......
......
......

######
......
......
......
......
......

#.....
#.....
#.....
#.....
#.....
#.....

.###..
##....
.#....
......
......
......

.#....
###...
#.....
#.....
......
......

.#....
###...
..#...
..#...
......
......

..#...
..#...
###...
.#....
......
......

###...
..##..
..#...
......
......
......

.#....
##....
.###..
......
......
......

..#...
..##..
###...
......
......
......

#.....
#.....
###...
.#....
......
......

#.#...
###...
#.....
......
......
......

#.#...
###...
..#...
......
......
......

#.....
###...
#.#...
......
......
......

##....
.#....
###...
......
......
......

..#...
###...
#.#...
......
......
......

###...
.#....
##....
......
......
......

.##...
.#....
###...
......
......
......

###...
.#....
.##...
......
......
......

###...
###...
......
......
......
......

##....
##....
##....
......
......
......

#####.
....#.
......
......
......
......

....#.
#####.
......
......
......
......

#####.
#.....
......
......
......
......

##....
#.....
#.....
#.....
#.....
......

.#....
.#....
.#....
.#....
##....
......

#.....
#.....
#.....
#.....
##....
......

##....
.#....
.#....
.#....
.#....
......

#.....
#####.
......
......
......
......

#.....
#.#...
###...
......
......
......

###...
#.....
##....
......
......
......

###...
#.#...
#.....
......
......
......

###...
..#...
.##...
......
......
......

##....
#.....
###...
......
......
......

###...
#.#...
..#...
......
......
......

..#...
#.#...
###...
......
......
......

.##...
..#...
###...
......
......
......

###...
.###..
......
......
......
......

.#....
##....
##....
#.....
......
......

#.....
##....
##....
.#....
......
......

.###..
###...
......
......
......
......

##....
.##...
..#...
..#...
......
......

###...
..##..
...#..
......
......
......

..#...
..#...
.##...
##....
......
......

.##...
##....
#.....
#.....
......
......

.###..
##....
#.....
......
......
......

#.....
##....
.###..
......
......
......

#.....
#.....
##....
.##...
......
......

...#..
..##..
###...
......
......
......

.##...
####..
......
......
......
......

#.....
##....
##....
#.....
......
......

.#....
##....
##....
.#....
......
......

####..
.##...
......
......
......
......

##....
.#....
##....
#.....
......
......

##....
#.....
##....
.#....
......
......

##.#..
.###..
......
......
......
......

.###..
##.#..
......
......
......
......

#.##..
###...
......
......
......
......

.#....
##....
#.....
##....
......
......

###...
#.##..
......
......
......
......

#.....
##....
.#....
##....
......
......

.#....
##....
.#....
.#....
.#....
......

...#..
#####.
......
......
......
......

#.....
#.....
#.....
##....
#.....
......

.#....
#####.
......
......
......
......

.#....
.#....
.#....
##....
.#....
......

#####.
...#..
......
......
......
......

#.....
##....
#.....
#.....
#.....
......

#####.
.#....
......
......
......
......

#..#..
####..
......
......
......
......

##....
.#....
.#....
##....
......
......

####..
#..#..
......
......
......
......

##....
#.....
#.....
##....
......
......

Scoring

This is a code golf challenge. Your score is the number of bytes in your code. Lowest score for each language wins.

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


  1. Thanks to The 35 hexominoes Wikimedia page. ↩︎

  2. Thanks to The 11 nets of a cube Wikimedia page. ↩︎

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

0 comment threads

1 answer

+1
−0

Python 3, 463 bytes

lambda s:hex(sum(2**i*(c=='#')for i,c in enumerate(s)))[2:]in"1020c102 1038c 10703 10781 10782 10784 10788 2040c081 20703 20781 20782 20784 20788 20c106 20c302 20c304 21c102 30303 30381 30382 30384 39c 408107 408186 408303 408381 408382 408384 40c106 40c302 40c304 418103 418181 418182 41c102 438c 4781 4782 4784 4788 608106 608302 608304 618102 818103 818181 818182 81c102 838c 8703 8781 8782 8784 8788 c08103 c08181 c08182 c0c102 c30c c702 c704 c708 e07 e08102"

Try it online!

Yet another interesting challenge foiled to brute force... (at least until someone comes up with a way to decision-problem this more efficiently...)

Anonymous lambda function which takes string as input. Takes a power of 2 from the character indexes, indicating #s with 1s and .s/newlines with 0s. Sums up and manually checks a lookup table for all valid cube nets. Returns True for cube nets and False otherwise.

(i.e. if # means include and ./\n mean exclude, 1st character has value 1, 2nd charcter has value 2, 3rd character has value 4, then values 8, 16, 32, and so on with all powers of 2 up to 240 inclusive)

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

2 comment threads

Base 36 (4 comments)
Omitting the spaces (2 comments)

Sign up to answer this question »