C ++ (Bcc), 287 byte
#include<algorithm.h>
f(a,b)char*a,**b;{int i,j,k,v,p[256];if(!a||!b||!*b)return-1;for(v=0;v<256&&b[v];++v)p[v]=v;if(v>=256)return-1;la:for(i=0,j=0;j<v&&a[i];){for(k=0;b[p[j]][k]==a[i]&&a[i];++i,++k);j=b[p[j]][k]?(i-=k),j+1:0;}if(a[i]&&next_permutation(p,p+v)) goto la;return i&&!a[i];}
karena saya tidak menulis atau menggunakan terlalu banyak next_permutation () saya tidak tahu apakah semua baik-baik saja. Saya tidak tahu 100% apakah itu solusi yang terlalu mungkin ini di luar kualitas ... Satu daftar string di sini adalah satu array pointer ke char; NULL diakhiri Algo itu mudah, ada satu algo yang linierinya coba jika semua string dalam daftar sesuai dengan argumen "a" string ada satu algo lain yang mengubah indeks daftar string sehingga mencoba semua kemungkinan kombinasi.
ungolf itu, tes kode dan hasilnya di sini
#include<stdio.h>
g(a,b)char*a,**b;
{int i,j,k,v,p[256];
if(!a||!b||!*b) return -1;
for(v=0;v<256&&b[v];++v) p[v]=v;
if(v>=256) return -1; // one array of len >256 is too much
la:
for(i=0,j=0;j<v&&a[i];)
{for(k=0;b[p[j]][k]==a[i]&&a[i];++i,++k);
j=b[p[j]][k]?(i-=k),j+1:0;
}
if(a[i]&&next_permutation(p,p+v)) goto la;
return i&&!a[i];
}
#define F for
#define P printf
test(char* a, char** b)
{int i;
P("f(\"%s\",[",a);
F(i=0;b[i];++i)
P("\"%s\"%s", b[i], b[i+1]?", ":"");
P("])=%d\n", f(a,b));
}
main()
{char *a1="Hello, world!", *b1[]={"l","He", "o, worl", "d!", 0};//1
char *a2="la lal al ", *b2[]={"la", " l", "al ", 0};//1
char *a3="this is a string", *b3[]={"this should return falsy", 0};//0
char *a4="thi is a string", *b4[]={"this", "i i", " a", " string", 0};//0
char *a5="aaaaa", *b5[]={"aa", 0};//0
char *a6="foo bar foobar", *b6[]={"foo","bar"," ","spam", 0};//1
char *a7="ababab", *b7[]={"a","ba","ab", 0};//1
char *a8="", *b8[]={"This return 0 even if has to return 1", 0};//0
char *a9="ababc", *b9[]={"a","abc", "b", 0};//1
test(a1,b1);test(a2,b2);test(a3,b3);test(a4,b4);test(a5,b5);test(a6,b6);
test(a7,b7);test(a8,b8);test(a9,b9);
}
f("Hello, world!",["l", "He", "o, worl", "d!"])=1
f("la lal al ",["la", " l", "al "])=1
f("this is a string",["this should return falsy"])=0
f("thi is a string",["this", "i i", " a", " string"])=0
f("aaaaa",["aa"])=0
f("foo bar foobar",["foo", "bar", " ", "spam"])=1
f("ababab",["a", "ba", "ab"])=1
f("",["This return 0 even if has to return 1"])=0
f("ababc",["a", "abc", "b"])=1
ini akan dikompilasi dalam kompiler gcc C ++
#include<algorithm>
int f(char*a,char**b){int i,j,k,v,p[256];if(!a||!b||!*b)return -1;for(v=0;v<256&&b[v];++v)p[v]=v;if(v>=256)return -1;la:;for(i=0,j=0;j<v&&a[i];){for(k=0;b[p[j]][k]==a[i]&&a[i];++i,++k);j=b[p[j]][k]?(i-=k),j+1:0;}if(a[i]&&std::next_permutation(p,p+v))goto la;return i&&!a[i];}