Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve code snippet generation #1

Merged
merged 12 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Tests

on: [push, pull_request]
on:
push:
branches: main
pull_request:

jobs:
cpp-lint:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
venv
.vscode
.cache
solutions/**/description.md
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ add_task(bitwise-and-of-numbers-range)
add_task(bitwise-xor-of-all-pairings)
add_task(boats-to-save-people)
add_task(buddy-strings)
add_task(build-array-where-you-can-find-the-maximum-exactly-k-comparisons)
add_task(bulb-switcher)
add_task(bulls-and-cows)
add_task(bus-routes)
Expand Down Expand Up @@ -94,6 +95,7 @@ add_task(combination-sum-ii)
add_task(combination-sum-iii)
add_task(combination-sum-iv)
add_task(combinations)
add_task(concatenation-of-array)
add_task(construct-binary-tree-from-inorder-and-postorder-traversal)
add_task(construct-binary-tree-from-preorder-and-inorder-traversal)
add_task(construct-quad-tree)
Expand Down Expand Up @@ -213,10 +215,10 @@ add_task(house-robber)
add_task(house-robber-ii)
add_task(implement-queue-using-stacks)
add_task(implement-stack-using-queues)
add_task(implement-trie)
add_task(implement-trie-prefix-tree)
add_task(increasing-triplet-subsequence)
add_task(increment-submatrices-by-one)
add_task(insert-delete-getrandom)
add_task(insert-delete-getrandom-o1)
add_task(insert-interval)
add_task(insert-into-a-binary-search-tree)
add_task(integer-break)
Expand Down Expand Up @@ -284,6 +286,7 @@ add_task(lowest-common-ancestor-of-a-binary-tree)
add_task(lru-cache)
add_task(magnetic-force-between-two-balls)
add_task(majority-element)
add_task(majority-element-ii)
add_task(make-array-strictly-increasing)
add_task(matrix-block-sum)
add_task(matrix-diagonal-sum)
Expand Down Expand Up @@ -391,6 +394,7 @@ add_task(number-of-1-bits)
add_task(number-of-closed-islands)
add_task(number-of-digit-one)
add_task(number-of-enclaves)
add_task(number-of-good-pairs)
add_task(number-of-increasing-paths-in-a-grid)
add_task(number-of-islands)
add_task(number-of-longest-increasing-subsequence)
Expand Down Expand Up @@ -435,9 +439,9 @@ add_task(plus-one)
add_task(populating-next-right-pointers-in-each-node)
add_task(populating-next-right-pointers-in-each-node-ii)
add_task(possible-bipartition)
add_task(pow-x-n)
add_task(power-of-three)
add_task(power-of-two)
add_task(powx-n)
add_task(predict-the-winner)
add_task(product-of-array-except-self)
add_task(product-of-the-last-k-numbers)
Expand All @@ -452,6 +456,7 @@ add_task(reconstruct-itinerary)
add_task(recover-a-tree-from-preorder-traversal)
add_task(recover-binary-search-tree)
add_task(reducing-dishes)
add_task(remove-colored-pieces-if-both-neighbors-are-the-same-color)
add_task(remove-duplicate-letters)
add_task(remove-duplicates-from-sorted-array)
add_task(remove-duplicates-from-sorted-array-ii)
Expand Down Expand Up @@ -496,7 +501,7 @@ add_task(search-in-rotated-sorted-array-ii)
add_task(search-insert-position)
add_task(search-suggestions-system)
add_task(seat-reservation-manager)
add_task(sell-diminishing_valued-colored-balls)
add_task(sell-diminishing-valued-colored-balls)
add_task(sequentially-ordinal-rank-tracker)
add_task(serialize-and-deserialize-binary-tree)
add_task(set-matrix-zeroes)
Expand All @@ -512,15 +517,15 @@ add_task(sign-of-the-product-of-an-array)
add_task(similar-string-groups)
add_task(simplify-path)
add_task(single-element-in-a-sorted-array)
add_task(single-number-i)
add_task(single-number)
add_task(single-number-ii)
add_task(single-number-iii)
add_task(sliding-puzzle)
add_task(sliding-window-maximum)
add_task(smallest-number-in-infinite-set)
add_task(smallest-range-i)
add_task(smallest-range-ii)
add_task(smallest-subsequence)
add_task(smallest-subsequence-of-distinct-characters)
add_task(smallest-sufficient-team)
add_task(snakes-and-ladders)
add_task(snapshot-array)
Expand All @@ -537,7 +542,7 @@ add_task(special-array-with-x-elements-greater-than-or-equal-x)
add_task(spiral-matrix)
add_task(spiral-matrix-ii)
add_task(split-linked-list-in-parts)
add_task(sqrt)
add_task(sqrtx)
add_task(squares-of-a-sorted-array)
add_task(stone-game-ii)
add_task(stone-game-iii)
Expand Down Expand Up @@ -575,7 +580,7 @@ add_task(total-cost-to-hire-k-workers)
add_task(trapping-rain-water)
add_task(triangle)
add_task(two-sum)
add_task(two-sum-ii)
add_task(two-sum-ii-input-array-is-sorted)
add_task(two-sum-iv-input-is-a-bst)
add_task(ugly-number)
add_task(ugly-number-ii)
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ ext install ms-python.vscode-pylance

## Generating a template for a task

Open project and run the following command in the VS Code terminal:
Copy the slug of the desired LeetCode problem as shown in the picture:

![plot](./res/slug.png)

Open project and run the following command in the VS Code terminal, specify the previously copied slug:

```bash
python3 gen_task.py "Some Problem"
python3 leetcode.py get concatenation-of-array
```

Open the following files:
The command above will generate several files, open them in the terminal:

```bash
code solutions/some-problem/solution.hpp
code solutions/some-problem/test.cpp
code solutions/concatenation-of-array/solution.hpp
code solutions/concatenation-of-array/test.cpp
```

After writing the solution to the problem and the tests, use the VS Code status bar to run the tests:
Expand All @@ -47,6 +51,12 @@ After writing the solution to the problem and the tests, use the VS Code status
Or use TestMate extension:
![plot](./res/test-mate.png)

The command to get the LeetCode Daily question:

```bash
python3 leetcode.py get-daily
```

## Auto-Format in VS Code

Install clang-format in Ubuntu:
Expand Down
72 changes: 0 additions & 72 deletions gen_task.py

This file was deleted.

Loading
Loading