Hello readers! It’s really important for me to continue my practice and learning. Every week, I block off 30 minutes, set a timer and choose a challenge from codewars. This helps me keep my skills sharp, see how other devs all over the planet would solve these problems, and take some leisure time to problem solve and be creative. Being able to see other solutions expands my mind for solving future problems in a clever and efficient way. Today, the problem set focuses on Python.
Complete the solution so that the function will break up camel casing, using a space between words.
"camelCasing" => "camel Casing" "identifier" => "identifier" "" => ""
def solution(s): # join the result of recurStrEval return ' '.join(recurStrEval(s, '', )) def recurStrEval(str, temp_str, str_arr): # if str is blank, append whats left and return if not str: str_arr.append(temp_str) return str_arr # if first letter of str is upper, append the temp str to array and then restart cycle if str.isupper(): str_arr.append(temp_str) temp_str = str return recurStrEval(str[1:], temp_str, str_arr) # if str is lower, concatenate to the existing string if str.islower(): temp_str += str return recurStrEval(str[1:], temp_str, str_arr)
All solutions are also now on my GitHub profile if you want to check out all of the coding challenges I’ve completed so far!
All credit to problem sets goes to codewars