博客
关于我
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 报错:Duplicate entry 'xxx' for key 'UNIQ_XXXX'
查看>>
Mysql 拼接多个字段作为查询条件查询方法
查看>>
mysql 排序id_mysql如何按特定id排序
查看>>
Mysql 提示:Communication link failure
查看>>
mysql 插入是否成功_PDO mysql:如何知道插入是否成功
查看>>
Mysql 数据库InnoDB存储引擎中主要组件的刷新清理条件:脏页、RedoLog重做日志、Insert Buffer或ChangeBuffer、Undo Log
查看>>
mysql 数据库中 count(*),count(1),count(列名)区别和效率问题
查看>>
mysql 数据库备份及ibdata1的瘦身
查看>>
MySQL 数据库备份种类以及常用备份工具汇总
查看>>
mysql 数据库存储引擎怎么选择?快来看看性能测试吧
查看>>
MySQL 数据库操作指南:学习如何使用 Python 进行增删改查操作
查看>>
MySQL 数据库的高可用性分析
查看>>
MySQL 数据库设计总结
查看>>
Mysql 数据库重置ID排序
查看>>
Mysql 数据类型一日期
查看>>
MySQL 数据类型和属性
查看>>
mysql 敲错命令 想取消怎么办?
查看>>
Mysql 整形列的字节与存储范围
查看>>
mysql 断电数据损坏,无法启动
查看>>
MySQL 日期时间类型的选择
查看>>