【Kata Daily 190920】Square(n) Sum(平方加总)
题目:
Complete the square sum function so that it squares each number passed into it and then sums the results together.
For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9.
解题方法:(再想想可能就出来了)
def square_sum(numbers):
return sum(map(lambda x: x**2,numbers))
还有其他的办法:
def square_sum(numbers):
return sum(x**2 for x in numbers)
【Kata Daily 190920】Square(n) Sum(平方加总)的更多相关文章
- 【Kata Daily 191010】Grasshopper - Summation(加总)
题目: Summation Write a program that finds the summation of every number from 1 to num. The number wil ...
- 【leetcode】1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold
题目如下: Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square ...
- leetcode_1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold_[二维前缀和]
题目链接 Given a m x n matrix mat and an integer threshold. Return the maximum side-length of a square w ...
- Project Euler 92:Square digit chains 平方数字链
题目 Square digit chains A number chain is created by continuously adding the square of the digits in ...
- [LeetCode] Valid Word Square 验证单词平方
Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...
- LeetCode 1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold
题目 我是按照边进行二分的 class Solution { public: int sum[100005]; int a[305][305]; int maxSideLength(vector< ...
- 【Kata Daily 190929】Password Hashes(密码哈希)
题目: When you sign up for an account somewhere, some websites do not actually store your password in ...
- 【Kata Daily 190927】Counting sheep...(数绵羊)
题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...
- 【Kata Daily 190912】Alphabetical Addition(字母相加)
题目: Your task is to add up letters to one letter. The function will be given a variable amount of ar ...
随机推荐
- 04 Storage and Calculation C语言中的存储和计算
文章内容来源于Programming Hub的学习记录,本人整理添加了中文翻译,如有侵权,联系本人删除 Variables C语言中的变量 Let's extend our mainfunction ...
- matlab中for 用来重复指定次数的 for 循环
参考:https://ww2.mathworks.cn/help/matlab/ref/for.html?searchHighlight=for&s_tid=doc_srchtitle for ...
- C# OOP编程
1:面向对象的概念:什么是类.对象.以及类与对象的关系. 面向对象三大特征: 封装/继承/多台 2:封装性: 用访问修饰符来体现封装性. Public 公共的/ private 私有的/Protect ...
- node_modules 文件夹需要管理员权限才能删除问题
方法一:以管理员权限运行IDE ,然后在IDE里面删除该文件夹 方法二:以管理员身份运行cmd,使用命令行来删除该文件夹 找到要删除文件夹的位置,使用命令行 rmdir /s/q 文件夹位置 /s 是 ...
- 53.Qt-QPdfWriter绘制PDF,支持表单输出
之前打印PDF都是通过html形式来实现的,但是这次要做的东西,需要打印界面控件,所以需要使用QPdfWriter. 通过QPdfWriter来获取QPainter对象,就能实现在PDF上来画画啦. ...
- 多测师_肖sir_git _004(版本控制器)
gitgit 是一个开源的分布式版本控制系统,用于敏捷高效的处理任何大小的项目.git是linux torvalds 为了帮助管理linux内核开发的一个开放源码的版本控制软件.git与常用的版本控制 ...
- .NET 5.0 RC2 发布,正式版即将在 11 月 .NET Conf 大会上发布
原文:http://dwz.win/ThX 作者:Richard 翻译:精致码农-王亮 说明:本译文舍弃了少许我实在不知道如何翻译但又不是很重要的语句. 今天(10月13日)我们发布了 .NET 5. ...
- Token 、Cookie和Session的区别
本文转至http://blog.csdn.net/tobetheender/article/details/52485948 https://blog.csdn.net/axin66ok/articl ...
- spring boot:shardingsphere+druid整合seata分布式事务(spring boot 2.3.3)
一,shardingshpere为什么要整合seata? 分库分表是数据库扩展中最常用的处理方法, shardingshpere作为使用最广泛的分表中间件, 如果不支持分布式事务,则它的数据一致性就会 ...
- laravel重写
laravel location / { try_files $uri $uri/ /index.php?$query_string; } ci location / { try_files $uri ...