29
8
This question is inspired by the cover of the book "Godel, Escher, Bach":
The challenge here is to write a function that tells if three given letters can produce a 3D sculpture that can be read from three sides.
For this exercise, the only letters you can use are 26 5px * 5px bitmaps:
Or in binary (A to Z):
01110 11110 01111 11110 11111 11111 11111 10001 11111 11111 10001 10000 10001 10001 01110 11110 01110 11110 01111 11111 10001 10001 10001 10001 10001 11111
10001 10001 10000 10001 10000 10000 10000 10001 00100 00100 10010 10000 11011 11001 10001 10001 10001 10001 10000 00100 10001 10001 10001 01010 01010 00010
10001 11110 10000 10001 11100 11110 10011 11111 00100 00100 11100 10000 10101 10101 10001 10001 10001 11111 01110 00100 10001 01010 10001 00100 00100 00100
11111 10001 10000 10001 10000 10000 10001 10001 00100 10100 10010 10000 10001 10011 10001 11110 10011 10010 00001 00100 10001 01010 10101 01010 00100 01000
10001 11110 01111 11110 11111 10000 11111 10001 11111 11100 10001 11111 10001 10001 01110 10000 01111 10001 11110 00100 01110 00100 01010 10001 00100 11111
The sculpture is formed by three letters in the following order:
- letter one on top,
- letter two on the left
- letter three on the right
- the bottom of letter one is bound to the top of the letter two.
Example:
Your function may accept as input three uppercase letters (three chars or three strings of one letter), and output a boolean (true/false or 0/1) telling if the corresponding sculpture can exist.
Example:
f("B","E","G") // true (because if you "sculpt out" B on top + E on the left + G on the right, and watch the three sides of the sculpture, you'll see exactly B, E and G as they are defined)
f("B","G","E") // false (because if you "sculpt out" B on top + G on the left + E on the right, and watch the three sides of the sculpture, you won't see a complete G and a complete E. Their shapes bother each other)
NB: you may return true even if the sculpture contains "flying pixels" (cubes or group of cubes that are attached to nothing).
Standard loopholes apply.
More precisely, you can't use external input besides the three letters, and you can't hardcode the 17576 possible answers in your source code
Shortest answer in characters in any language wins!
Have fun :)
11You guys gotta be kidding me. – Martin Ender – 2014-07-14T20:21:43.650
Yep, it's the MU puzzle that made me discover the book, and it's the cover of the book that made me think of this challenge. Is there a problem? Was this a part of your 18 holes thing? – xem – 2014-07-14T20:30:46.970
2It would have been a good option to replace hole 1. ;) ... Never mind, if anything it's my fault for not getting something up sooner. It's a really decent challenge, +1! – Martin Ender – 2014-07-14T21:00:25.050
Can we retrieve the data defining the shapes of letters from an external file, or does that need to be included in the source as well? – CesiumLifeJacket – 2014-07-14T23:09:46.317
Your binary B has 0 in the top left corner, not 1. – Calvin's Hobbies – 2014-07-15T04:11:34.793
@m.buettner thanks! I'll try to avoid asking other GEB questions until your 18-hole puzzle :p – xem – 2014-07-15T06:18:49.470
@Calvin'sHobbies thanks, fixed it – xem – 2014-07-15T06:19:17.010
@CesiumLifeJacket including the letters' data in your function is part of the challenge :) (you can use all Unicode characters) – xem – 2014-07-15T06:21:05.247
The direction of letters on the cube is defined by the example and we cannot rotate any face, right? – Ray – 2014-07-18T20:12:57.087
that's right @Ray. – xem – 2014-07-18T20:17:41.643
You may get more hits if you change the title to: "Make a Godel-Escher-Bach cube" – DavidC – 2014-07-19T09:59:24.460