给定整数n,返回n可以写成素数列表的方式数。例如,可以将2323编写为(2,3,23)、(23,23)或(2,3,2,3)或(23,2,3),以便输出4。如果不能用这种方式编写,则应该输出0。
质数(如019或00000037 )是解决此问题的有效素数。
测试用例:
5 -> 1
55 -> 1
3593 -> 4 (359 and 3, or 3 and 593, or 3 and 59 and 3, or 3593)
3079 -> 2 (3 and 079, or 3079)
119 -> 0
5730000037 -> 7 (5,7,3,000003,7, 5,7,3,0000037, 5,73,000003,7, 5,73,0000037, 5,73000003,7, 5,7,30000037, 5730000037)
0-> undefined (you do not have to handle this case)这是密码-高尔夫,所以每种语言中以字节为单位的最短答案获胜!
编辑:现在我知道为什么下次我要使用沙箱了。
发布于 2017-12-19 00:32:01
ŒṖḌÆPẠ€S-1字节,这要归功于漏Nun
-感谢丹尼斯的1字节
ŒṖḌÆPẠ€S Main Link
ŒṖ List Partitions (automatically converts number to decimal digits)
Ḍ Convert back to integers (auto-vectorization)
ÆP Are they primes? (auto-vectorization)
Ạ€ For each, are they all truthy (were the numbers all primes?); 1/0 for truthy/falsy
S Sum; gets number of truthy elements发布于 2017-12-19 20:38:15
发布于 2017-12-19 00:27:26
https://codegolf.stackexchange.com/questions/151142
复制相似问题