- 博客(7)
- 收藏
- 关注
原创 Python 回文数问题
def is_palindrome(n): return str(n)==str(n)[-1::-1]测试output = filter(is_palindrome, range(1, 1000))print('1~1000:', list(output))if list(filter(is_palindrome, range(1, 200))) == [1, 2, 3, 4, 5, 6, ...
2018-03-19 16:33:15
1157
原创 Python 求1000以内素数
先构造从3开始的奇数数列def _odd_iter(): n=1 while True: n=n+2 yield n判断函数def _not_divisible(n): return lambda x: x % n>0返回素数函数def primes(): yield 2 it = _odd_iter() while True: n=next(it) yield ...
2018-03-19 16:31:02
4726
转载 汉诺塔问题(递归)最清晰的回答 python
转自知乎https://www.zhihu.com/question/37152936重点其实是:不要一开始就关心每一步怎么解决的,你只需要把函数当成一个实现你目的的神器,随时调用。也就是递归。比如说我们有一个万能神器move,只需要给它几个参数,即可自动完成一个功能:把n个盘子利用缓冲区,从起点运送到终点,期间严格遵守汉诺塔规则move(N,起点,缓冲区,终点) N: 盘子的个数现在有个n个盘子...
2018-03-17 10:56:26
257
原创 Python 学习 one
height=float(input('Input your height:'))weight=float(input('Input your weight:'))bmi=float(weight/(height*height))if bmi<18.5: print('体重过轻')elif (bmi>=18.5 and bmi<25): print('正常')eli...
2018-03-17 10:16:38
218
转载 有用的java代码片段2
distinctValuesOfArray返回数组的所有不同值。使用 Arrays.stream().distinct() 去除所有重复的值。public static int[] distinctValuesOfArray(int[] elements) { return Arrays.stream(elements).distinct().toArray();}dropElement...
2018-03-07 23:02:24
231
转载 有用的java代码片段①
Array (数组相关)chunk将数组分割成特定大小的小数组。public static int[][] chunk(int[] numbers, int size) { return IntStream.iterate(0, i -> i + size) .limit((long) Math.ceil((double) numbers.length / ...
2018-02-21 19:36:11
235
原创 eclipse无法创建工作区
装了一下jdk1.9,发现在启动eclipse的时候出现了这个窗口(借图)然后去找日志文件 日志如下!SESSION 2018-02-04 14:39:01.533 -----------------------------------------------eclipse.buildId=4.4.0.I20140606-1215java.version=9.0.4java.v
2018-02-04 15:26:09
7569
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人