Skip to content

Commit f37efb5

Browse files
retimangithub-actions[bot]
andauthored
ADHOC: Converts to Python (#196)
Very annoying that there's no easy way to get access to a heap in TypeScript. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@github.com>
1 parent b2715eb commit f37efb5

File tree

568 files changed

+11937
-17854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

568 files changed

+11937
-17854
lines changed

.editorconfig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ charset = utf-8
55
end_of_line = lf
66
indent_size = 2
77
indent_style = space
8-
# Setting this to true makes VSCode break typing flow. The following ticket mentions that Intellisense dropdowns
9-
# disappear, and that is presumably fixed. However, if you aren't, then the cursor still jumps and typing flow is still
10-
# broken.
11-
#
12-
# See https://github.com/editorconfig/editorconfig-vscode/issues/40
13-
# insert_final_newline = true
8+
insert_final_newline = true
149
trim_trailing_whitespace = true
10+
11+
[*.py]
12+
indent_size = 4

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* text=auto eol=lf
1+
* text eol=lf

.github/workflows/build-and-test.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Build and Test
33
on:
44
pull_request:
55
paths-ignore:
6+
- CODEOWNERS
67
- LICENSE
78
- README.md
89
push:
@@ -27,19 +28,31 @@ jobs:
2728
ref: ${{ github.head_ref }}
2829
token: ${{ steps.generate-token.outputs.token }}
2930

30-
- name: Setup NodeJS
31-
uses: actions/setup-node@v3
31+
- name: Setup Python
32+
uses: actions/setup-python@v5
3233
with:
33-
node-version: 20
34+
python-version: '3.13'
35+
36+
- name: Install poetry
37+
run: python -m pip install poetry==2.1.1
38+
39+
- name: Configure poetry
40+
run: poetry config virtualenvs.in-project true
41+
42+
- name: Cache the virtualenv
43+
uses: actions/cache@v4
44+
with:
45+
path: ./.venv
46+
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
3447

3548
- name: Install dependencies
36-
run: npm ci
49+
run: poetry install
3750

38-
- name: Fix
39-
run: npm run fix
51+
- name: Run format
52+
run: poetry run format
4053

41-
- name: Build
42-
run: npm run build
54+
- name: Run lint
55+
run: poetry run lint
4356

4457
- name: Commit
4558
if: ${{ github.ref != 'refs/heads/main' }}
@@ -52,4 +65,4 @@ jobs:
5265

5366
- name: Test
5467
if: ${{ steps.commit.outputs.committed == 'false' }}
55-
run: npm run test
68+
run: poetry run test

.gitignore

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
__pycache__/
2+
.env/
3+
.mypy_cache/
4+
.venv/
5+
.vscode/
16
build/
2-
coverage/
37
dist/
4-
node_modules/
58

6-
*.tgz
7-
.env
9+
*.egg-info/
10+
*.pyc
11+
*.pyo

.prettierignore

Lines changed: 0 additions & 18 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,8 @@
22

33
Problems and solutions for LeetCode.
44

5+
## Development
56

6-
## Priority Queue
7-
8-
Several problems require access to a priority queue; however, TypeScript itself does not have such a built-in data structure.
9-
10-
11-
### LeetCode
12-
13-
LeetCode provides support for [heaps](https://support.leetcode.com/hc/en-us/articles/360011833974-What-are-the-environments-for-the-programming-languages) via [datastructures-js/priority-queue](https://github.com/datastructures-js/priority-queue) at version `5.4.0`. This is the library used, because this repository is for LeetCode submissions.
14-
15-
A couple of gotchas for version `5.4.0` that don't exist in later versions:
16-
17-
- LeetCode uses `require` style imports and not `import`. Practically that means `MaxPriorityQueue` and `MinPriorityQueue` do not accept parameterized types.
18-
- Also, `MaxPriorityQueue` and `MinPriorityQueue` are exported as values. To get the type, do `InstanceType<typeof MaxPriorityQueue>`.
19-
- Primitives are wrapped. That is, if you do `heap.enqueue(1)`, then you should `heap.dequeue().element` to get `1` back.
20-
- Objects are not wrapped. That is, if you do `heap.enqueue(foo)`, then you should do `heap.dequeue()` to get `foo` back, if `foo` is an object.
21-
22-
23-
### CoderPad
24-
25-
CoderPad has no official support for priority queues.
26-
27-
28-
### CodeSignal
29-
30-
CodeSignal's official documentation does not claim support for priority queues. However, there is [documentation](https://learn.codesignal.com/preview/lessons/3525/heaps-and-priority-queues-in-javascript?utm_source=chatgpt.com) suggesting that [heap-js](https://github.com/ignlg/heap-js) is available.
31-
32-
33-
### Other
34-
35-
There are a few other options.
36-
37-
- Insert into an array and sort it afterwards. See [simple-heap.ts](src/heap/simple-heap.ts).
38-
- Use binary search to insert into an array and do not sort. See [bs-search-heap.ts](src/heap/bs-search-heap.ts).
39-
- Roll your own heap during the interview. You beast.
40-
- Give up.
7+
1. Install poetry: `curl -sSL https://install.python-poetry.org | python`
8+
1. Install dependencies: `poetry install`
9+
1. Run tests: `poetry run test`

eslint.config.mjs

Lines changed: 0 additions & 153 deletions
This file was deleted.

0 commit comments

Comments
 (0)