Underscores in Numeric Literals
긴 숫자를 선언할때 숫자사이에 언더스코어를 넣어서 가독성을 향상 시킬수 있다.
숫자 구두점처럼 3자리마다 찍을 필요는 없고 숫자와 숫자 사이에서만 유효하다.
int price = 1000000; int price =1_000_000;
Underscores in Numeric Literals
긴 숫자를 선언할때 숫자사이에 언더스코어를 넣어서 가독성을 향상 시킬수 있다.
숫자 구두점처럼 3자리마다 찍을 필요는 없고 숫자와 숫자 사이에서만 유효하다.
int price = 1000000; int price =1_000_000;
#78 Convert PascalCase string into snake_case
Complete the function/method so that it takes CamelCase string and returns the string in snake_case notation. Lowercase characters can be numbers. If method gets number, it should return string.
Examples:
// returns test_controller
toUnderscore('TestController');
// returns movies_and_books
toUnderscore('MoviesAndBooks');
// returns app7_test
toUnderscore('App7Test');
// returns "1"
toUnderscore(1);
codewars #80 Calculating Batting Average (6kyu) (0) | 2018.07.17 |
---|---|
codewars #79 Human readable duration format (4kyu) (0) | 2018.07.13 |
codewars #77 Tortoise racing (6kyu) (0) | 2018.07.11 |
codewars #76 Ones and Zeros (7kyu) (0) | 2018.07.10 |
codewars #75 Numericals of a String (6kyu) (0) | 2018.07.09 |
Two tortoises named A and B must run a race. A starts with an average speed of 720 feet per hour. Young B knows she runs faster than A, and furthermore has not finished her cabbage.
When she starts, at last, she can see that A has a 70 feet lead but B's speed is 850 feet per hour. How long will it take B to catch A?
More generally: given two speeds v1 (A's speed, integer > 0) and v2 (B's speed, integer > 0) and a lead g (integer > 0) how long will it take B to catch A?
The result will be an array [hour, min, sec] which is the time needed in hours, minutes and seconds (round down to the nearest second) or a string in some languages.
If v1 >= v2 then return nil, nothing, null, None or {-1, -1, -1} for C++, C, Go, Nim, [] for Kotlin or "-1 -1 -1".
Examples:
(form of the result depends on the language)
race(720, 850, 70) => [0, 32, 18] or "0 32 18"
race(80, 91, 37) => [3, 21, 49] or "3 21 49"
codewars #79 Human readable duration format (4kyu) (0) | 2018.07.13 |
---|---|
codewars #78 Convert PascalCase string into snake_case (5kyu) (0) | 2018.07.12 |
codewars #76 Ones and Zeros (7kyu) (0) | 2018.07.10 |
codewars #75 Numericals of a String (6kyu) (0) | 2018.07.09 |
codewars #74 CamelCase to underscore(6kyu) (0) | 2018.07.06 |