I have a binary number. This binary has 256 possibilities. I only need to check for 47 of those possibilities.
Its hard to explain and irrelevant, but point[]
is an array of Int
that I obtain from checking the surrounding tiles in an SKTileMapNode.
let number = 1 * point[0] + 2 * point[1] + 4 * point[2] + 8 * point[3] + 16 * point[4] + 32 * point[5] + 64 * point[6] + 128 * point[7]
//=======o
// 1-10 { 2 = 1, 8 = 2, 10 = 3, 11 = 4, 16 = 5, 18 = 6, 22 = 7, 24 = 8, 26 = 9, 27 = 10, }
// 11-19 { 30 = 11, 31 = 12, 64 = 13, 66 = 14, 72 = 15, 74 = 16, 75 = 17, 80 = 18, 82 = 19,}
// 20-28 { 86 = 20, 88 = 21, 90 = 22, 91 = 23, 94 = 24, 95 = 25, 104 = 26, 106 = 27, 107 = 28, }
// 29-37 { 120 = 29, 122 = 30, 123 = 31, 126 = 32, 127 = 33, 208 = 34, 210 = 35, 214 = 36, 216 = 37, }
// 38-47 { 218 = 38, 219 = 39, 222 = 40, 223 = 41, 248 = 42, 250 = 43, 251 = 44, 254 = 45, 255 = 46, 0 = 47 }
//=======o
binary = 1, binary = 2, binary = 3, etc.
I only need these 47 out of the 256 possibilities. Is there an easy way to check my number
against these 47 without having to write 47 if-statements?