13
1
An interesting puzzle came to me looking at the elevator buttons this morning.
You are required to generate a list of all Braille patterns that fit in a 2x3 grid. Use a hash #
to denote a bump and a hyphen -
to denote a flat area.
Expected output sample:
#-
--
--
##
--
--
#-
#-
--
(and so on...)
Rules:
- Your program must separate each pattern by at least one character or line.
- The patterns may be generated in any order.
- All patterns, regardless of what the Braille alphabet actually uses, should be produced. The completely blank pattern is optional.
- Only unique bump patterns should be generated. The following patterns are considered equivilent as the bumps are in an identical arangement. In these cases, use the pattern that is closest to the top-left corner (ie. the first option in this example.)
#- -# -- --
#- -# #- -#
-- -- #- -#
Bonus points if you can make it work for any x by y sized grid. (EDIT: Within reasonable bounds. Up to 4x4 is enough for proof of concept.)
Reading the wiki article, it appears there are 45 patterns (including the blank) that meet this puzzle's rules.
It's not quite counting, but it's very close. For
x
xy
grids you generate the first2^(xy)
numbers and filter out those which mask to 0 against2^x - 1
or(2^(xy+1) - 1)/(2^y - 1)
. – Peter Taylor – 2012-09-26T08:11:59.913