【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 ...
随机推荐
- matlab中exist 检查变量、脚本、函数、文件夹或类的存在情况
参考: 1.https://ww2.mathworks.cn/help/matlab/ref/exist.html?searchHighlight=exist&s_tid=doc_srchti ...
- 可能是东半球第二好用的软件工具全部在这里(update in 2020.10.09)
1. 产品经理工具种草 浏览器:Google Chrome 网络浏览器 原型绘制软件:墨刀- 在线产品原型设计与协作平台(https://modao.cc/).摹客mockplus - 摹客,让设计和 ...
- centos7下安装fabric2.2
准备基础环境 1.安装curl.git yum install curl yum install git 2.go环境搭建 下载解压 cd /home mkdir app cd app wget ht ...
- 【MySQL Errors】Table 'xxx' is marked as crashed and should be repaired 的解决方案
现象描述 访问 Zabbix Web,出现如下错误提示: • Error in query [SELECT * FROM history_uint h WHERE h.itemid='25067' O ...
- Python 导入模块的两种方法:import xxx 和from...import xxx
import 方式导入模块 import tool.getsum.add # 导入模块,优先会从启动文件的当前目录开始寻找 # 如果找到,就使用 # 如果找不到,会在系统模块存放目录去 tool.ge ...
- gitlab-配置邮件
一:配置邮件 1. 进入配置文件,通过修改/etc/gitlab/gitlab.rb来设置邮件功能 修改后的文件 1 ## GitLab URL 2 ##! URL on which GitLab ...
- win7如何安装maven
1.Maven的简介Maven是一个项目管理工具,主要用于Java平台的项目构建.依赖管理和项目生命周期管理. 当然对于我这样的程序猿来说,最大的好处就是对jar包的管理比较方便,只需要告诉Maven ...
- rs232转以太网转换器
rs232转以太网转换器 rs232转网络ZLAN5103可以实现RS232/485/422和TCP/IP之间进行透明数据转发.方便地使得串口设备连接到以太网和Internet,实现串口设备的网络化升 ...
- [leetcode] 剑指 Offer 专题(一)
又开了一个笔记专题的坑,未来一两周希望能把<剑指Offer>的题目刷完
- 【动态规划】DP搬运工3
UPD:修了点锅(啊昨天居然写脑抽了) 题目内容 给定两个长度为 \(n\) 的序列,定义 \(magic(A,B)=\sum\limits_{i=1}^n \max(A_i,B_i)\). 现在给定 ...