Algorithms
Easy
2788
2881
Split Strings by Separator
split-strings-by-separator
"""
Given an array of strings words and a character separator, split each string in words by separator.

Return an array of strings containing the new strings formed after the splits, excluding empty strings.

Notes

 * separator is used to determine where the split should occur, but it is not included as part of the resulting strings.
 * A split may result in more than two strings.
 * The resulting strings must maintain the same order as they were initially given.

Example 1:

Input: words = ["one.two.three","four.five","six"], separator = "."
Output: ["one","two","three","four","five","six"]
Explanation: In this example we split as follows:

"one.two.three" splits into "one", "two", "three"
"four.five" splits into "four", "five"
"six" splits into "six"

Hence, the resulting array is ["one","two","three","four","five","six"].

Example 2:

Input: words = ["$easy$","$problem$"], separator = "$"
Output: ["easy","problem"]
Explanation: In this example we split as follows:

"$easy$" splits into "easy" (excluding empty strings)
"$problem$" splits into "problem" (excluding empty strings)

Hence, the resulting array is ["easy","problem"].

Example 3:

Input: words = ["|||"], separator = "|"
Output: []
Explanation: In this example the resulting split of "|||" will contain only empty strings, so we return an empty array [].

Constraints:

 * 1 <= words.length <= 100
 * 1 <= words[i].length <= 20
 * characters in words[i] are either lowercase English letters or characters from the string ".,|$#@" (excluding the quotes)
 * separator is a character from the string ".,|$#@" (excluding the quotes)
"""
class Solution:
    def splitWordsBySeparator(self, words: List[str], separator: str) -> List[str]:
        
Given an array of strings words and a character separator, split each string in words by separator.

Return an array of strings containing the new strings formed after the splits, excluding empty strings.

Notes

 * separator is used to determine where the split should occur, but it is not included as part of the resulting strings.
 * A split may result in more than two strings.
 * The resulting strings must maintain the same order as they were initially given.

Example 1:

Input: words = ["one.two.three","four.five","six"], separator = "."
Output: ["one","two","three","four","five","six"]
Explanation: In this example we split as follows:

"one.two.three" splits into "one", "two", "three"
"four.five" splits into "four", "five"
"six" splits into "six"

Hence, the resulting array is ["one","two","three","four","five","six"].

Example 2:

Input: words = ["$easy$","$problem$"], separator = "$"
Output: ["easy","problem"]
Explanation: In this example we split as follows:

"$easy$" splits into "easy" (excluding empty strings)
"$problem$" splits into "problem" (excluding empty strings)

Hence, the resulting array is ["easy","problem"].

Example 3:

Input: words = ["|||"], separator = "|"
Output: []
Explanation: In this example the resulting split of "|||" will contain only empty strings, so we return an empty array [].

Constraints:

 * 1 <= words.length <= 100
 * 1 <= words[i].length <= 20
 * characters in words[i] are either lowercase English letters or characters from the string ".,|$#@" (excluding the quotes)
 * separator is a character from the string ".,|$#@" (excluding the quotes)


Please complete the code below to solve above prblem:
```python
class Solution:
    def splitWordsBySeparator(self, words: List[str], separator: str) -> List[str]:
        
```

my_solution = Solution()

test_input = { "words": ["one.two.three","four.five","six"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["one","two","three","four","five","six"]

test_input = { "words": ["$easy$","$problem$"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["easy","problem"]

test_input = { "words": ["|||"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == []

test_input = { "words": ["stars.bars.$"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["stars","bars","$"]

test_input = { "words": ["###x#i@f"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["x","i@f"]

test_input = { "words": ["##q@t#"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["q@t"]

test_input = { "words": ["#,"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == [","]

test_input = { "words": ["#@"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["#"]

test_input = { "words": ["#a$f$nwgq#vw"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["#a","f","nwgq#vw"]

test_input = { "words": ["#uyddd,trxiwfv"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["#uyddd","trxiwfv"]

test_input = { "words": ["#x"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["#x"]

test_input = { "words": ["#x#,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["#x#"]

test_input = { "words": ["#|"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["|"]

test_input = { "words": ["#|a|b|##|#|#g#u|"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["#","a","b","##","#","#g#u"]

test_input = { "words": ["$$.o.$$."], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == [".o.","."]

test_input = { "words": ["$,,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["$"]

test_input = { "words": ["$j@@@"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["$j"]

test_input = { "words": [",$$"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == [","]

test_input = { "words": [",,"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == [",,"]

test_input = { "words": [",,,@@n"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["@@n"]

test_input = { "words": [",,,@o,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["@o"]

test_input = { "words": [",,,p,#r#"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["p","#r#"]

test_input = { "words": [",,."], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["."]

test_input = { "words": [",,ulxh|,u|ustg||ulo"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == [",,ulxh",",u","ustg","ulo"]

test_input = { "words": [",esplco"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == [",esplco"]

test_input = { "words": [",g#,,,#"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["g#","#"]

test_input = { "words": [",gko"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == [",gko"]

test_input = { "words": [",h,u.f"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["h","u.f"]

test_input = { "words": [",y|z|bg,"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == [",y","z","bg,"]

test_input = { "words": [".#z.###b"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == [".","z.","b"]

test_input = { "words": [".."], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == []

test_input = { "words": [".@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["@"]

test_input = { "words": [".n#.#.."], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == [".n",".",".."]

test_input = { "words": [".trs.t..cvvw.,..p"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["trs","t","cvvw",",","p"]

test_input = { "words": [".vy.$$.qw"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["vy","$$","qw"]

test_input = { "words": ["@,,"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == [",,"]

test_input = { "words": ["@..@@.s.@u@.@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["@","@@","s","@u@","@"]

test_input = { "words": ["@@..@@@.@vn@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["@@","@@@","@vn@"]

test_input = { "words": ["@@@@@@@...@@@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["@@@@@@@","@@@"]

test_input = { "words": ["@@@@@@g@@v"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["g","v"]

test_input = { "words": ["@@||@"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["@@","@"]

test_input = { "words": ["@acp.@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["@acp","@"]

test_input = { "words": ["@iw"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["@iw"]

test_input = { "words": ["@z#y@@ni"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["@z","y@@ni"]

test_input = { "words": ["aovx"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["aovx"]

test_input = { "words": ["b"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["b"]

test_input = { "words": ["b,,"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["b,,"]

test_input = { "words": ["b,s"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["b","s"]

test_input = { "words": ["bqukl,bv"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["bqukl","bv"]

test_input = { "words": ["cmypa#"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["cmypa"]

test_input = { "words": ["cq,,,,y"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["cq,,,,y"]

test_input = { "words": ["d,,,@d"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["d","@d"]

test_input = { "words": ["dgjtc"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["dgjtc"]

test_input = { "words": ["e$,$,w$,,z,,$$,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["e$","$","w$","z","$$"]

test_input = { "words": ["e,,$,$,,,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["e","$","$"]

test_input = { "words": ["edz."], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["edz."]

test_input = { "words": ["f"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["f"]

test_input = { "words": ["f."], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["f."]

test_input = { "words": ["g"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["g"]

test_input = { "words": ["g###"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["g###"]

test_input = { "words": ["g|@@@@@|"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["g|","|"]

test_input = { "words": ["h"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["h"]

test_input = { "words": ["h#"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["h"]

test_input = { "words": ["hpo"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["hpo"]

test_input = { "words": ["imq#zect"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["imq#zect"]

test_input = { "words": ["io@"], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["io@"]

test_input = { "words": ["j@..@f.v@."], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["j","..","f.v","."]

test_input = { "words": ["jxe|xfim"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["jxe","xfim"]

test_input = { "words": ["lyegjxsg"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["lyegjxsg"]

test_input = { "words": ["l|"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["l|"]

test_input = { "words": ["mm..,.j.."], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["mm",",","j"]

test_input = { "words": ["n."], "separator": "." }
assert my_solution.splitWordsBySeparator(**test_input) == ["n"]

test_input = { "words": ["no#"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["no#"]

test_input = { "words": ["nyy|"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["nyy"]

test_input = { "words": ["pfx|ons"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["pfx|ons"]

test_input = { "words": ["pl"], "separator": "#" }
assert my_solution.splitWordsBySeparator(**test_input) == ["pl"]

test_input = { "words": ["q"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["q"]

test_input = { "words": ["q"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["q"]

test_input = { "words": ["qv"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["qv"]

test_input = { "words": ["r"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["r"]

test_input = { "words": ["rxs|$mg"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["rxs|","mg"]

test_input = { "words": ["sls,l,xn"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["sls","l","xn"]

test_input = { "words": ["t@"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["t"]

test_input = { "words": ["tsklm|dhmsr"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["tsklm","dhmsr"]

test_input = { "words": ["t|@@w||"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["t","@@w"]

test_input = { "words": ["u"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["u"]

test_input = { "words": ["ufjvddie"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["ufjvddie"]

test_input = { "words": ["unvywqeuqvdq"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["unvywqeuqvdq"]

test_input = { "words": ["vt@"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["vt"]

test_input = { "words": ["w,xu#v,m,jh,"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["w","xu#v","m","jh"]

test_input = { "words": ["w|vip|"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["w","vip"]

test_input = { "words": ["xjmjh$@"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["xjmjh$"]

test_input = { "words": ["xm,tjd$"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["xm,tjd"]

test_input = { "words": ["yww"], "separator": "@" }
assert my_solution.splitWordsBySeparator(**test_input) == ["yww"]

test_input = { "words": ["z"], "separator": "$" }
assert my_solution.splitWordsBySeparator(**test_input) == ["z"]

test_input = { "words": ["z#|||###"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["z#","###"]

test_input = { "words": ["zb@"], "separator": "," }
assert my_solution.splitWordsBySeparator(**test_input) == ["zb@"]

test_input = { "words": ["|,,|,|||"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == [",,",","]

test_input = { "words": ["|,r,fg"], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == [",r,fg"]

test_input = { "words": ["|."], "separator": "|" }
assert my_solution.splitWordsBySeparator(**test_input) == ["."]