给定一个由正则凸多边形组成的顶点图,确定它是否表示凸均匀多面体。
均匀多面体是一个面为规则多边形的多面体,而每个顶点具有相同的顶点形状。一般情况下,均匀多面体可以是非凸的,但在这一挑战中只考虑凸多面体。(更准确地说,多面体必须是顶点传递的,但这只是另一个细节。)
在凸均匀多面体的上下文中,顶点图是一个顶点周围多边形边数的列表。例如,立方体的顶点数为(4.4.4)。
(3.3.3) -四面体 (4.4.4) - Cube (3.3.3.3) - Octahedron (5.5.5) - Dodecahedron (3.3.3.3.3) - Icosahedron (4.4.N)对于每一个N≥3 -N-角棱镜(它是N=4的立方体) (3.3.3.N)为每一个N≥4 -N-角反棱镜(为N=3的八面体) (3 ).6.6) -截断tetrahedron (3.4.3.4) - Cuboctahedron (3.8.8) -截断cube (4.6.6) -截断octahedron (3.4.4.4) - Rhombicuboctahedron (4.6.8) -截断cuboctahedron (3.3.3.3.4) - Icosidodecahedron (3.10.10) -截断dodecahedron (5.6.6)-截短icosahedron (3.4.5.4) - Rhombicosidodecahedron (4.6.10) -截短icosidodecahedron (3.3.3.3.5) -短缩十二面体
这些列表的旋转和反转(通常,所有的二面体排列)也是真实的。例如,(4.6.8)、(4.8.6)、(6.4.8)、(6.8.4)、(8.4.6)、(8.6.4)都是真实的。
(3.3.3.3.3.3) -三角形瓦片;不是多面体。 (5.5.5.5) --4级五角(双曲)瓷砖;不是polyhedron. (3.3.4.4) --不能是均匀的。请注意,这与(3.4.3.4)不同。
一个输入至少有3个条目,由至少3个整数组成。否则,挑战就落在“不关心”的情况下。
(5/2.5/2.5/2) -大柄十二面体;不凸。 (3.3) -三角形二面体;非Euclidean. (2.2.2) -三角形软管;非Euclidean. (3/2.3/2.3/2) -逆行tetrahedron. (1) (-3) ()
发布于 2020-07-19 08:34:42
def f(F):s="".join(hex(k)[2]for k in F);F[1:]in[[4,4],[3]*3]or{s,s[::-1]}&{*"555 333 366 388 3aa 466 566 468 46a 3434 3444 3454 3535 33333 33334 33335".split()}and max(F)<16or f(F[1:]+F[:1])将输入作为表示顶点图形的整数列表。如果顶点图形不是均匀多面体,则函数错误 (RecursionError)没有错误。
我尝试了几种方案,将有限的类组织成一种聪明的方式,利用模式,但硬编码所有的可能性占优势,因为它是一个相对较小的集合。
def f(F):
# F is a rotation of the input vertex figure; initially is the input vertex figure
# Convert to string for easier comparison later in the code
s="".join(hex(k)[2]for k in F)
# Test true if the permutation is N.4.4.4 or N.3.3.3
(F[1:]in[[4,4],[3]*3]or
# Test truthy if permutation (or its reverse) is in
# 3.3.3, 3.6.6, 3.8.8, 3.10.10, 4.6.6, 5.6.6, 4.6.8, 4.6.10,
# 3.3.3.N, 3.4.3.4, 3.4.4.4, 3.4.5.4, 3.5.3.5
# 3.3.3.3.3, 3.3.3.3.4, 3.3.3.3.5
{s,s[::-1]}&{*"555 333 366 388 3aa 466 566 468 46a 3434 3444 3454 3535 33333 33334 33335".split()}
# Numbers greater than 15 would convert into the most-significant hexit when converted to a string,
# causing 0x43 to match the same as 0x4,
# so we need to check that none of this happened if we want a bugfree string search
and max(F)<16
# If we tested truthy, then terminate
# Otherwise, recurse with the vertex figure cyclically rotated left one
or f(F[1:]+F[:1]))https://codegolf.stackexchange.com/questions/207244
复制相似问题