Permutation in String

There are 3,628,800 permutations of a 10-character string. Let us try checking all of them.

The problem: given two strings s1 and s2, check if any permutation of s1 is a substring of s2. The brute-force instinct is to generate every permutation of s1 and search for each one. How bad can that get?

Let us watch it fail. Then we will find an approach so much faster that the two are not even in the same universe.

The Absurdity

For s1 = "abcdefghij" (10 characters), the brute force generates every permutation and searches s2 for each one. Watch the counter climb.

Permutations checked:0/ 3,628,800

If you tried every permutation of a 10-character string, would you finish before your coffee gets cold?