@@ -33,23 +33,27 @@ var (
33
33
languageConfigs = map [string ]LanguageConfig {
34
34
"go" : {
35
35
LeetcodeLang : "Go" ,
36
- TplFiles : []TplFile {{"code" , "solve_ %s.go" , codeStrGo }, {"test" , "solve_ %s_test.go" , testCodeStrGo }},
36
+ TplFiles : []TplFile {{"code" , "%s.%s. go" , codeStrGo }, {"test" , "%s. %s_test.go" , testCodeStrGo }},
37
37
},
38
38
"ts" : {
39
39
LeetcodeLang : "TypeScript" ,
40
- TplFiles : []TplFile {{"code" , "solve_ %s.ts" , codeStrTs }, {"test" , "solve_ %s.test.ts" , testCodeStrTs }},
40
+ TplFiles : []TplFile {{"code" , "%s.%s. ts" , codeStrTs }, {"test" , "%s. %s.test.ts" , testCodeStrTs }},
41
41
},
42
42
"js" : {
43
43
LeetcodeLang : "JavaScript" ,
44
- TplFiles : []TplFile {{"code" , "solve_ %s.js" , codeStrJs }, {"test" , "solve_ %s.test.js" , testCodeStrJs }},
44
+ TplFiles : []TplFile {{"code" , "%s.%s. js" , codeStrJs }, {"test" , "%s. %s.test.js" , testCodeStrJs }},
45
45
},
46
46
"py3" : {
47
47
LeetcodeLang : "Python3" ,
48
- TplFiles : []TplFile {{"code" , "solve_ %s.py" , codeStrPy3 }, {"test" , "test_%s .py" , testCodeStrPy3 }, {"__init__" , "__init__.py" , "" }},
48
+ TplFiles : []TplFile {{"code" , "%s.%s. py" , codeStrPy3 }, {"test" , "%s.%s_test .py" , testCodeStrPy3 }, {"__init__" , "__init__.py" , "" }},
49
49
},
50
50
"java" : {
51
51
LeetcodeLang : "Java" ,
52
- TplFiles : []TplFile {{"code" , "solve_%s.java" , codeStrJava }, {"test" , "test_%s.java" , testCodeStrJava }},
52
+ TplFiles : []TplFile {{"code" , "%s.%s.java" , codeStrJava }, {"test" , "test_%s_%s.java" , testCodeStrJava }},
53
+ },
54
+ "cpp" : {
55
+ LeetcodeLang : "C++" ,
56
+ TplFiles : []TplFile {{"code" , "%s.%s.cpp" , codeStrCpp }},
53
57
},
54
58
}
55
59
)
@@ -103,7 +107,7 @@ func Run(lc *leetcode.Leetcode, n string, lang string) {
103
107
log .Fatal (err , meta )
104
108
}
105
109
number := normalizeNumber (meta .Index )
106
- folderName := prefix + number
110
+ folderName := number + "." + meta . Slug
107
111
fp := filepath .Join (folder , folderName )
108
112
_ = os .MkdirAll (fp , 0755 )
109
113
metaf := & MetaWithFolder {
@@ -123,8 +127,8 @@ func Run(lc *leetcode.Leetcode, n string, lang string) {
123
127
124
128
for _ , tpl := range config .TplFiles {
125
129
fileName := tpl .FileName
126
- if strings .Count (tpl .FileName , "%s" ) > 0 {
127
- fileName = fmt .Sprintf (tpl .FileName , number )
130
+ if strings .Count (tpl .FileName , "%s" ) > 1 {
131
+ fileName = fmt .Sprintf (tpl .FileName , number , meta . Slug )
128
132
}
129
133
fp := filepath .Join (fp , fileName )
130
134
if ! fileExists (fp ) {
@@ -245,3 +249,26 @@ public class test_{{ printf "%04s" .Index }} {
245
249
}
246
250
`
247
251
)
252
+
253
+ var (
254
+ codeStrCpp = `#include <algorithm>
255
+ #include <unordered_map>
256
+ #include <string>
257
+ #include <vector>
258
+ #include <iostream>
259
+ #include <math.h>
260
+ using namespace std;
261
+
262
+ /**
263
+ * @index {{ .Index }}
264
+ * @title {{ .Title }}
265
+ * @difficulty {{ .Difficulty }}
266
+ * @tags {{ .TagStr }}
267
+ * @draft false
268
+ * @link {{ .Link }}
269
+ * @frontendId {{ .FrontendId }}
270
+ * @solved {{ .Solved }}
271
+ */
272
+ {{ .Code }}
273
+ `
274
+ )
0 commit comments