# Challenge

A simple challenge: given two or more strings, output all of the substrings that are in each string.

# Rules

• Input is always a comma separated list of strings
• Strings should be outputted from longest to shortest length without duplicates
• Strings should preserve whitespace

# Examples

Input: aaa,aa
Output:
aa
a

Input: ababa,aba
Output:
aba
ab
ba
a
b

Input: Hello\, world!, Hello world!
Output:
world!
world!
world
worl
world
orld!
Hello
orld
rld!
ello
wor
Hell
worl
ell
rld
wo
ld!
llo
wor
orl
Hel
d!
ll
w
lo
rl
wo
or
He
el
ld
o
l
r
H
e
d
!
w


## closed as unclear what you're asking by Sriotchilism O'Zaic, xnor, Chris, Martin EnderApr 18 '18 at 7:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• You do not have examples of more than two strings as input. – Chas Brown Apr 18 '18 at 2:43
• In addition why is the input format so strict? The input format you require seems overly stringent. If I were to solve this the majority of my code would be an input parser. – Sriotchilism O'Zaic Apr 18 '18 at 2:44
• To pile on with What Wizard, \, is a pretty non-standard way of saying "don't split on this comma". Why not just take as input a list of strings? – Chas Brown Apr 18 '18 at 2:48
• Also - welcome to PPCG! I didn't notice that this is your first post, and didn't mean to bite your head off! :) You might want to check out the sandbox where people often post their questions first so they can get helpful feedback including the usual sorts of expectations that people have for questions/challenges. – Chas Brown Apr 18 '18 at 2:59
• Note that cumbersome I/O formats are discouraged. If you really want to enforce that, you should make it more explicit in the post (and the reason why you enforce it). – user202729 Apr 18 '18 at 7:52

# 05AB1E, 9 bytes

€Œ.»ÃÙéR»


Try it online!

Explanation

€Œ         # get the substrings of each
.»Ã      # reduce by intersection
Ù     # remove duplicates
é    # sort by length
R   # reverse
»  # join on newline


# Jelly, 6 bytes

Ẇ€f/QṚ


Try it online!

Ẇ€f/QṚ  Main Link
€      For each string
Ẇ       Get all substrings
/    Reduce this list of lists by
f     Filter (intersection)
Q   Remove duplicates
Ṛ  Reverse


# Pyth, 8

_{@Fm.:d


## Explanation

        Q  # Implicit input list of 2 strings
m.:d   # get lists of all substrings of each input string
@F       # intersection
{         # deduplicate
_          # reverse

• The comment should probably read "Implicit input list of strings", since it can be more than two strings. – Nit Apr 18 '18 at 7:58