JavaScript(ES6),88个字节
a=>a.map(o=n=>[x=o[n]=-~o[n],6,,,21,9,8^o[1]][a=x<a?a:x])[5]|[,1,4,5,o[1]&2|8,2,4][o[4]]
在线尝试!
或测试所有可能的卷!
根据以下映射输出整数:
Rank | Output Rank | Output
------+-------- ------+--------
0 | 31 7 | 7
1 | 12 8 | 5
2 | 14 9 | 21
3 | 8 10 | 4
4 | 11 11 | 1
5 | 9 12 | 0
6 | 29
怎么样?
方法
通过在以下之间执行按位或运算来计算输出:
例外情况:
- F= 44 b4 个
- 中号= 66 b6 个
表
F中号
中号1个23456 个6 bF要么600219814006002198141个1个71个1个219915246442113121435755211313154 个814882998144b101410103111101452622231110146464421131214
中号≥ 3中号≤ 3中号F= 3
例
中号= 1F= 1
6 或 1 = 7
77
已评论
a => // a[] = input array, reused as an integer to keep track of the
a.map( // maximum number of occurrences of the same dice (M)
o = // o = object used to count the number of occurrences of each dice
n => // for each dice n in a[]:
[ // this is the lookup array for M-bitmasks:
x = // x = o[n] = number of occurrences of the current dice
o[n] = -~o[n], // increment o[n] (we can't have M = 0, so this slot is not used)
6, // M = 1 -> bitmask = 6
, // M = 2 -> bitmask = 0
, // M = 3 -> bitmask = 0
21, // M = 4 -> bitmask = 21
9, // M = 5 -> bitmask = 9
8 ^ o[1] // M = 6 -> bitmask = 14 for six 1's, or 8 otherwise
][a = // take the entry corresponding to M (stored in a)
x < a ? a : x] // update a to max(a, x)
)[5] // end of map(); keep the last value
| // do a bitwise OR with the second bitmask
[ // this is the lookup array for F-bitmasks:
, // F = 0 -> bitmask = 0
1, // F = 1 -> bitmask = 1
4, // F = 2 -> bitmask = 4
5, // F = 3 -> bitmask = 5
o[1] & 2 | 8, // F = 4 -> bitmask = 10 if we also have two 1's, 8 otherwise
2, // F = 5 -> bitmask = 2
4 // F = 6 -> bitmask = 4
][o[4]] // take the entry corresponding to F (the number of 4's)