今天出了一些事~到现在才开始看
题目:
[
’ * ',
’ *** ',
‘*****’
]
让我们以列表的形式输出:

def bulid_tower(n):output = []for i in range(n):str = ''for _ in range(n - i - 1):str += ' 'for _ in range(2 * i + 1):str +='*'for _ in range(n - i - 1):str += ' 'output.append(str)return output

大神代码:

def build_tower(n):return [('*'*(2*i+1)).center(2*n - 1) for i in range(0,n)]

题目:
Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative.

就是给你一个整数,把它变成二进制数,然后统计1的个数

我的代码:

def countBits(n):n = bin(n)n = str(n)count = 0for i in n:if i == '1':count += 1return count

别人的代码:

def countBits(n):count = 0while n >0:if n & 1 == 1:count += 1n >>= 1return count

注意移位运算符 >>

题目:
Return the number (count) of vowels in the given string. We will consider a, e, i, o, and u as vowels for this Kata.The input string will only consist of lower case letters and/or spaces.
要求我们返回给定字符串中元音字母的个数
很简单的一道编程题
我的代码:

def getCount(inputStr):s = 'aeiou'count = 0for i in inputStr:if i in s:count += 1return count

高亮代码:

def getCount(inputStr):return sum(1 for let in inputStr if let in 'aeiou')

sum(iterable, [, start])函数
iterable:可迭代的对象,列表、元组、集合等。
start:指定相加的参数,若缺省则为0
满足if条件时生成一个1加入序列,最终生成一个包含多个1的序列作为sum的函数,求和可得1的个数。

题目:
A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (base 10).
给我们一个数字,让我们判断它是不是一个自幂数,所谓自幂数,就是它本身各个位的n次方相加等于本身,这里面的n是这个数的位数

思路:
先判断这个数字是几位数,再判断是不是自幂数

我的代码:

def narcissistic( value ):n = len(str(value))newvalue = str(value)temp = 0for i in newvalue:temp += int(i)**nif temp == value:return Trueelse:return False

大神代码:

def narcissistic(value):return value == sum(int(x)**len(str(value)) for x in str(value))

今日最后一题:
Alice and Bob were on a holiday. Both of them took many pictures of the places they’ve been, and now they want to show Charlie their entire collection. However, Charlie doesn’t like this sessions, since the motive usually repeats. He isn’t fond of seeing the Eiffel tower 40 times. He tells them that he will only sit during the session if they show the same motive at most N times. Luckily, Alice and Bob are able to encode the motive as a number. Can you help them to remove numbers such that their list contains each number only up to N times, without changing the order?

给我们一个列表,要求相同的元素不能出现n次(n给定)

我的代码:

def delete_nth(order,max_e):output = []for i in order:if output.count(i) < max_e:output.append(i)return output

难得写这么好一次(主要是以前做过类似的)

小白的自我救赎:今日份学习相关推荐

  1. 2020.04.16今日份学习小结

    自我总结第二天start. 主要学习了分支结构中的 if 语句. //在代码运行中常见的结构有:1.顺序结构 2.分支结构 3.循环结构. 一. if 分支结构 格式为: if (/* 条件判断 */ ...

  2. 积极考研自救day1之leectode24点问题+今日份学习总结

    今天开始不能丧气的听天由命,把那个诅咒我考不上的学长删了 ,努力把自己那不高的考研分数发挥到极致,主动联系导师要论文,LeetCode主要是搜索和字符串链表之类的,每天日更博客五道编程题从中选一个最精 ...

  3. redis spring 切面缓存_今日份学习: Spring中使用AOP并实现redis缓存?

    笔记 在Spring中如何使用AOP? Spring是如何切换JDK动态代理和CGLIB的? spring.aop.proxy-target-class=true (在下方第二个链接中,原生doc中提 ...

  4. springboot自动配置原理_今日份学习之Spring Boot自动配置实现原理

    通过前面章节的学习,我们掌握了使用Spring Boot框架进行实际应用开发的方法.在使用Spring Boot 的过程中,我们时常会为一些看似简单,但实际上蕴藏了强大功能的实现而惊呼,下面就让我们来 ...

  5. GPS 校验和 代码_今日份∣学习(三菱-菱云系列)电梯故障代码表

    作为电梯人, 我们不仅要从培训中学习, 更要从实践中总结窍门和技巧, 这样,见的多了, 遇到问题才不会慌张,才能得心应手, 想要成为"电梯高手", 还需要我们下功夫,加油吧! 故障 ...

  6. 小白的自我救赎:今日份codewars

    今天一天的课-练的可能会少点 题目: The museum of incredible dull things The museum of incredible dull things wants t ...

  7. 0基础软件测试小白,如何找到一份高薪的工作?

    对于很多测试小白,刚刚学习的时候都会有许多困惑,从事软件测试到底要掌握哪些知识?如何学习和提升自己的能力?测试行业的职业发展应该如何规划?...... 以上这些问题都是软件测试小白入门需要了解的内容. ...

  8. 程序员的自我救赎,使用python开发性格分析工具

    自我救赎 帕累托法则 上世纪初,意大利经济学家维尔弗雷多▪帕累托发现了一个有趣的现象: 在意大利, 大约80%的财富掌握在大约20%的人手中,这在后来被概括为帕累托法则(80/20法则),即二八法则. ...

  9. 二本菜鸡,颓废两年的自我救赎

    大家好,我是帅地. 随着校招的结束,帅地的星球里也有不少小伙伴前来报喜,今天这篇,是星球一个颓废两年同学的自我救赎之路,我觉得他的经历和很多人一样,前两年可能就颓废了,后面才后知后觉,具有一定的代表性 ...

最新文章

  1. html图片显示和夫宽一样,功夫:HTML和CSS?
  2. 【错误记录】360 加固后的运行错误 ( 加固 SO 动态库时不能对第三方动态库进行加固 )
  3. 团队竞争力有多强,你的企业就能走多远
  4. 中青旅:在线旅游行业如何选型数据分析平台?
  5. linux之pmap命令
  6. c++五子棋_Java五子棋实现
  7. Pytorch实战1:线性回归(Linear Regresion)
  8. C# 发送邮件的记录(qq,126,Gmail)
  9. 【CodeForces - 987C 】Three displays (dp,最长上升子序列类问题,三元组问题)
  10. 【SpringClould】SpringClould eureka 单机与集群搭建
  11. oracle 中关于 SID db_name、instance_name (转)
  12. 判断一个整数是否为2的方幂
  13. MAC 访问 Windows 共享文件夹
  14. php工程师外派,招聘兼职Php工程师|Php工程师外包-猿急送
  15. Android 眼睛 显示隐藏密码(ImageView)
  16. 飞行棋程序(附源码)
  17. 2022前端面试(一面面试题)
  18. 微信支付的两种模式,扫码支付
  19. 独立游戏——《爱与正义》准备开工啦!
  20. Android 百度语音合成 (含离线、在线、API合成方式,详细步骤+源码)

热门文章

  1. sybase登录用户管理2
  2. Grade下载网页地址
  3. 厉害了!九州云边缘计算管理平台获国家权威认证
  4. python curses_Py之curses:curses库的简介、使用、安装方法详细攻略
  5. 【bind()函数】JavaScript手写bind()及详解-超详细~~~
  6. Linux 磁盘相关知识点总结
  7. 文件头、文件尾、特征码、常见文件的特征码
  8. 新手卖家如何利用Listing在亚马逊站稳脚跟?
  9. 20230408英语学习
  10. 搜索其他计算机共享的打印机,打印机共享后其他电脑搜索不到_共享打印机查找不到_打印机品牌排行榜...