Skip to content

Commit 9f2c846

Browse files
authored
feat: convert .ipynb to .py (#37)
1 parent 4079793 commit 9f2c846

File tree

154 files changed

+2558
-5667
lines changed

Some content is hidden

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

154 files changed

+2558
-5667
lines changed

.codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
coverage:
2+
ignore:
3+
- "**/playground.py"
24
status:
35
project:
46
default:

.github/workflows/ci-pre-commit.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
12+
with:
13+
fetch-depth: 0
14+
submodules: recursive
15+
token: ${{ secrets.GITHUB_TOKEN }}
1216

1317
- uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
1418
with:

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ repos:
2222
id: gitleaks
2323
- repo: local
2424
hooks:
25+
- id: sync-submodules
26+
name: Sync git submodules
27+
entry: bash -c 'output=$(git submodule update --init --recursive --remote 2>&1); [ -z "$output" ]'
28+
language: system
29+
always_run: true
30+
pass_filenames: false
31+
- id: nb-to-py
32+
name: convert notebooks to python
33+
entry: make nb-to-py
34+
language: system
35+
pass_filenames: false
2536
- id: lint
2637
name: lint
2738
entry: make lint

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ p-gen:
7777
p-del:
7878
rm -rf leetcode/$(PROBLEM)
7979

80+
# Convert all notebooks to .py files and delete .ipynb for better version control
81+
nb-to-py:
82+
@echo "Converting all .ipynb files in leetcode/ to .py files..."
83+
@find leetcode -name "*.ipynb" -exec poetry run jupytext --to py:percent {} \;
84+
@find leetcode -name "*.ipynb" -delete
85+
@echo "Conversion complete. All .ipynb files converted to .py and deleted."
86+
8087
# Generate All Problems - useful for people who fork this repo
8188
gen-all-problems:
8289
@echo "This will DELETE all existing problems and regenerate from JSON templates."

leetcode/accounts_merge/playground.ipynb

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# text_representation:
5+
# extension: .py
6+
# format_name: percent
7+
# format_version: '1.3'
8+
# jupytext_version: 1.17.3
9+
# kernelspec:
10+
# display_name: leetcode-py-py3.13
11+
# language: python
12+
# name: python3
13+
# ---
14+
15+
# %%
16+
from helpers import assert_accounts_merge, run_accounts_merge
17+
from solution import Solution
18+
19+
# %%
20+
# Example test case
21+
accounts = [
22+
["John", "johnsmith@mail.com", "john_newyork@mail.com"],
23+
["John", "johnsmith@mail.com", "john00@mail.com"],
24+
["Mary", "mary@mail.com"],
25+
["John", "johnnybravo@mail.com"],
26+
]
27+
expected = [
28+
["John", "john00@mail.com", "john_newyork@mail.com", "johnsmith@mail.com"],
29+
["Mary", "mary@mail.com"],
30+
["John", "johnnybravo@mail.com"],
31+
]
32+
33+
# %%
34+
result = run_accounts_merge(Solution, accounts)
35+
result
36+
37+
# %%
38+
assert_accounts_merge(result, expected)

leetcode/add_binary/playground.ipynb

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

leetcode/add_binary/playground.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# text_representation:
5+
# extension: .py
6+
# format_name: percent
7+
# format_version: '1.3'
8+
# jupytext_version: 1.17.3
9+
# kernelspec:
10+
# display_name: leetcode-py-py3.13
11+
# language: python
12+
# name: python3
13+
# ---
14+
15+
# %%
16+
from helpers import assert_add_binary, run_add_binary
17+
from solution import Solution
18+
19+
# %%
20+
# Example test case
21+
a = "11"
22+
b = "1"
23+
expected = "100"
24+
25+
# %%
26+
result = run_add_binary(Solution, a, b)
27+
result
28+
29+
# %%
30+
assert_add_binary(result, expected)

0 commit comments

Comments
 (0)