博客
关于我
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 /*! 50100 ... */ 条件编译
查看>>
mudbox卸载/完美解决安装失败/如何彻底卸载清除干净mudbox各种残留注册表和文件的方法...
查看>>
mysql 1264_关于mysql 出现 1264 Out of range value for column 错误的解决办法
查看>>
mysql 1593_Linux高可用(HA)之MySQL主从复制中出现1593错误码的低级错误
查看>>
mysql 5.6 修改端口_mysql5.6.24怎么修改端口号
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
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
查看>>