title: Break a string in two and match both elements to a sequence of values
body: <h3>The Problem</h3>
  <p>I have a database in which a table contains cryptocurrency metadata, such as its ticker. For the sake of this problem, let's say it encompasses:</p>
  <pre class="lang-py prettyprint-override"><code>meta = ['BTC', 'LTC', 'ETH', 'BNB', 'USDT', 'BUSD', 'ATOM', 'SC', '0X', 'WAVES']
  </code></pre>
  <p>Tickers come with several different string lengths, and when they are shown isolated, it's easy to join strings back from a dataset to get their ids stored in my database.</p>
  <p>However, when importing a transaction history from an exchange, tickers come in pairs, such as:</p>
  <pre class="lang-py prettyprint-override"><code>thist = ['BTCUSDT', 'SCUSDT', 'SCBTC', 'ATOMBTC', 'WAVESBTC', 'WAVESUSDT']
  </code></pre>
  <p>One could set an arbitrary position (i.e., the middle of the string) as to separate each &quot;half&quot; of the pair, but it would fail whenever the lengths of each element differ by 2 or more (e.g., WAVESBTC and 0XUSDT would never work in this case).</p>
  <hr />
  <h3>The desired output</h3>
  <p>I have implemented a way to &quot;break&quot; a pair string into all possible combinations and output the matching combinations against a sequence <code>seq</code>:</p>
  <pre class="lang-py prettyprint-override"><code>def check_string(string, seq):
      ll = []
  
      for i in range(len(string)):
          if i &gt; 0:
              t = (string[:i], string[i:])
              ll.append(t)
  
      return [i for i in ll if all(x in seq for x in i)]
  </code></pre>
  <p>However, I'm looking for ways to improve this function so it doesn't rely on iterating the string and appending a list. <code>itertools</code> comes to mind with <code>combinations</code>, but its pure implementation would only generate combinations of single characters, not differently-sized slices of a string. Any ideas?</p>
  <hr />
  <p><strong>Obs:</strong> evidently the problem is limited to having unique tickers in the database, which does not happen in the real world given the multitude of cryptos out there. But for this problem I'm more interested in implementing an optimal way to get a &quot;matching&quot; combination rather than be 100% accurate (given that string-joining is not advised to begin with anyway).</p>