Are you ready to meet the Elite-Four?

Python 2, 68 bytes

One of the few cases where itertools is useful.

lambda b,a:s(b)in map(s,product(*a))
s=sorted
from itertools import*

Try it online!


Python 2, 70 bytes

f=lambda s,l:l and any(f(s.replace(x,'',1),l[1:])for x in l[0])or''==s

Try it online!

Tries every possible character from each list entry in turn, removing it from the target string s if present, and checking if we end up with the empty string. The s.replace(x,'',1) removes at most one copy of x in the string s.

An annoying issue is that in the base case where l==[], we get an error when we try to read l[0] even if the result doesn't matter, making it hard to cut the l and. It "almost" works to save a byte as below, but we get an error when l becomes empty because the l[0] is evaluated before the if l is tested and fails.

f=lambda s,l:s==''or any(f(s.replace(x,'',1),l[1:])for x in l[0]if l)

Try it online!

69 bytes

f=lambda s,l:any(f(s.replace(x,'',1),l[1:]+[[]])for x in l[0])or''==s

Try it online!

Pad l to the right with empty lists.

69 bytes

f=lambda s,h,*t:t and any(f(s.replace(x,'',1),*t)for x in h)or s in h

Try it online!

Takes input as the target string, followed by a splatted list of lists.


69 bytes

f=lambda s,l:any(f(s.replace(x,'',1),l[x in l[0]:])for x in s)or[]==l

Try it online!

A "dual" method based on ovs' solution, iterating over characters in the target string and removing from the list.


Haskell, 54 bytes

import Data.List
(.permutations).any.flip elem.mapM id

Try it online!

Without imports, 85 bytes

x#[]=[[x]]
x#(a:b)=(x:a:b):map(a:)(x#b)
(.foldr((=<<).(#))[[]]).any.flip elem.mapM id

Try it online!

Tags:

Code Golf