Corinne.与现充少女

Thinking will not overcome fear but action will.

Duplicate Encoder

20181002_Codewars_duplicate_encode

Duplicate Encoder Codewars Kata 24√ Description Link: https://www.codewars.com/kata/54b42f9314d9229fd6000d9c -简述:本题给定一个字符串,若字符串中的字符只出现过一次,则用’(‘代替,若出现过不止一次,则用’)’代替。 -思路:计数,判断是否出现过超过一次,分情况替代。 -难点:如何...

Round by 0.5 steps

20181001_Codewars_round_0.5steps

Round by 0.5 steps Codewars Kata 23√ Description Link: https://www.codewars.com/kata/51f1342c76b586046800002a -简述:本题要求设计一个函数使得小数以0.5为步长进行四舍五入。 -思路:具体分类讨论小数的范围和对应的四舍五入的值(笨方法)。将该数字翻倍,按照原本的四舍五入规则进行处理...

English beggars

20180930_Codewars_beggars

English beggars Codewars Kata 22√ Description https://www.codewars.com/kata/59590976838112bfea0000fa -简述:本题给定一系列值和一些乞丐,你应该返回一个数组,其中包含每个乞丐带回家的总和,假设它们都经常循环, 第一个到最后一个。 -思路:常规做法:循环递增;巧妙方法:values[i::n]...

Two Sum

20180929_Codewars_two_sum

Two Sum Codewars Kata 21√ Description Link: https://www.codewars.com/kata/52c31f8e6605bcc646000082 -简述:本题给定一列整数和一个目标数字,要求设计一个函数,使得在该数列中找到两个不同的数字相加得到目标数字。 -思路:遍历一个数字,判断另一个数是否存在 -难点:1 如何降低时间复杂度 Wri...

A Rule of Divisibility by 13

20180928_Codewars_thirt

A Rule of Divisibility by 13 Codewars Kata 20√ Description Link: thirt -简述:本题给定10的次方数被13整除的余数列表1, 10, 9, 12, 3, 4,是一个循环数列,求任意多位数被13整除的remainder。 -思路:各位数字和余数列表分别相乘,若相加结果等于该数字,则为remainder,若不等则继续调用函数...

Simple fraction to mixed number converter

20180927_Codewars_mixed_fraction

Simple fraction to mixed number converter Codewars Kata 19√ Description Link: mixed_fraction -简述:本题旨在设计一个函数,将假分数转换为带分数的形式。 -思路:考虑多种正负数的情况,先求出带分数前面的数字。 -难点:1 如何简化代码 Task Given a string representin...

Tank Truck

20180926_Codewars_tankvol

Tank Truck Codewars Kata 18√ Description Link: tankvol -简述:本题假设有一个油罐车,罐内剩余一些液体,给定液体高度、罐的横截面直径和罐的体积,求剩余液体的体积? -思路:数学方法直接求 -难点:无 To introduce the problem think to my neighbor who drives a tanker tr...

Common Denominators

20180925_Codewars_convertFracts

Common Denominators Codewars Kata 17√ Description Link: convertFracts -简述:本题以列表形式给定一些分数的分子和分母组合值,要求将各分数转换为分母相等的形式。 -思路:求出所有分母的最小公倍数。 -难点:1 模块导入和列表推导式表达。 You will have a list of rationals in the f...

Help the bookseller !

20180924_Codewars_stock_list

Help the bookseller ! Codewars Kata 16√ Description Link: stock_list A bookseller has lots of books classified in 26 categories labeled A, B, … Z. Each book has a code c of 3, 4, 5 or more capital...

String incrementer

20180923_Codewars_increment_string

String incrementer Codewars Kata 15√ Description Link: increment_string -简述:本题给定一个字符串,若以数字结尾,则将该数字加1,若不以数字结尾,则在字符串最后加上’1’。 -思路:我的方法是提取数字之后再提取最后一个数字单独加1求解,given solution的解法是数字整体加1,运用zfill()函数使字符串长度...