pythonchallenge Level 10
2021/12/7 11:18:03
本文主要是介绍pythonchallenge Level 10,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
第10关地址:http://www.pythonchallenge.com/pc/return/bull.html
账号:huge 密码:file
页面提示 len(a[30])
点击大牛的位置,跳转到了http://www.pythonchallenge.com/pc/return/sequence.txt
a = [1, 11, 21, 1211, 111221,
也就是找规律,求len(a[30])是多少
规律是第二个数字是读第一个数字,如
1:1个1=11
11:2个1=21
21:1个2,2个1=1221
1211:1个1,1个2,2个1=111221
111221:3个1,2个2,1个1=312211
...以此类推得到a[30]并且计算长度
def deal_numNew(str_num): num = 1 new_list = [] if len(str_num) == 1: num = 1 new_list.append(str(num)) new_list.append(str_num[0]) else: for i in range(len(str_num)): if i+1==len(str_num): new_list.append(str(num)) new_list.append(str_num[i]) elif str_num[i+1] == str_num[i]: num += 1 else: new_list.append(str(num)) new_list.append(str_num[i]) num = 1 return ''.join(new_list) a = [1, 11, 21, 1211, 111221, 312211] str_num = "312211" for i in range(30): new_list = deal_numNew(str_num) a.append(new_list) str_num = a[-1] print(a[30]) print(len(a[30]))
得到 len(a[30]) = 5808
获得下一关地址:http://www.pythonchallenge.com/pc/return/5808.html
这篇关于pythonchallenge Level 10的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24Python编程入门指南
- 2024-12-24Python编程基础入门
- 2024-12-24Python编程基础:变量与数据类型
- 2024-12-23使用python部署一个usdt合约,部署自己的usdt稳定币
- 2024-12-20Python编程入门指南
- 2024-12-20Python编程基础与进阶
- 2024-12-19Python基础编程教程
- 2024-12-19python 文件的后缀名是什么 怎么运行一个python文件?-icode9专业技术文章分享
- 2024-12-19使用python 把docx转为pdf文件有哪些方法?-icode9专业技术文章分享
- 2024-12-19python怎么更换换pip的源镜像?-icode9专业技术文章分享