博客
关于我
codewars练习(javascript)-2021/1/28
阅读量:738 次
发布时间:2019-03-22

本文共 1822 字,大约阅读时间需要 6 分钟。

文章目录

codewars-js练习

2021/1/28

github 地址

【1】<7kyu>【Simple Fun #176: Reverse Letter】

Given a string str, reverse it omitting all non-alphabetic characters.

example

For str = "krishan", the output should be "nahsirk".For str = "ultr53o?n", the output should be "nortlu".

solution

【2】<7kyu>【Find the middle element】

As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements.

The input to the function will be an array of three distinct numbers (Haskell: a tuple).

您需要创建一个函数,当提供三元组时,返回位于其他两个元素之间的数值元素的索引。函数的输入将是一个由三个不同数字组成的数组(Haskell:一个元组)。

example

gimme([2, 3, 1]) // 0 -> 2 is the number that fits between 1 and 3 and the index of 2 in the input array is 0.gimme([5, 10, 14]) // 1 -> 10 is the number that fits between 5 and 14 and the index of 10 in the input array is 1.

solution

【3】<7kyu>【Vowel Count】

Return the number (count) of vowels in the given string.

We will consider a, e, i, o, u as vowels for this Kata (but not y).

The input string will only consist of lower case letters and/or spaces.

返回给定字符串中元音的数量(count)。输入只包含小写字母或空格

example

getCount("abracadabra")// 5

solution

【4】<7kyu>【Alternate capitalization】

Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even.

给定一个字符串,将占用偶数索引和奇数索引的字母分别大写,并返回如下所示。索引0将被认为是偶数。

example

capitalize("abcdef")// ['AbCdEf', 'aBcDeF']

solution

【5】<7kyu>【Form The Minimum】

Given a list of digits, return the smallest number that could be formed from these digits, using the digits only once (ignore duplicates).

给定一个数字列表,返回可以由这些数字组成的最小数字,只使用这些数字一次(忽略重复)。

example

minValue ([1, 3, 1])  // return (13)minValue([5, 7, 5, 9, 7])  // return (579)

solution

以上为自己思路供大家参考,可能有更优的思路。

转载地址:http://uvdwk.baihongyu.com/

你可能感兴趣的文章
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>
mysql cmake 报错,MySQL云服务器应用及cmake报错解决办法
查看>>
Multiple websites on single instance of IIS
查看>>
mysql CONCAT()函数拼接有NULL
查看>>
multiprocessing.Manager 嵌套共享对象不适用于队列
查看>>
multiprocessing.pool.map 和带有两个参数的函数
查看>>
MYSQL CONCAT函数
查看>>
multiprocessing.Pool:map_async 和 imap 有什么区别?
查看>>
MySQL Connector/Net 句柄泄露
查看>>
multiprocessor(中)
查看>>
mysql CPU使用率过高的一次处理经历
查看>>