본문 바로가기

in10

Find the vowels We want to know the index of the vowels in a given word, for example, there are two vowels in the word super (the second and fourth letters). So given a string "super", we should return a list of [2, 4]. Some examples: Mmmm => [] Super => [2,4] Apple => [1,5] YoMama -> [1,2,4,6] NOTES Vowels in this context refers to: a e i o u y (including upper case) This is indexed from [1..n] (not zero index.. 2022. 5. 1.
Apparently-Modifying Strings Description: For every string, after every occurrence of 'and' and/or 'but', insert the substring 'apparently' directly after the occurrence(s). If input does not contain 'and' or 'but', return the same string. If a blank string, return ''. If substring 'apparently' is already directly after an 'and' and/or 'but', do not add another. (Do not add duplicates). Examples: Input 1 'It was great and I.. 2022. 4. 26.
Regex validate PIN code Description: ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. Examples (Input --> Output) Solution: 1. 인자가 숫자인지 확인한다. 2. 인자의 길이가 4 혹은 6이라면 pin을 반환한다. def validate_pin(pin): return pin.isdigit() and len(pin) in (4, 6) 2022. 4. 16.
Invert values Description: Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] invert([]) == [] You can assume that all values are integers. Do not mutate the input array/list. Solution: 1. Get the numbers in the array. 2. Change positive numbers to nega.. 2022. 3. 27.