您将获得2个字符串列表 - A和B.找到匹配A中所有字符串的最短正则表达式,而不是B中的所有字符串.请注意,此正则表达式可以匹配/不匹配不在A中而不在B中的其他字符串.简单,我们可以假设我们的字母大小只有2个字符 - 0和1.也只允许这些运算符:
* - 0或更多
?- 0或1
+ - 1或更多
() - 括号
为简单起见,不允许使用正则表达式运算符.我不知道是否允许或运算符(|)会简化问题.A和B的路线没有共同的元素.这里有些例子:
A=[00,01,10]
B=[11]
answer = 1*0+1*
Run Code Online (Sandbox Code Playgroud)
A=[00,01,11]
B=[10]
answer = 0*1*
Run Code Online (Sandbox Code Playgroud) 我在哪里可以找到解决方案的良好练习python问题?
我正在寻找具有编码目的的详细实践问题.
我使用malloc时遇到问题.
我有一个叫做jacobi_gpuwich 的函数被多次调用:
int main(int argc, char* argv[]){
/* ... */
int totalrot=0;
while(nrot>0){
iter++;
nrot=jacobi_gpu(a,q, tol, dimmat);
totalrot+=nrot;
printf("iter =%3d nrot=%3d\n",iter, nrot);
}
/* ... */
}
Run Code Online (Sandbox Code Playgroud)
参数a,q,tol和dimmat被正确初始化.A和Q是2平方矩阵,dimmat是它们的维度.
这是我的代码:
int jacobi_gpu(double A[], double Q[], double tol, long int dim){
int nrot, p, q, k, tid;
double c, s;
double *mc, *vc;
printf("jacobi begins \n");
mc = (double *)malloc(2 * dim * sizeof(double));
vc = (double *)malloc(2 * dim * sizeof(double));
if( mc == NULL || vc == …Run Code Online (Sandbox Code Playgroud) def simple_decorator(f):
def tmp(*args, **kwargs):
res = f(*args, **kwargs)
return res
return tmp
@simple_decorator
class FirstClass():
pass
@simple_decorator
class SecondClass(FirstClass):
pass
Run Code Online (Sandbox Code Playgroud)
我有错误:
File "1.py", line 16, in <module>
class SecondClass(FirstClass):
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
Run Code Online (Sandbox Code Playgroud)
为什么?