题目:

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(平方加总)的更多相关文章

  1. 【Kata Daily 191010】Grasshopper - Summation(加总)

    题目: Summation Write a program that finds the summation of every number from 1 to num. The number wil ...

  2. 【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 ...

  3. 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 ...

  4. Project Euler 92:Square digit chains 平方数字链

    题目 Square digit chains A number chain is created by continuously adding the square of the digits in ...

  5. [LeetCode] Valid Word Square 验证单词平方

    Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a v ...

  6. 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< ...

  7. 【Kata Daily 190929】Password Hashes(密码哈希)

    题目: When you sign up for an account somewhere, some websites do not actually store your password in ...

  8. 【Kata Daily 190927】Counting sheep...(数绵羊)

    题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...

  9. 【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 ...

随机推荐

  1. 058 01 Android 零基础入门 01 Java基础语法 06 Java一维数组 05 案例:求数组元素的最大值

    058 01 Android 零基础入门 01 Java基础语法 06 Java一维数组 05 案例:求数组元素的最大值 本文知识点:求数组元素的最大值 案例:求数组元素的最大值 程序代码及其执行过程 ...

  2. matlab中sum

    来源:https://ww2.mathworks.cn/help/matlab/ref/sum.html?searchHighlight=sum&s_tid=doc_srchtitle#btv ...

  3. P1879 [USACO06NOV] Corn Fields G

    题目描述 农场主John新买了一块长方形的新牧场,这块牧场被划分成M行N列(1 ≤ M ≤ 12; 1 ≤ N ≤ 12),每一格都是一块正方形的土地.John打算在牧场上的某几格里种上美味的草,供他 ...

  4. 十一、模拟扫码登录微信(用Django简单的布置了下页面)发送接收消息

    为了能够模拟登陆QQ,并获取信息.对扫码登录微信进行了分析.简单的用了一下Django将获取的信息映射到页面上.(python3+pycharm) 主要过程就是: 1.获取二维码 2.扫码登录(有三种 ...

  5. 实现Excel文件的上传和解析

    前言 本文思维导图 一.需求描述 实现一个页面上传excel的功能,并对excel中的内容做解析,最后存储在数据库中. 二.代码实现 需求实现思路: 先对上传的文件做校验和解析,这里我们通过Excel ...

  6. 【手摸手,带你搭建前后端分离商城系统】01 搭建基本代码框架、生成一个基本API

    [手摸手,带你搭建前后端分离商城系统]01 搭建基本代码框架.生成一个基本API 通过本教程的学习,将带你从零搭建一个商城系统. 当然,这个商城涵盖了很多流行的知识点和技术核心 我可以学习到什么? S ...

  7. spring boot:用spring security加强druid的安全(druid 1.1.22 / spring boot 2.3.3)

    一,druid的安全保障有哪些环节要注意? 1,druid ui的访问要有ip地址限制 2,用户必须要有相应的权限才能访问druid 3,关闭重置功能 说明:stat-view-servlet.url ...

  8. Nginx常见错误解决办法

    报错: nginx: [error] CreateFile() "C:\mytools\nginx-1.8.1/logs/nginx.pid" failed (2: The sys ...

  9. 无法为数据库 'tempdb' 中的对象分配空间,因为 'PRIMARY' 文件组已满

    错误描述 消息 1105,级别 17,状态 2,第 1 行无 法为数据库 'tempdb' 中的对象 'dbo.SORT temporary run storage:  140737503494144 ...

  10. Hibernate关系映射之many-to-many(多对多)

    在表设计中,我们一般都会考虑表与表之间的关系,现在我来介绍一下表与表之间的几种对应关系many-to-many 多对多 比如一个用户可以有多种角色 一种角色可以对用多个不同的用户所以角色和用户之间的关 ...