Skip to content

Commit 17d06b8

Browse files
committed
feat: add hints
1 parent df69a65 commit 17d06b8

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/commands/show.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ function showProblem(problem, argv) {
175175

176176
log.info();
177177
log.info(problem.desc);
178+
179+
for (let i = 0; i < problem.hints.length; i++) {
180+
log.info();
181+
log.info('<details>');
182+
log.info(`\t<summary><strong>Hint ${i + 1}:</strong></summary>`);
183+
log.info(`\t<p>${problem.hints[i]}</p>`);
184+
log.info('</details>')
185+
}
178186
}
179187

180188
cmd.handler = function(argv) {

lib/plugins/leetcode.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ plugin.getProblem = function(problem, needTranslation, cb) {
140140
' enableRunCode',
141141
' metaData',
142142
' translatedContent',
143+
' hints',
143144
' }',
144145
'}'
145146
].join('\n'),
@@ -167,6 +168,7 @@ plugin.getProblem = function(problem, needTranslation, cb) {
167168
problem.testcase = q.sampleTestCase;
168169
problem.testable = q.enableRunCode;
169170
problem.templateMeta = JSON.parse(q.metaData);
171+
problem.hints = q.hints;
170172
// @si-yao: seems below property is never used.
171173
// problem.discuss = q.discussCategoryId;
172174

templates/detailed.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ ${comment.line} Total Submissions: ${totalSubmit}
1414
${comment.line} Testcase Example: ${testcase}
1515
${comment.line}
1616
{{ desc.forEach(function(x) { }}${comment.line} ${x}
17+
{{ }) }}{{ hints.forEach(function(hint, index) { }}${comment.line}
18+
${comment.line} Hint ${index + 1}:
19+
${comment.line}
20+
${comment.line} ${hint}
1721
{{ }) }}${comment.end}
1822

1923
${comment.singleLine} @lc code=start

0 commit comments

Comments
 (0)