![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codewars
Zhanghp947
这个作者很懒,什么都没留下…
展开
-
Codewars(Python):Some Egyptian fractions 一些埃及分数
这个是Codewars网站的一个题目,OJ地址题目大意这篇题目的意思就是给你一个字符串n,字符串的形式呢可能是分数,也可能是小数,然后呢,让你把这些数字分成一些埃及分数之和。注意给定的这个n的值呢可能是大于1的。给出一些测试数据,方便大家理解解题工具拿到这个题目应该就是先百度埃及分数是什么样子的:埃及分数的百度百科然后就想到了分解分子分母,我用到了一个fractions模块-分数...原创 2020-04-10 19:48:38 · 301 阅读 · 0 评论 -
Codewars(Python):Josephus Survivor约瑟夫环的问题
相信大家都知道约瑟夫环的问题在本题中,就是给定人数n,n个人围成一个圆圈,然后给定一个特定的数字k,从一个人开始往下数,第k个人出局,然后再从k+1个人接着从1开始数,依此类推求留下来的最后一个人。思路就是本来的话,我用的是一个队列模拟的思路,当然很明显,对于oj,运行速度就太慢了,就去网上百度了约瑟夫环,发现了一个约瑟夫环的递推公式:那么通过这个公式,可以采用递归或者循环都可以,那么这里...原创 2020-04-09 19:54:58 · 256 阅读 · 0 评论 -
Python编程练习 codewars:Unary Messages
题目链接codewars网站:codewars:Unary Messages题目大意通常的二进制是用0和1来进行编码和解码的,但是本题希望能够只用0来表示。在用0进行编码的时候,需要遵守的规则有以下几点:字符信息都要用七位二进制来表示(未满7位的要补满)连续相同的数字为有两部分组成,前一部分为数字的种类,后一部分为这个连续数字的长度个0构成各个部分都要用空格来分割数字的种类:0 用...原创 2020-03-06 14:30:15 · 189 阅读 · 0 评论 -
Python编程练习 codewars:List of all Rationals
Python编程练习 codewars:List of all RationalsInstructionsHere’s a way to construct a list containing every positive rational number:Build a binary tree where each node is a rational and the root is 1/1,...原创 2020-03-04 19:26:44 · 214 阅读 · 0 评论 -
codewars(Python):Easy Diagonal 组合数的计算
codewars(Python):Easy DiagonalInstructionsIn the drawing below we have a part of the Pascal’s triangle, lines are numbered from zero (top). The left diagonal in pale blue with only numbers equal to ...原创 2020-02-29 21:16:16 · 294 阅读 · 0 评论 -
codewars(Python):Next polydivisible number
codewars(Python):Next polydivisible numberInstructionsGiven a non-negative number, return the next bigger polydivisible number, or an empty value like null or Nothing.A number is polydivisible if i...原创 2020-02-27 17:16:02 · 486 阅读 · 0 评论 -
codewars:Split Strings
codewars:Split StringsInstructionsComplete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missi...原创 2020-02-26 15:52:37 · 296 阅读 · 0 评论 -
codewars:Element equals its index
Element equals its indexInstructionsGiven a sorted array of distinct integers, write a function index_equals_value that returns the lowest index for which array[index] == index.Return -1 if there i...原创 2020-02-25 14:30:58 · 356 阅读 · 0 评论