给定两个序列A和B,如何生成可以从A中删除B的所有可能方式的列表?
例如,在JavaScript中,如果我有一个函数removeSubSeq
接受两个我想要的数组参数,它将按如下方式工作:
removeSubSeq([1,2,1,3,1,4,4], [1,4,4])
会返回,[ [2,1,3,1], [1,2,3,1], [1,2,1,3] ]
因为最后的4s会匹配,并且有1个匹配的可能位置
removeSubSeq([8,6,4,4], [6,4,8])
会返回,[]
因为第二个参数实际上不是一个子序列
removeSubSeq([1,1,2], [1])
会返回,[ [1,2], [1,2] ]
因为有两种方法可以删除1,即使它会导致重复
我试图确定有多少种不同的方法可以从序列中删除一组值,保留原始序列的顺序(稳定),并确保从原始序列中只删除1个实例值.例如,如果我有
[1,2,1,3,1,4,4]
,我想删除[1,4,4]
我得到的组合将是:
[1,2,1,3,1,4,4] \ [1,4,4] = [ [2,1,3,1], [1,2,3,1], [1,2,1,3] ]
要么
[1,2,1,3,1,4,4] \ [1,1] = [ [2,3,1,4,4], [1,2,3,4,4], [2,1,3,4,4] ]
我有javascript代码我写的所有数组值的组合没有删除和删除部分似乎应该很容易但我没有看到算法需要多次可能删除多个值.
我正在尝试组织我的项目以使其更易于维护.我有大量的html模板,我被迫将它们全部放在公共目录中.我真的很想像这样组织它
public directory
views
index.html
register.html
terms.html
privacy.html
support.html
stylesheets
styles.css
scripts
script.js
authentication.js
Run Code Online (Sandbox Code Playgroud)
但它看起来像这样
public
index.html
register.html
terms.html
privacy.html
support.html
script.js
authentication.js
styles.css
Run Code Online (Sandbox Code Playgroud)
这是我的firebase.json
档案
{
"firebase": "funmathgame",
"public": "mathgame",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
Run Code Online (Sandbox Code Playgroud)
这是我收到的错误消息
网页未找到
该文件不存在,并且
index.html
在当前目录或404.html
根目录中找不到该文件.我为什么看到这个?
您可能已为应用程序部署了错误的目录.检查
firebase.json
并确保公共目录指向包含index.html
文件的目录.您还可以
404.html
在站点的根目录中添加a ,以使用自定义错误页面替换此页面.
第一个结构更好,因为它分隔代码.每当我在文本编辑器中运行文件时,此结构都有效.但是,每当我部署到firebase时它都不起作用.
举个例子,这就是我引用样式表的方法
<head>
<title>Frequently Asked Questions</title>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css'>
</link>
<link rel='stylesheet' href='../stylesheets/styles.css'></link>
Run Code Online (Sandbox Code Playgroud)
在上面的目录结构中,我在public/views
目录中.我..
用来将一个目录移回公共目录,然后转发到stylesheets目录.但是,这里我的index.html
文件不在公共目录中,而是在public/views
目录中. …
我很难通过XAML尝试将我的属性List绑定到我的组合框中.
public List<string> MyProperty { get; set; }
Run Code Online (Sandbox Code Playgroud)
以下XAML绑定不起作用:
<ComboBox Name="cboDomainNames" ItemsSource="{Binding Path=MyProperty}"/>
Run Code Online (Sandbox Code Playgroud)
但是以下任务:
cboDomainNames.ItemsSource = MyProperty;
Run Code Online (Sandbox Code Playgroud)
工作得很好.我在这里缺少什么?
我正在使用Select2版本4.0.0.
如果我的结果包含多个单词,并且用户输入其中一个单词,我想显示按输入单词在结果中的位置排序的结果.
例如,用户输入"apple",我的结果是:
然后"apple banana orange"应首先出现在select2结果列表中,因为这是"apple"最早出现在结果中的结果.我不太关心过去的顺序.
我可以覆盖或配置什么来获得这样的东西?它似乎matcher
不处理排序,并且sorter
不包含查询数据.
在以前的Jison版本中,可以使用类似Flex的功能,允许在词法分析器和解析器上下文中定义变量,例如:
%{
var chars = 0;
var words = 0;
var lines = 0;
%}
%lex
%options flex
%%
\s
[^ \t\n\r\f\v]+ { words++; chars+= yytext.length; }
. { chars++; }
\n { chars++; lines++ }
/lex
%%
E : { console.log(lines + "\t" + words + "\t" + chars) ; };
Run Code Online (Sandbox Code Playgroud)
参考: Flex喜欢的功能?
虽然,在最新版本的Jison中,这是无效的.chars
,words
并且lines
无法从解析器上下文到达,生成错误.
在搜索有关新版本的更多信息时,我发现应该可以通过在解析器的上下文中定义输出%{ ... %}
,但它不起作用,尽管它用于多行语句.我正在生成从源代码到目标语言的代码,我将对这些代码进行美化,应用正确的缩进,由作用域控制并直接从解析器生成,而不构建AST.
全球定义目前如何在Jison中运作?
我正在尝试使用grunt buildcontrol首次部署我继承到heroku的项目.虽然我能够构建和部署,但在运行时我收到错误:
ENOENT:没有这样的文件或目录,打开'ssl/keys/server.key'
检查dist目录,确实没有ssl目录.因此,我将它添加到/ dist无济于事.认为/ dist/server /中的app.js可能限定在该目录范围内,我在那里复制了ssl目录 - 同样的问题.在/dist/server/app.js里面:
var options = {
key: fs.readFileSync('ssl/keys/server.key'),
cert: fs.readFileSync('ssl/keys/server.crt')
};
// Setup server
var app = express();
var server = require('https').createServer(options, app);
Run Code Online (Sandbox Code Playgroud)
如果不在服务器文件夹中,它将在哪里寻找ssl目录?
在我的Spring项目中,我将注销目标URL设置为"/ login?logout"以显示登录页面,并显示消息"您现在已注销".
在Spring Security配置中,我这样做了:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/error").permitAll()
.anyRequest().fullyAuthenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.successHandler(loginSuccessHandler)
.failureUrl("/login?error")
.and()
.httpBasic()
.and()
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.permitAll()
.logoutSuccessHandler(logoutSuccessHandler);
}
Run Code Online (Sandbox Code Playgroud)
和logoutSuccessHandler:
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
if (authentication != null) {
Log.debug(authentication.getName() + " LOGOUT !!");
}
setDefaultTargetUrl("/login?logout");
super.onLogoutSuccess(request, response, authentication);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试注销时,我到达页面"/ login"(没有?logout).我不明白为什么它会在这个页面上重定向我.
我认为该应用程序试图将我重定向到"/ login?logout",但由于我不再连接,Spring安全性要求我再次登录.
当我在登录时尝试访问"/ login?logout"页面时,它会显示正常页面.
我通过添加以下内容找到了解决此问题的方法:
.authorizeRequests()
.antMatchers("/error","/login").permitAll()
Run Code Online (Sandbox Code Playgroud)
为什么不loginPage("/login").permitAll()
这样做?我做错什么了吗?
我想创建一个非常简单的自定义原子包,我在其中突出显示基于正则表达式的特定单词.我正在处理处理大量ip地址的配置文件.我想将IP地址1.1.1.1的颜色设为红色,例如0.0.0.0蓝色......
创建包这么简单,这就是我所做的:
创建文件:
C:\Users\MyUsername\.atom\packages\MyPackage\package.json
{
"name": "language-conf",
"version": "0.0.1",
"description": "Syntax highlighting for configuration files",
"engines": {
"atom": "*"
}
}
Run Code Online (Sandbox Code Playgroud)
AND文件:
C:\Users\MyUsername\.atom\packages\MyPackage\grammars\rules.cson
'scopeName': 'source.conf'
'name': 'CONF'
'fileTypes': ['CONF']
'patterns': [
{
'match': '1\.1\.1\.1'
'name': 'constant.numeric.integer.hexadecimal.python'
},
{
'match': '0\.0\.0\.0'
'name': 'constant.numeric.integer.hexadecimal.python'
}
]
Run Code Online (Sandbox Code Playgroud)
当我打开配置文件时,它的外观如下:
注意ips是如何格式化的,这很棒!我怎样才能为不同的ips选择颜色?所有的ips都是黄色的.如果不是name属性,那么就会有一个颜色属性.
总之,我想设置这个例子的样式:
http://blog.gaku.net/create-a-custom-syntax-highlighting-with-atom-editor/
在该链接中,它没有向您展示如何将不同的颜色/样式放置到不同的规则.
我在spring-boot中创建了一个Web应用程序.我正在使用testNG为我的业务层编写单元测试.
我创建了Application类
@SpringBootApplication
public class TestApplication
{
public static void main(String[] args)
{
SpringApplication.run(TestApplication.class, args);
}
@Bean
Mapper mapper()
{
List<String> mappingFiles = new ArrayList<String>();
mappingFiles.add("dozer-mappings.xml");
return new DozerBeanMapper(mappingFiles);
}
}
Run Code Online (Sandbox Code Playgroud)
我的测试类看起来像
@ContextConfiguration(classes = { TestApplication.class })
public class CommissionRuleServiceTest extends AbstractTestNGSpringContextTests
{
@InjectMocks
@Autowired
MyService
@Mock
MyDAO;
@BeforeMethod
public void initMock()
{
MockitoAnnotations.initMocks(this);
}
@Test(dataProvider = "....")
......
......
}
Run Code Online (Sandbox Code Playgroud)
当我运行项目时,它会显示休息登录控制台,只需几次小测试就需要20.00秒.日志中的一些陈述是,
DEBUG oscisPathMatchingResourcePatternResolver - 搜索目录DEBUG oscaConfigurationClassPostProcessor DEBUG oscaClassPathBeanDefinitionScanner DEBUG oscisPathMatchingResourcePatternResolver DEBUG osbfsDefaultListableBeanFactory DEBUG oacbconverters.ArrayConverter DEBUG org.dozer.loader.xml.XMLParser DEBUG org.hibernate.cfg.SettingsFactory DEBUG …
javascript ×4
algorithm ×2
css ×2
java ×2
jquery ×2
atom-editor ×1
c# ×1
combinations ×1
combobox ×1
data-binding ×1
firebase ×1
flex-lexer ×1
heroku ×1
html ×1
jison ×1
node.js ×1
packages ×1
performance ×1
sequence ×1
set-theory ×1
spring ×1
spring-boot ×1
ssl ×1
testng ×1
wpf ×1
xaml ×1