Strings Problem Set 9
String.25Repeat End
Given a string and an int N, return a string made of N repetitions of the last N characters of the string. You may assume that N is between 0 and the length of the string, inclusive.
- repeatEnd("Hello", 3) . "llollollo"
- repeatEnd("Hello", 2) . "lolo"
- repeatEnd("Hello", 1) . "o"
String.26Repeat Front
Given a string and an int N, return a string made of the first N characters of the string, followed by the first N-1 characters of the string, and so on. You may assume that N is between 0 and the length of the string, inclusive (i.e. N>=0 and N <= str.length()).
- repeatFront("Chocolate", 4) . "ChocChoChC"
- repeatFront("Chocolate", 3) . "ChoChC"
- repeatFront("Ice Cream", 2) . "IcI"
String.27Repeat Separator
Given two strings, word and a separator, return a big string made of count occurences of the word, separated by the separator string.
- repeatSeparator("Word", "X", 3) . "WordXWordXWord"
- repeatSeparator("This", "And", 2) . "ThisAndThis"
- repeatSeparator("This", "And", 1) . "This"