kata题目
来源:互联网 发布:linux做网站需要环境 编辑:程序博客网 时间:2024/05/22 02:13
My little sister came back home from school with the following task:given a squared sheet of paper she has to cut it in pieceswhich, when assembled, give squares the sides of which forman increasing sequence of numbers.At the beginning it was lot of fun but little by little we were tired of seeing the pile of torn paper.So we decided to write a program that could help us and protects trees.
Examples
decompose(11)
must return [1,2,4,10]
. Note that there are actually two ways to decompose 11²,11² = 121 = 1 + 4 + 16 + 100 = 1² + 2² + 4² + 10² but don't return[2,6,9]
, since 9 is smaller than 10.
For decompose(50)
don't return [1, 1, 4, 9, 49]
but [1, 3, 5, 8, 49]
since [1, 1, 4, 9, 49]
doesn't form a strictly increasing sequence.
python:
def decompose(n): def recurse(s,i): if s<0: return None if s == 0: return [] for j in xrange(i - 1,0,-1): sub = recurse(s-j**2,j) if sub != None: return sub+[j] return recurse(n**2,n)
- kata题目
- coding kata
- code Kata NO.1
- Software Craftsmanship - code kata
- Kata-One:超级市场定价
- 文档Kata练习
- My first code kata
- code kata NO.3 - Kata Three: How Big, How Fast?
- 从kata中学习编程
- code kata NO.2 : Karate Chop
- Kata代码,程序猿的练习课程
- Code Kata编码套路练习网站参考
- BD、人脸识别、KATA、Gray码--程序员杂志文摘
- 在英文网站kata上遇到的小题
- 终极编程道场(The Ultimate Code Kata)
- Kata系列之排序算法的冒泡排序
- Kata系列之排序算法的选择排序
- 为什么推出 Kata Containers? OpenStack 基金会主席这样说
- 【Android】SQLite 创建数据库,并实现增删改查
- DSRC
- C盘空间异常(坑)
- 8-11
- html的基本标签
- kata题目
- xamarin学习笔记A10(安卓SQLite)
- 利用什么软件可以将PDF文件进行文件的拆分
- 牛客6
- 判断网络 并选择加载图片的方式
- Spring 4初级 2
- listview多条目展示
- 分治法和动态规划求解最长公共子串
- 南阳oj 116 士兵杀敌二 线段树