Q # Implicit input list of 2 strings m.:d # get lists of all substrings of each input string @F # intersection { # deduplicate _ # reverse
Объяснение
_{@Fm.:d
||answer||Ẇ€f/QṚ Main Link
€ For each string
Ẇ Get all substrings
/ Reduce this list of lists by
f Filter (intersection)
Q Remove duplicates
Ṛ Reverse
Ẇ€f/QṚ
||answer||€Œ # get the substrings of each
.»Ã # reduce by intersection
Ù # remove duplicates
é # sort by length
R # reverse
» # join on newline
€Œ.»ÃÙéR»