-
Notifications
You must be signed in to change notification settings - Fork 0
/
kyu6_which_are_in.py
31 lines (23 loc) · 965 Bytes
/
kyu6_which_are_in.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are
substrings of strings of a2;
Example 1:
a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns ["arp", "live", "strong"]
Example 2:
a1 = ["tarp", "mice", "bull"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns []
Notes:
Arrays are written in "general" notation. See "Your Test Cases" for examples in your language;
In Shell bash a1 and a2 are strings. The return is a string where words are separated by commas;
Beware: In some languages r must be without duplicates;
https://www.codewars.com/kata/550554fd08b86f84fe000a58
"""
def in_array(array1, array2):
def __check(string, array):
for item in array:
if string in item:
return True
return sorted(set([a for a in array1 if __check(a, array2)]))