Given a string, return the string made of its first two chars, so the string "Hello" yields "He". If the string is shorter than length 2,...
Search Results
Searching for: String
Individual Exercises
Return true
if the string "cat" and "dog" appear the same number of times in the given string.
Return true if the given string contains a "bob" string, but where the middle 'o' character can be any character.
Given two strings, word
and a separator sep
, return a big string made of count
occurrences of the word
, separated by the separator...
Given a string, count the number of words ending in 'y' or 'z'--so the 'y' in "heavy" and the 'z' in "fez" count, but not the 'y' in...
Given a string, compute recursively a new string where all the adjacent chars are now separated by a "*". So given "hello", return...
Given a string that contains a single pair of parenthesis, compute recursively a new string containing only the parentheses and their...
Given a string and a non-empty substring sub
, compute recursively if at least n
copies of sub
appear in the string somewhere, possibly...
Given a string str
and a non-empty substring sub
, compute recursively the largest substring which both starts and ends with sub
and...
Given a string, return true
if it is a nesting of zero or more pairs of parentheses, like "(())" or "((()))". Suggestion: check the first...
Given a string, compute the number of times lowercase "hi" appears in the string. Make the countHi
be recursive.
Count recursively (no loops) the total number of "abc" and "aba" substrings that appear in the given string.
Given a string, compute recursively (no loops) a new string where all the lowercase 'x' chars have been changed to 'y' chars.
We'll say that a "pair" in a string is two instances of the same character separated by another character. So in "AxA", the A's make a...
Given a string, return a recursively "cleaned" string where adjacent chars that are the same have been reduced to a single char. So...
Given a string, compute recursively a new string where all the 'x' chars have been removed.
Given a string, compute recursively (no loops) a new string where all appearances of "pi" have been replaced by "3.14".
Write a method called listUpper()
that takes in a list of strings, and returns a list of the same length containing the same strings but...
Write a method called listSearch()
that takes in a target string and a list of other strings. This method returns a (possibly shorter)...
Write a method called listLength()
that takes in a list of strings and returns a list of their lengths as integers. You must create a new...
Given a string, return a string where for every char in the original, there are two chars.
Given a string, consider the prefix string made of the first N chars of the string. Does that prefix string appear somewhere else in the...
Given a string, compute a new string by moving the first char to come after the next two chars, so "abc" yields "bca". Repeat this...
Returns true if for every '*' (star) in the string, if there are chars both immediately before and after the star, they are the same.
Given two strings, base
and remove
, return a version of the base
string where all instances of the remove
string have been removed (not...