diff --git a/docs/commands.md b/docs/commands.md
index 2eda14a7..1893dbc4 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -234,7 +234,9 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g
* golang
* java
* javascript
+ * kotlin
* mysql
+ * php
* python
* python3
* ruby
@@ -465,7 +467,7 @@ Display version information.
Short:
$ leetcode version
- 2.6.1
+ 2.6.2
Verbose:
@@ -475,7 +477,7 @@ Verbose:
| | ___ ___| |_ ___ ___ __| | ___
| |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \
| | __/ __/ |_ (__| (_) | (_| | __/
- |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.1
+ |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.2
[Environment]
Node v8.1.4
diff --git a/docs/releases.md b/docs/releases.md
index 7b78a5f3..77cce5eb 100644
--- a/docs/releases.md
+++ b/docs/releases.md
@@ -2,6 +2,10 @@
layout: default
title: Release Notes
---
+# 2.6.2
+* `submit`
+ * fixes beta ratio issue
+
# 2.6.1
* `submit`
* fixes 500 error on windows.
diff --git a/lib/commands/plugin.js b/lib/commands/plugin.js
index 78a966b5..ca5a9cff 100644
--- a/lib/commands/plugin.js
+++ b/lib/commands/plugin.js
@@ -52,10 +52,10 @@ const cmd = {
.example(chalk.yellow('leetcode plugin company'), 'Show company plugin')
.example(chalk.yellow('leetcode plugin company -c'), 'Show config of company plugin')
.example('', '')
- .example(chalk.yellow('leetcode plugin -i'), 'Install all missing plugins from GtiHub')
- .example(chalk.yellow('leetcode plugin -i company'), 'Install company plugin from GtiHub')
+ .example(chalk.yellow('leetcode plugin -i'), 'Install all missing plugins from GitHub')
+ .example(chalk.yellow('leetcode plugin -i company'), 'Install company plugin from GitHub')
.example(chalk.yellow('leetcode plugin -d company'), 'Disable company plugin')
- .example(chalk.yellow('leetcode plugin -e company'), 'Enable comapny plugin')
+ .example(chalk.yellow('leetcode plugin -e company'), 'Enable company plugin')
.example(chalk.yellow('leetcode plugin -D company'), 'Delete company plugin');
}
};
diff --git a/lib/commands/stat.js b/lib/commands/stat.js
index 3c51ab98..772499c4 100644
--- a/lib/commands/stat.js
+++ b/lib/commands/stat.js
@@ -104,7 +104,8 @@ function showGraph(problems) {
for (let problem of problems)
graph[problem.fid] = ICONS[problem.state] || ICONS.none;
- let line = [sprintf(' %03s', 0)];
+ let rowNumFormat = ' %04s';
+ let line = [sprintf(rowNumFormat, 0)];
for (let i = 1, n = graph.length; i <= n; ++i) {
// padding before group
if (i % 10 === 1) line.push(' ');
@@ -114,7 +115,7 @@ function showGraph(problems) {
// time to start new row
if (i % (10 * groups) === 0 || i === n) {
log.info(line.join(' '));
- line = [sprintf(' %03s', i)];
+ line = [sprintf(rowNumFormat, i)];
}
}
diff --git a/lib/commands/submit.js b/lib/commands/submit.js
index 7376598b..56f5ed04 100644
--- a/lib/commands/submit.js
+++ b/lib/commands/submit.js
@@ -76,7 +76,7 @@ cmd.handler = function(argv) {
let ratio = 0.0;
for (let score of scores) {
- if (parseFloat(score[0]) > myRuntime)
+ if (parseFloat(score[0]) >= myRuntime)
ratio += parseFloat(score[1]);
}
diff --git a/lib/config.js b/lib/config.js
index 692b958d..373b9f0f 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -22,9 +22,11 @@ const DEFAULT_CONFIG = {
'javascript',
'kotlin',
'mysql',
+ 'php',
'python',
'python3',
'ruby',
+ 'rust',
'scala',
'swift'
],
@@ -67,7 +69,8 @@ const DEFAULT_CONFIG = {
theme: ''
},
network: {
- concurrency: 10
+ concurrency: 10,
+ delay: 1
},
plugins: {}
};
diff --git a/lib/helper.js b/lib/helper.js
index 5ca496aa..8806086e 100644
--- a/lib/helper.js
+++ b/lib/helper.js
@@ -39,9 +39,11 @@ const LANGS = [
{lang: 'javascript', ext: '.js', style: 'c'},
{lang: 'kotlin', ext: '.kt', style: 'c'},
{lang: 'mysql', ext: '.sql', style: '--'},
+ {lang: 'php', ext: '.php', style: 'c'},
{lang: 'python', ext: '.py', style: '#'},
{lang: 'python3', ext: '.py', style: '#'},
{lang: 'ruby', ext: '.rb', style: '#'},
+ {lang: 'rust', ext: '.rs', style: 'c'},
{lang: 'scala', ext: '.scala', style: 'c'},
{lang: 'swift', ext: '.swift', style: 'c'}
];
diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js
index a2e17b8f..24331ec6 100644
--- a/lib/plugins/leetcode.js
+++ b/lib/plugins/leetcode.js
@@ -157,11 +157,12 @@ plugin.getProblem = function(problem, cb) {
problem.totalAC = JSON.parse(q.stats).totalAccepted;
problem.totalSubmit = JSON.parse(q.stats).totalSubmission;
- if (!q.translatedContent) {
- problem.desc = he.decode(cheerio.load(q.content).root().text());
- }else{
- problem.desc = he.decode(cheerio.load(q.translatedContent).root().text());
- }
+
+ let content = q.translatedContent ? q.translatedContent : q.content;
+ // Replace with '^' as the power operator
+ content = content.replace(/<\/sup>/gm, '').replace(//gm, '^');
+ problem.desc = he.decode(cheerio.load(content).root().text());
+
problem.templates = JSON.parse(q.codeDefinition);
problem.testcase = q.sampleTestCase;
problem.testable = q.enableRunCode;
@@ -178,7 +179,7 @@ function runCode(opts, problem, cb) {
opts.headers.Origin = config.sys.urls.base;
opts.headers.Referer = problem.link;
opts.json = true;
- opts._delay = opts._delay || 1; // in seconds
+ opts._delay = opts._delay || config.network.delay || 1; // in seconds
opts.body = opts.body || {};
_.extendOwn(opts.body, {
@@ -260,7 +261,13 @@ function formatResult(result) {
x.expected_answer = result.expected_output;
x.stdout = result.std_output;
} else {
- x.stdout = util.inspect((result.code_output || []).join('\n'));
+ if (typeof(result.code_output) === 'string') {
+ x.stdout = util.inspect(result.code_output);
+ } else if (Array.isArray(result.code_output)) {
+ x.stdout = util.inspect(result.code_output.join('\n'));
+ } else {
+ x.stdout = util.inspect('');
+ }
}
// make sure we pass eveything!
@@ -335,7 +342,7 @@ plugin.getSubmission = function(submission, cb) {
let re = body.match(/submissionCode:\s('[^']*')/);
if (re) submission.code = eval(re[1]);
- re = body.match(/distribution_formatted:\s('[^']+')/);
+ re = body.match(/runtimeDistributionFormatted:\s('[^']+')/);
if (re) submission.distributionChart = JSON.parse(eval(re[1]));
return cb(null, submission);
});
diff --git a/package.json b/package.json
index ee8f2414..a9af9f7c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "leetcode-cli",
- "version": "2.6.1",
+ "version": "2.6.2",
"description": "A cli tool to enjoy leetcode!",
"preferGlobal": "true",
"engines": {
diff --git a/test/test_helper.js b/test/test_helper.js
index cfc502d4..143bda9e 100644
--- a/test/test_helper.js
+++ b/test/test_helper.js
@@ -128,12 +128,13 @@ describe('helper', function() {
assert.equal(h.langToExt('java'), '.java');
assert.equal(h.langToExt('javascript'), '.js');
assert.equal(h.langToExt('mysql'), '.sql');
+ assert.equal(h.langToExt('php'), '.php');
assert.equal(h.langToExt('python'), '.py');
assert.equal(h.langToExt('python3'), '.py');
assert.equal(h.langToExt('ruby'), '.rb');
+ assert.equal(h.langToExt('rust'), '.rs');
assert.equal(h.langToExt('scala'), '.scala');
assert.equal(h.langToExt('swift'), '.swift');
- assert.equal(h.langToExt('rust'), '.raw');
});
}); // #langToExt
@@ -146,11 +147,13 @@ describe('helper', function() {
assert.equal(h.extToLang('../file.go'), 'golang');
assert.equal(h.extToLang('file.java'), 'java');
assert.equal(h.extToLang('c:/file.js'), 'javascript');
+ assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql');
+ assert.equal(h.extToLang('~/leetcode/hello.php'), 'php');
assert.equal(h.extToLang('c:/Users/skygragon/file.py'), 'python');
assert.equal(h.extToLang('~/file.rb'), 'ruby');
+ assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust');
assert.equal(h.extToLang('/tmp/file.scala'), 'scala');
assert.equal(h.extToLang('~/leetcode/file.swift'), 'swift');
- assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql');
assert.equal(h.extToLang('/home/skygragon/file.dat'), 'unknown');
});
}); // #extToLang
@@ -169,9 +172,11 @@ describe('helper', function() {
assert.deepEqual(h.langToCommentStyle('java'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('javascript'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('mysql'), SQL_STYLE);
+ assert.deepEqual(h.langToCommentStyle('php'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('python'), RUBY_STYLE);
assert.deepEqual(h.langToCommentStyle('python3'), RUBY_STYLE);
assert.deepEqual(h.langToCommentStyle('ruby'), RUBY_STYLE);
+ assert.deepEqual(h.langToCommentStyle('rust'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('scala'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('swift'), C_STYLE);
});