diff --git a/.gitignore b/.gitignore index edd9d60..67efb3d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build/ dist/ +node_modules/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..57f5663 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "markdownlint.config": { + "no-inline-html": { + "allowed_elements": ["img", "u", "br"] + }, + "no-empty-links": false, + "no-hard-tabs": false, + "single-h1": false + } +} diff --git a/README.md b/README.md index a6ead4a..cad2117 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,9 @@ cmake --install build Or you should try `./build.sh` to help you do this. Then you will get all test file on `dist/`. + +## Migrate Description from HTML to Markdown + +For the first time, you should install nodejs and run `npm install` to install dependencies. + +Then you can run `node html2md.ts ` to convert HTML to Markdown. diff --git a/html2md.ts b/html2md.ts new file mode 100644 index 0000000..e326f55 --- /dev/null +++ b/html2md.ts @@ -0,0 +1,11 @@ +// For Node.js +var TurndownService = require("turndown"); + +var htmlPath = process.argv[2]; +var html = require("fs").readFileSync(htmlPath, "utf8"); + +var turndownService = new TurndownService(); +var markdown = turndownService.turndown(html); + +var markdownPath = htmlPath.replace(/\.html$/, ".raw.md"); +require("fs").writeFileSync(markdownPath, markdown); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..174332a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,43 @@ +{ + "name": "judger-test-collection", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "turndown": "^7.1.2" + }, + "devDependencies": { + "@types/node": "^20.8.9" + } + }, + "node_modules/@types/node": { + "version": "20.8.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz", + "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/domino": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/domino/-/domino-2.1.6.tgz", + "integrity": "sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==" + }, + "node_modules/turndown": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/turndown/-/turndown-7.1.2.tgz", + "integrity": "sha512-ntI9R7fcUKjqBP6QU8rBK2Ehyt8LAzt3UBT9JR9tgo6GtuKvyUzpayWmeMKJw1DPdXzktvtIT8m2mVXz+bL/Qg==", + "dependencies": { + "domino": "^2.1.6" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..93b7b07 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "turndown": "^7.1.2" + }, + "devDependencies": { + "@types/node": "^20.8.9" + } +} diff --git a/packages/icpc/two-sum/description.html b/packages/icpc/two-sum/description.html new file mode 100644 index 0000000..c82004c --- /dev/null +++ b/packages/icpc/two-sum/description.html @@ -0,0 +1,43 @@ +
+

Given an array of integers nums and an integer target, return indices of the + two numbers such that they add up to target.

+ +

You may assume that each input would have exactly one solution, and you may not use the + same element twice.

+ +

You can return the answer in any order.

+ +

 

+

Example 1:

+ +
Input: nums = [2,7,11,15], target = 9
+    Output: [0,1]
+    Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
+    
+ +

Example 2:

+ +
Input: nums = [3,2,4], target = 6
+    Output: [1,2]
+    
+ +

Example 3:

+ +
Input: nums = [3,3], target = 6
+    Output: [0,1]
+    
+ +

 

+

Constraints:

+ + + +

 

+ Follow-up: Can you come up with an algorithm that is less than O(n2) +  time complexity? +
\ No newline at end of file diff --git a/packages/icpc/two-sum/description.md b/packages/icpc/two-sum/description.md new file mode 100644 index 0000000..ea71ec5 --- /dev/null +++ b/packages/icpc/two-sum/description.md @@ -0,0 +1,32 @@ +# [Two Sum](https://leetcode.com/problems/two-sum/) + +Given an array of integers `nums` and an integer `target`, return _indices of the two numbers such that they add up to `target`_. + +You may assume that each input would have **_exactly_ one solution**, and you may not use the _same_ element twice. + +You can return the answer in any order. + +**Example 1:** + +**Input:** nums = \[2,7,11,15\], target = 9
+**Output:** \[0,1\]
+**Explanation:** Because nums\[0\] + nums\[1\] == 9, we return \[0, 1\]. + +**Example 2:** + +**Input:** nums = \[3,2,4\], target = 6
+**Output:** \[1,2\] + +**Example 3:** + +**Input:** nums = \[3,3\], target = 6
+**Output:** \[0,1\] + +**Constraints:** + +* `2 <= nums.length <= 104` +* `-109 <= nums[i] <= 109` +* `-109 <= target <= 109` +* **Only one valid answer exists.** + +**Follow-up:** Can you come up with an algorithm that is less than `O(n2)` time complexity?