
Codewars
文章平均质量分 77
张子虚
夫水之积也不厚,则其负大舟也无力。
展开
-
Codewars-Javascript训练手册:Date 对象
乌龟赛跑问题(Tortoise racing)两只蠢蠢的乌龟长跑比赛,年老的乌龟(老龟)跑的慢v1,领先跑了一段距离g,年青的乌龟(青龟)跑得快v2,在某个时间点后够追上老龟,那么问题来了:什么时间后青龟追上老龟。 Examples:race(720, 850, 70) => [0, 32, 18]race(80, 91, 37) => [3, 21, 49]写出实现这个功能的函数。 Solu原创 2016-04-26 21:49:31 · 708 阅读 · 0 评论 -
Codewars-Javascript训练手册:数组(上)
Directions Reduction题目描述(Description):write a function dirReduc which will take an array of strings and returns an array of strings with the needless directions removed (W<->E or S<->N side by side).原创 2016-04-20 13:28:35 · 1054 阅读 · 0 评论 -
Codewars-Javascript训练手册:字符串(上)
Recursive reverse string(递归反转字符串)stackoverflow解决方案:function reverse (str) { if (str === "") { return ""; } else { return reverse(str.substr(1)) + str.charAt(0); }}可改写为:retur原创 2016-04-19 01:21:25 · 782 阅读 · 0 评论 -
Codewars-Javascript训练手册:字符串(中)
这几天Codewars上的字符串训练好繁琐Detect Pangram:检测全字母句子还记得那个经典的英文句子吗:迅捷的棕色狐狸跳过了懒惰的狗狗身上(The quick brown fox jumps over the lazy dog),如题,这次的题目是检测给定的字符串是否为全字母句子,是返回true,否则,返回false。 解决方案:function isPangram(string){原创 2016-05-11 18:44:29 · 649 阅读 · 0 评论 -
这题目有毒之干不过codewars的OJ系统(一)
题目描述给定一个整数数组和一个求和的数值,函数返回数组中第一对元素求和值等于给定求和值的数组元素,返回形式为数组。 案例:sum_pairs([0, 0, -2, 3], 2)# there are no pairs of values that can be added to produce 2.== None/nil/undefined (Based on the language)su原创 2016-05-21 13:10:05 · 1113 阅读 · 0 评论 -
Codewars-Javascript训练手册:正则表达式(上)
Autocomplete! Yay!(字符串自动补全)The autocomplete function will take in an input string and a dictionary array and return the values from the dictionary that start with the input string. If there are more th原创 2016-04-27 01:57:42 · 626 阅读 · 0 评论 -
数据结构与逻辑代码(一)
前言《大教堂和市集》中有这样一句话:聪明的数据结构和笨拙的代码要比相反的搭配工作的更好 ,我深以为然。本篇博文就是对此话题的个人简单理解,涉及的编程问题基本上来源于Codewars。 关于《大教堂与市集》中文版可访问这里释读Pascal之父——Nicklaus Wirth提出著名公式 “算法+数据结构=程序”本篇博文的主题也可以用简单的数学语句表达出来: 聪明的数据结构 + 笨拙的逻辑代原创 2016-04-30 22:07:42 · 2446 阅读 · 0 评论 -
这题目有毒之干不过codewars的OJ系统(二)
kata<4kyu>Guess the Digits and Expression Description: Give you a multiplication arithmetic expression: ABC * CBA ------- = 39483Each character ...原创 2018-04-27 16:35:51 · 380 阅读 · 0 评论