Determine the type of Cuboid
05AB1E, 26 21 bytes
None: 0
Cube: 1
Regular Domino Cuboid: 2
Shapeshifter Cuboid: 3
Brick Cuboid: 4
Floppy Cuboid: 5
•S3X@I¨%÷'•5L¦3ãPÙIkè
Try it online! or as a Test suite
Explanation
•S3X@I¨%÷'• # push base-214 compression of the number 123224454212324512210
5L¦ # push the list [2,3,4,5]
3ã # cartesian product with repetion of size 3
P # product of each sublist
Ù # remove duplicates
Ik # get the index of input in that list (-1 if non-existant)
è # get the element at this index in the above number
The only place I see that we could save bytes here is find a better way of generating the number 123224454212324512210.
It is only 1-off from a prime, so one possible save would be to find the index of that prime and generate the index in less than 9 bytes.
I don't know how well the pi-function works for 21-digit primes but that could be a possibility.
JavaScript (ES6), 97 92 86 bytes
This function first checks the validity of the input, then picks the correct value from a lookup table.
Surprisingly, the longest part is the validity check (is n of the form x*y*z with x, y and z in [2,3,4,5]?). There must be a shorter way of doing it, but I couldn't figure it out so far.
n=>'NBBF..CRCC.BRR..SFRRRRR.B..C'[[34707324,0x80000800,4240,262208][n&3]>>n/4&1&&n%29]
Returns a character:
- N: None
- C: Cube
- R: Regular Domino Cuboid
- S: Shapeshifter Cuboid
- B: Brick Cuboid
- F: Floppy Cuboid
Test
let f =
n=>'NBBF..CRCC.BRR..SFRRRRR.B..C'[[34707324,0x80000800,4240,262208][n&3]>>n/4&1&&n%29]
// invalid
;[9,13,99].map(
n => { console.log(n, f(n)) }
)
// valid
;[8,12,16,20,18,24,30,32,40,50,27,36,45,48,60,75,64,80,100,125].map(
n => { console.log(n, f(n)) }
)