leetcode-cli


Nameleetcode-cli JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/chenpengcheng/cli
SummaryLeetCode CLI
upload_time2023-04-10 08:23:58
maintainer
docs_urlNone
authorPengcheng Chen
requires_python
license
keywords leetcode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LeetCode CLI

Start `tmux`, `vim` and `leetcode-cli`. Practice as many questions as you can:-)

This tool is not affiliated with [LeetCode](https://leetcode.com).

## Install

### Mac OS X

```
brew install node
sudo easy_install leetcode-cli
```

### Linux

```
sudo apt install nodejs
sudo pip install leetcode-cli
```

## Usage

The most common commands are: `cd`, `ls`, `pull`, `cat`, `check`, `push`, `cheat`, `clear` and `/`.

```
$ leetcode-cli

 (\_/)
=(^.^)=
(")_(")
243 solved 17 failed 523 todo

#:/> ?
cat                     - Show test case(s).
cd      <tag|number>    - Change problem(s).
cheat   <number>        - Find the best solution.
check                   - Test the solution.
chmod   <language>      - Change programming language.
clear                   - Clear screen.
find    <keyword>       - Find problems by keyword. Alias: /<keyword>.
limit   <number>        - Limit the number of problems.
login                   - Login into the online judge.
ls                      - Show problem(s).
print   [keyword]       - Print problems by keyword in HTML.
pull    [*]             - Pull latest solution(s). '*': all solved problems.
push                    - Submit the solution.
su      <session>       - Change session.

A tag can refer to a topic (e.g. array) or a company (e.g. amazon).
A keyword can be anything (including a tag).
Commands and options can be completed via <TAB>.

#:/>
```

Control+D to exit.

## Demo

At the root (`/`) level. `ls` lists all the topics. `#` is for problems without a topic.

```
#:/> ls
     29 #
     81 array
     28 backtracking            <- 28 problems todo in backtracking
      5 binary-indexed-tree
     35 binary-search
     12 binary-search-tree
     26 bit-manipulation
      3 brainteaser
     31 breadth-first-search
     60 depth-first-search
...
     13 sort
     14 stack
     62 string
      3 topological-sort
     53 tree
     12 trie
     21 two-pointers
      9 union-find
242 solved 18 failed 523 todo
```

`cd <topic>` changes the current topic.

```
#:/> cd heap
#:/heap>
```

At the topic level, `ls` lists the problems by difficulty level and acceptance rate. Levels are seperated by a blank line. At each level, the problems are listed in the order of acceptance rate.
The marks: `*` means `todo`, `x` `failed`, none means `solved`.

```
#:/heap> ls
     355 design-twitter                             <- the hardest
    *719 find-k-th-smallest-pair-distance
    *836 race-car
      23 merge-k-sorted-lists
    *218 the-skyline-problem
    *803 cheapest-flights-within-k-stops

     295 find-median-from-data-stream               <- medium level
    *895 shortest-path-to-get-all-keys
     373 find-k-pairs-with-smallest-sums
...
     215 kth-largest-element-in-an-array
    *692 top-k-frequent-words
    *794 swim-in-rising-water

     378 kth-smallest-element-in-a-sorted-matrix    <- easy level
     347 top-k-frequent-elements
     451 sort-characters-by-frequency
    *761 employee-free-time                         <- the easiest
11 solved 0 failed 17 todo
```

`cd <number>` changes the current problem. Then `ls` shows the description.

```
#:/heap> cd 23
#:/heap/23-merge-k-sorted-lists> ls
[Linked-List, Heap, Divide-And-Conquer, 8/20]

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
Example:

Input:
[
 1->4->5,
 1->3->4,
 2->6
]
Output: 1->1->2->3->4->4->5->6
```

`pull` downloads the latest solution and sample test case from the online judge. If no solution was submitted, a boiler plate is used. The solution/boilerplate is saved in `./ws/<number>.<ext>` and can be edited.

```
#:/heap/23-merge-k-sorted-lists> pull
,___,
[O.o]  Replace working copy? (y/N)
/)__)
-"--"-y
ws/23.py
```
`cat` show the sample test case. It is saved in `./ws/tests.dat`. Test cases can be added to it and be used by `check`.

```
#:/heap/23-merge-k-sorted-lists> cat
ws/23.py << [[1,4,5],[1,3,4],[2,6]]
```

Now that we have the problem description and the sample test case, start coding and test the solution locally.

```
$ vim ./ws/23.py
$ python ./ws/23.py
```

The default programming language is `Python`. To change it, use `chmod <language>`. Once the solution passes tests locally, we can `check` it with or `push` it to the online judge. `push` reports the runtime and number of tests passed.

```
#:/heap/23-merge-k-sorted-lists> check
Input:  [[1,4,5],[1,3,4],[2,6]]
Result: [1,1,2,3,4,4,5,6]
Runtime: 20 ms

#:/heap/23-merge-k-sorted-lists> push
Runtime                                                                  %  ms
###############################################################################
**                                                                       0  48
*****                                                                    1  52
*****************                                                        2  56
**********************************************************************   8  60
***********************************************************************  8  64*
****************************************                                 5  68
***********************************************                          6  72
***************************************************************          7  76
**************************************                                   4  80
************************                                                 3  84
****************                                                         2  88
**************                                                           2  92
************                                                             1  96
****************                                                         2  100
*****************                                                        2  104
****************                                                         2  108
***********************                                                  3  112
********************************                                         4  116
************************                                                 3  120
***********************                                                  3  124
***********************                                                  3  128
******************                                                       2  132
**********                                                               1  136
*********                                                                1  140
Rank: 20.51%
Result: 131/131 tests passed
Runtime: 64 ms
```

`/<keyword>` searches for problems matching a tag (`airbnb`) or a keyword (e.g. `palindrome`)

```
#:/heap/23-merge-k-sorted-lists> cd ..
#:/heap> cd ..
#:/> /airbnb
     220 contains-duplicate-iii
      68 text-justification
      10 regular-expression-matching
    x212 word-search-ii
     269 alien-dictionary
    *336 palindrome-pairs
       2 add-two-numbers
      23 merge-k-sorted-lists
    *190 reverse-bits
    *803 cheapest-flights-within-k-stops

     227 basic-calculator-ii
     160 intersection-of-two-linked-lists
    *221 maximal-square
     385 mini-parser
     219 contains-duplicate-ii
      20 valid-parentheses
    *756 pour-water
      42 trapping-rain-water
       1 two-sum
     198 house-robber
     251 flatten-2d-vector
     415 add-strings
     202 happy-number

     108 convert-sorted-array-to-binary-search-tree
    *787 sliding-puzzle
    *757 pyramid-transition-matrix
     217 contains-duplicate
    *752 ip-to-cidr
    *761 employee-free-time
     136 single-number
20 solved 1 failed 9 todo

#:/>
```

The solutions are saved in the `./ws/` directory.

`print` generates a syntax-highlighted [HTML](http://www.spiderman.ly/all.html).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/chenpengcheng/cli",
    "name": "leetcode-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "leetcode",
    "author": "Pengcheng Chen",
    "author_email": "pengcheng.chen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/2b/fdfc94251a2128b5f4475a81be9d0dd9942ba324c5e5ad60428b2d0286c0/leetcode-cli-0.1.0.tar.gz",
    "platform": null,
    "description": "# LeetCode CLI\n\nStart `tmux`, `vim` and `leetcode-cli`. Practice as many questions as you can:-)\n\nThis tool is not affiliated with [LeetCode](https://leetcode.com).\n\n## Install\n\n### Mac OS X\n\n```\nbrew install node\nsudo easy_install leetcode-cli\n```\n\n### Linux\n\n```\nsudo apt install nodejs\nsudo pip install leetcode-cli\n```\n\n## Usage\n\nThe most common commands are: `cd`, `ls`, `pull`, `cat`, `check`, `push`, `cheat`, `clear` and `/`.\n\n```\n$ leetcode-cli\n\n (\\_/)\n=(^.^)=\n(\")_(\")\n243 solved 17 failed 523 todo\n\n#:/> ?\ncat                     - Show test case(s).\ncd      <tag|number>    - Change problem(s).\ncheat   <number>        - Find the best solution.\ncheck                   - Test the solution.\nchmod   <language>      - Change programming language.\nclear                   - Clear screen.\nfind    <keyword>       - Find problems by keyword. Alias: /<keyword>.\nlimit   <number>        - Limit the number of problems.\nlogin                   - Login into the online judge.\nls                      - Show problem(s).\nprint   [keyword]       - Print problems by keyword in HTML.\npull    [*]             - Pull latest solution(s). '*': all solved problems.\npush                    - Submit the solution.\nsu      <session>       - Change session.\n\nA tag can refer to a topic (e.g. array) or a company (e.g. amazon).\nA keyword can be anything (including a tag).\nCommands and options can be completed via <TAB>.\n\n#:/>\n```\n\nControl+D to exit.\n\n## Demo\n\nAt the root (`/`) level. `ls` lists all the topics. `#` is for problems without a topic.\n\n```\n#:/> ls\n     29 #\n     81 array\n     28 backtracking            <- 28 problems todo in backtracking\n      5 binary-indexed-tree\n     35 binary-search\n     12 binary-search-tree\n     26 bit-manipulation\n      3 brainteaser\n     31 breadth-first-search\n     60 depth-first-search\n...\n     13 sort\n     14 stack\n     62 string\n      3 topological-sort\n     53 tree\n     12 trie\n     21 two-pointers\n      9 union-find\n242 solved 18 failed 523 todo\n```\n\n`cd <topic>` changes the current topic.\n\n```\n#:/> cd heap\n#:/heap>\n```\n\nAt the topic level, `ls` lists the problems by difficulty level and acceptance rate. Levels are seperated by a blank line. At each level, the problems are listed in the order of acceptance rate.\nThe marks: `*` means `todo`, `x` `failed`, none means `solved`.\n\n```\n#:/heap> ls\n     355 design-twitter                             <- the hardest\n    *719 find-k-th-smallest-pair-distance\n    *836 race-car\n      23 merge-k-sorted-lists\n    *218 the-skyline-problem\n    *803 cheapest-flights-within-k-stops\n\n     295 find-median-from-data-stream               <- medium level\n    *895 shortest-path-to-get-all-keys\n     373 find-k-pairs-with-smallest-sums\n...\n     215 kth-largest-element-in-an-array\n    *692 top-k-frequent-words\n    *794 swim-in-rising-water\n\n     378 kth-smallest-element-in-a-sorted-matrix    <- easy level\n     347 top-k-frequent-elements\n     451 sort-characters-by-frequency\n    *761 employee-free-time                         <- the easiest\n11 solved 0 failed 17 todo\n```\n\n`cd <number>` changes the current problem. Then `ls` shows the description.\n\n```\n#:/heap> cd 23\n#:/heap/23-merge-k-sorted-lists> ls\n[Linked-List, Heap, Divide-And-Conquer, 8/20]\n\nMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.\nExample:\n\nInput:\n[\n 1->4->5,\n 1->3->4,\n 2->6\n]\nOutput: 1->1->2->3->4->4->5->6\n```\n\n`pull` downloads the latest solution and sample test case from the online judge. If no solution was submitted, a boiler plate is used. The solution/boilerplate is saved in `./ws/<number>.<ext>` and can be edited.\n\n```\n#:/heap/23-merge-k-sorted-lists> pull\n,___,\n[O.o]  Replace working copy? (y/N)\n/)__)\n-\"--\"-y\nws/23.py\n```\n`cat` show the sample test case. It is saved in `./ws/tests.dat`. Test cases can be added to it and be used by `check`.\n\n```\n#:/heap/23-merge-k-sorted-lists> cat\nws/23.py << [[1,4,5],[1,3,4],[2,6]]\n```\n\nNow that we have the problem description and the sample test case, start coding and test the solution locally.\n\n```\n$ vim ./ws/23.py\n$ python ./ws/23.py\n```\n\nThe default programming language is `Python`. To change it, use `chmod <language>`. Once the solution passes tests locally, we can `check` it with or `push` it to the online judge. `push` reports the runtime and number of tests passed.\n\n```\n#:/heap/23-merge-k-sorted-lists> check\nInput:  [[1,4,5],[1,3,4],[2,6]]\nResult: [1,1,2,3,4,4,5,6]\nRuntime: 20 ms\n\n#:/heap/23-merge-k-sorted-lists> push\nRuntime                                                                  %  ms\n###############################################################################\n**                                                                       0  48\n*****                                                                    1  52\n*****************                                                        2  56\n**********************************************************************   8  60\n***********************************************************************  8  64*\n****************************************                                 5  68\n***********************************************                          6  72\n***************************************************************          7  76\n**************************************                                   4  80\n************************                                                 3  84\n****************                                                         2  88\n**************                                                           2  92\n************                                                             1  96\n****************                                                         2  100\n*****************                                                        2  104\n****************                                                         2  108\n***********************                                                  3  112\n********************************                                         4  116\n************************                                                 3  120\n***********************                                                  3  124\n***********************                                                  3  128\n******************                                                       2  132\n**********                                                               1  136\n*********                                                                1  140\nRank: 20.51%\nResult: 131/131 tests passed\nRuntime: 64 ms\n```\n\n`/<keyword>` searches for problems matching a tag (`airbnb`) or a keyword (e.g. `palindrome`)\n\n```\n#:/heap/23-merge-k-sorted-lists> cd ..\n#:/heap> cd ..\n#:/> /airbnb\n     220 contains-duplicate-iii\n      68 text-justification\n      10 regular-expression-matching\n    x212 word-search-ii\n     269 alien-dictionary\n    *336 palindrome-pairs\n       2 add-two-numbers\n      23 merge-k-sorted-lists\n    *190 reverse-bits\n    *803 cheapest-flights-within-k-stops\n\n     227 basic-calculator-ii\n     160 intersection-of-two-linked-lists\n    *221 maximal-square\n     385 mini-parser\n     219 contains-duplicate-ii\n      20 valid-parentheses\n    *756 pour-water\n      42 trapping-rain-water\n       1 two-sum\n     198 house-robber\n     251 flatten-2d-vector\n     415 add-strings\n     202 happy-number\n\n     108 convert-sorted-array-to-binary-search-tree\n    *787 sliding-puzzle\n    *757 pyramid-transition-matrix\n     217 contains-duplicate\n    *752 ip-to-cidr\n    *761 employee-free-time\n     136 single-number\n20 solved 1 failed 9 todo\n\n#:/>\n```\n\nThe solutions are saved in the `./ws/` directory.\n\n`print` generates a syntax-highlighted [HTML](http://www.spiderman.ly/all.html).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "LeetCode CLI",
    "version": "0.1.0",
    "split_keywords": [
        "leetcode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d34fa783064b1a5668e2613df22e3181c3b196badb0f21b595b17f6775744281",
                "md5": "14162d0a29205fea4f720344f8555481",
                "sha256": "278f83890bd97294df227b9ccc5415ed5931644ef26b9ee21d5cc5a0b4411040"
            },
            "downloads": -1,
            "filename": "leetcode_cli-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "14162d0a29205fea4f720344f8555481",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 13773,
            "upload_time": "2023-04-10T08:23:56",
            "upload_time_iso_8601": "2023-04-10T08:23:56.965543Z",
            "url": "https://files.pythonhosted.org/packages/d3/4f/a783064b1a5668e2613df22e3181c3b196badb0f21b595b17f6775744281/leetcode_cli-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d2bfdfc94251a2128b5f4475a81be9d0dd9942ba324c5e5ad60428b2d0286c0",
                "md5": "7a42abfeb9b75477df27fbd2a90e5c65",
                "sha256": "4dffecaf23af8c0ed15a58c6a214fc85d218d42c6d8203ce41a2bc7db9e995e2"
            },
            "downloads": -1,
            "filename": "leetcode-cli-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7a42abfeb9b75477df27fbd2a90e5c65",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13636,
            "upload_time": "2023-04-10T08:23:58",
            "upload_time_iso_8601": "2023-04-10T08:23:58.904468Z",
            "url": "https://files.pythonhosted.org/packages/3d/2b/fdfc94251a2128b5f4475a81be9d0dd9942ba324c5e5ad60428b2d0286c0/leetcode-cli-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-10 08:23:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "chenpengcheng",
    "github_project": "cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "leetcode-cli"
}
        
Elapsed time: 1.63365s