본문 바로가기

전체 글54

[Codewars] Tribonacci Sequence Q. Well met with Fibonacci bigger brother, AKA Tribonacci. As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :( So, if we are to start our Tribonacci sequence with [1, 1, 1] as a starting i.. 2024. 6. 11.
[Codewars] Counting Duplicates Q. Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits. Example."abcde" -> 0 # no characters repeats more than once"aabbcde" -> 2 # 'a' and 'b'"aabBcde" -> 2 # 'a' occurs twice and .. 2024. 6. 10.
[Codewars] Exes and Ohs Q. Check to see if a string has the same amount of 'x's and 'o's. The method must return a boolean and be case insensitive. The string can contain any char. Examples input/output:XO("ooxx") => trueXO("xooxx") => falseXO("ooxXm") => trueXO("zpzpzpp") => true // when no 'x' and 'o' is present should return trueXO("zzoo") => false S. 간단하게 쓰려고 forEach와 삼항연산자를 이용했는데 가독성면에서는 좋지 않은 것 같다bool XO(String s.. 2024. 6. 10.
[Codewars] Create Phone Number Q. Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. Example.createPhoneNumber([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) // => returns "(123) 456-7890" The returned format must be correct in order to complete this challenge.Don't forget the space after the closing parentheses! S. 리스트의 서브리스트를 구한 다음 문자열로 바꾸어 문자열 보간법.. 2024. 6. 9.