题目:

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. 01 Arcgis10.6 安装教程

    一.ArcGIS系统要求 包括: Win7 SP1(及以上) 32/64位系统 Win8.1 32/64位系统 Win10 32/64位系统 二.下载ArcGIS 10.6安装文件 链接:https: ...

  2. 001 发大招了 神奇的效率工具--Java代码转python代码

    今天发现一个好玩的工具: 可以直接将java转成python 1. 安装工具(windows 环境下面) 先下载antlr: 下载链接如下: http://www.antlr3.org/downloa ...

  3. 配置adpate的方式

    配置adpate的方式 资源文件配置 ArryAdapter<CharSequence>cadapt= ArryAdapter.createFromResource(this,资源id,a ...

  4. 【Go语言入门系列】Go语言工作目录介绍及命令工具的使用

    [Go语言入门系列]前面的文章: [保姆级教程]手把手教你进行Go语言环境安装及相关VSCode配置 [Go语言入门系列](八)Go语言是不是面向对象语言? [Go语言入门系列](九)写这些就是为了搞 ...

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

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

  6. SpringBoot整合Mybatis 编译失败:找不到符号 程序包不存在

    问题描述:jpa不好用,转用mybatis,配置多数据源  但是配置后无法编译mvn clean install  dao层这些报错,找不到entity的包     问题解决:罪魁祸首:热部署的部分 ...

  7. MeteoInfoLab脚本示例:水汽通量散度计算

    用ncep数据计算水汽通量散度的脚本.需要air, uwnd, vwnd和rhum变量.数据是4维数据,需要固定时间维和高度维,数据中纬度维的数据是反向的,因此读取时需要特殊的设置(::-1).脚本中 ...

  8. Mysql数据库分布式事务XA详解

    XA事务简介 XA 事务的基础是两阶段提交协议.需要有一个事务协调者来保证所有的事务参与者都完成了准备工作(第一阶段).如果协调者收到所有参与者都准备好的消息,就会通知所有的事务都可以提交了(第二阶段 ...

  9. docker 启动redis/nginx

    1.docker 启动redis   # redis docker run -itd --name redis-test -p 16379:6379 redis   2.docker 启动nginx ...

  10. ImageMagick:用identify得到图片的平均颜色(基本颜色/主色调)

    一,平均颜色的用途: 很多app在流式的展示图片时, 在图片没加载出来之前, 不是使用统一的背景图, 而是先显示一个纯色的背景, 而背景色和图片的颜色非常接近, 这样给用户的体验会更好. 我们这里演示 ...