Python Challenge (level 10)

xiaoxiao2026-09-02  4

URI: [url]http://www.pythonchallenge.com/pc/return/bull.html[/url] Username: huge; password: file 说明: — 解题方法: import itertoolsdef look_and_say (length): table = { ("1", "1", "1"): "31", ("1", "1"): "21", ("1", ): "11", ("2", "2", "2"): "32", ("2", "2"): "22", ("2", ): "12", ("3", "3", "3"): "33", ("3", "3"): "23", ("3", ): "13" } prec, result = "1", [1] for i in xrange(length - 1): prec = "".join(table[tuple(l)] for e, l in itertools.groupby(prec)) result.append(int(prec)) return resultprint len(str(look_and_say(31)[30])) 过关答案: 5808 相关资源:pythonchallenge level2官方方法集
转载请注明原文地址: https://www.6miu.com/read-5052281.html

最新回复(0)