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

fetch upstream March 25, 2022 #3

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
68386a1
Updated Prim's MST
rap2montemayor Mar 11, 2022
55283b8
Merge pull request #17 from bullybutcher/jt--fix-preprocessing
bullybutcher Mar 20, 2022
9101faa
Merge pull request #18 from admu-progvar/jt--fix-preprocessing
bullybutcher Mar 20, 2022
449c098
Added nits and updated contributors
rap2montemayor Mar 20, 2022
5311c67
Merge branch 'main' into rm--fix-prims
rap2montemayor Mar 20, 2022
4cb370f
Merge pull request #11 from rap2montemayor/rm--fix-prims
rap2montemayor Mar 20, 2022
df4355a
team name can be passed as argument
bullybutcher Mar 23, 2022
8f37463
raprap contrib updated
bullybutcher Mar 23, 2022
b85409e
pass team name as argument
bullybutcher Mar 25, 2022
b6c726a
pass team name as argument
bullybutcher Mar 25, 2022
097a821
only add subtitle when team name is specified
leloykun Mar 26, 2022
1b93840
Merge pull request #21 from bullybutcher/jt--implement--teamname
leloykun Mar 29, 2022
8f88ea1
fix preprocess.py
leloykun Mar 29, 2022
362084e
Merge pull request #26 from admu-progvar/fc--fix-preprocessing
leloykun Mar 29, 2022
15b7597
run pre-commit on all files
leloykun Mar 29, 2022
fa8eb36
exclude checking for thread safety
leloykun Mar 29, 2022
11fd72a
update black
leloykun Mar 29, 2022
35adb91
fix black excluded files
leloykun Mar 29, 2022
f240cbb
run tests on pull_request
leloykun Mar 29, 2022
9d5b4d8
fixed build_tex.py
ongyiumark Mar 29, 2022
d24dbb8
remove _code & _docs on start of makefile
leloykun Mar 29, 2022
366a272
Merge pull request #27 from admu-progvar/fc--fix-pre-commit
leloykun Mar 29, 2022
dda981e
Shortened Z-Algo
ongyiumark Mar 29, 2022
79b4c42
fixed build_tex.py
ongyiumark Mar 29, 2022
53706cd
resolved merge conflicts
ongyiumark Mar 29, 2022
f4091f7
use exist_ok on all makedirs
leloykun Mar 29, 2022
2144579
Merge pull request #28 from admu-progvar/mo--fix-buildtex
ongyiumark Mar 29, 2022
d0b41f4
Added tests and compressed abridged
ongyiumark Mar 30, 2022
ec39ada
generate new notebook
ongyiumark Mar 30, 2022
ee4e0eb
fix formatting
leloykun Mar 30, 2022
f54fd49
Merge pull request #23 from admu-progvar/mo--edit-z
ongyiumark Mar 30, 2022
5b73bf9
O(n) Prime Sieve
ongyiumark Mar 30, 2022
cd38289
added abridged
ongyiumark Mar 30, 2022
2b97985
arranged directories
ongyiumark Mar 30, 2022
f721ec8
generated notebook
ongyiumark Mar 30, 2022
02d8544
added contributors
ongyiumark Mar 30, 2022
2e2b204
Merge pull request #29 from admu-progvar/mo--faster-prime-sieve
ongyiumark Mar 30, 2022
243d27d
Fixed Z-algo
ongyiumark Sep 11, 2022
b5fb850
updated tests
ongyiumark Sep 11, 2022
cfbbc19
Updated notebook
ongyiumark Sep 11, 2022
626235f
Removed red from z-algo
ongyiumark Sep 11, 2022
be76eab
Added comments and added z[0] = n
ongyiumark Sep 11, 2022
bc2cf86
Merge pull request #35 from admu-progvar/mo--fix-zalgo
ongyiumark Sep 14, 2022
ce9ccb5
fix interface
leloykun Sep 18, 2022
987f525
fix github action for testing
leloykun Sep 18, 2022
3582f78
fix testing
leloykun Sep 18, 2022
33cbc25
Merge pull request #36 from admu-progvar/fc--fix-interface
leloykun Sep 18, 2022
ed00bb2
add dynamic data struct
leloykun Sep 19, 2022
222a9a4
Merge pull request #37 from admu-progvar/fc--add-dynamic-data-structs
leloykun Sep 19, 2022
cfd9255
add link to alternative implementation
leloykun Sep 19, 2022
9b328a4
move combi stuff up a page
leloykun Oct 29, 2022
954f072
change colors
leloykun Oct 29, 2022
433ed6d
add monotonic queue
leloykun Nov 1, 2022
42ea17c
remove splay tree
leloykun Nov 1, 2022
186a259
clean up dynamic data structs
leloykun Nov 1, 2022
f992107
add knuth optimization & persistent li chao tree
leloykun Nov 1, 2022
920a3a0
minor nits
leloykun Nov 1, 2022
8a9e2d8
update notebook
leloykun Nov 1, 2022
31d8ed5
add list large primes
leloykun Nov 1, 2022
50e767b
add miller rabin
leloykun Nov 1, 2022
05a1583
update notebook
leloykun Nov 1, 2022
66f5a22
minor formatting fixes
leloykun Nov 2, 2022
7b027dd
fix formatting of granville's algorithm
leloykun Nov 2, 2022
fb3798e
add tests for centroid decomposition
leloykun Nov 4, 2022
e589c14
Added persistent lazy segtree (abridged)
rap2montemayor Nov 5, 2023
32dd6e1
Added non-abridged version and tests for persistent lazy segment tree
rap2montemayor Nov 5, 2023
696ef81
Make abridged persistent segtree fit in 62 cols
rap2montemayor Nov 5, 2023
aaddac8
Appease linters
rap2montemayor Nov 5, 2023
a5e7cf7
Regenerate notebook with persistent lazy segtree
rap2montemayor Nov 5, 2023
01fbd1f
Merge pull request #39 from rap2montemayor/rm--persistent-lazy-segtree
rap2montemayor Nov 5, 2023
efe6128
fixed bookmark bug in pdf
ongyiumark Nov 11, 2023
cecfcf8
Merge pull request #40 from admu-progvar/mo--housekeeping
ongyiumark Nov 11, 2023
4082336
quickfix
ongyiumark Nov 12, 2023
1e1f3a6
Update Franz' Creds
leloykun Nov 12, 2023
06b88e3
Merge pull request #42 from admu-progvar/leloykun-patch-1
leloykun Nov 12, 2023
d2caf71
Merge pull request #41 from admu-progvar/mo--fix-ordered-stat-tree
leloykun Oct 18, 2024
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
12 changes: 12 additions & 0 deletions .github/workflows/run_pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: pre-commit

on: pull_request

jobs:
pre-commit:
name: Run pre-commit on all files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
15 changes: 15 additions & 0 deletions .github/workflows/run_pvl_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: pvl-tests

on: pull_request

jobs:
pre-commit:
name: Run PVL tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Get latest CMake
uses: lukka/get-cmake@latest
- name: Run tests
run: ./run.sh test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@
/notebook/_docs
/notebook/_tex

/tests/build/
/tests/build/

.vscode/
build/
17 changes: 16 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,24 @@ repos:
rev: 9a5aa38207bf557961110d6a4f7e3a9d352911f9
hooks:
- id: cpplint
name: cpplint - pvl
files: pvl
args: [
"--exclude=pvl/abridged",
"--filter=-legal/copyright,-readability/alt_tokens,-whitespace/parens,-build/include_what_you_use,-runtime/int",
"--linelength=62"
]
files: 'pvl'
- id: cpplint
name: cpplint - tests
files: tests
args: [
"--exclude=tests/build",
"--filter=-legal/copyright,-readability/alt_tokens,-whitespace/parens,-build/include_what_you_use,-runtime/int,-build/include_order,-runtime/threadsafe_fn",
"--linelength=80"
]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
args: ["--exclude=docs|tests\/build|pvl\/abridged"]
106 changes: 68 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# AdMU ProgVar Competitive Programming Library

A collection of algorithms, data structures and other useful information for competitive programming.
Used and maintained by members of the Ateneo de Manila University Programming Varsity.

Expand All @@ -10,12 +11,14 @@ This repo is a mixture of our previous team notebook, [Reykjavik University's op

## Goals

### Long-term Goals:
### Long-term Goals

- Develop this into a fully-fledged code library for competitive programming. Like [Atcoder's AC Library](https://github.com/atcoder/ac-library) but with more algorithms and data structures.
- Write wikis, documentation, and tutorials for each of the algorithms and data structures here.
- Make the team notebook easily customizable; maybe based on analytics on how often a team uses each code snippet.

### Short-term Goals

- Move the codes in `pvl/abridged` to `pvl` and add tests for each of them.
- Clean-up the team notebook.
- Add tutorials (even just as comments) on how to use each code snippet.
Expand All @@ -25,82 +28,101 @@ This repo is a mixture of our previous team notebook, [Reykjavik University's op

## How to Contribute

### Prerequisites
- Latex and extra plugins and fonts
> **Note:** It's best to use Linux or [WSL 2](https://docs.microsoft.com/en-us/windows/wsl), if you're using Windows.

### Install requirements

To install all system & Python library requirements, simply run:

```shell
./run.sh init
```
// Warning: this could take up around 2 Gb of space

> Note: If you get a permission error, try running `chmod +x ./run.sh` first.

Alternatively, you can install the requirements individually:

- Latex and extra plugins and fonts

```shell
cat $SCRIPT_DIR/requirements.system.txt | xargs sudo apt install;

// or: (requires ~2 Gb of space)
sudo apt install texlive-latex-base
sudo apt install texlive-latex-extra
sudo apt install texlive-fonts-extra

// or simply,

// Warning: this could take up around 5 Gb of space
// or simply: (requires ~5 Gb of space)
sudo apt install texlive-full
```

- Pygments
```

```shell
pip3 install Pygments
// or
pip install Pygments
```

- Cmake, for testing
```

```shell
sudo apt install cmake
```

#### Pre-commit

We use [Pre-commit](https://pre-commit.com/) to make sure the codes are properly linted.

- Install Pre-commit using `pip3 install pre-commit`.
- Then run `pre-commit install` to setup the git hook scripts.

### Contribution Workflow:
### Contribution Workflow

1. Clone this repository using `git clone https://github.com/admu-progvar/progvar-library.git`
2. Create a new branch using `git checkout -b [add your 2-letter initials here]--[branch code]`. For example `git checkout -b fc--edit-readme`
3. Add codes to the folder `/pvl`
4. Add tests if necessary. See the section below for more details.
5. Add an abridged version of your codes to `/pvl/abridged`
6. Document your codes in `notebook.tex`
7. Run `notebook/makefile.sh` to generate the notebook
8. Submit a pull request
9. Tag someone to review your code
10. Merge your PR only after receiving at least 1 approval from a reviewer
3. Install the requirements using `./run.sh init`
4. Add codes to the folder `/pvl`
5. Add tests if necessary. See [Testing](#tests) for more info.
6. Add an abridged version of your codes to `/pvl/abridged`
7. Document your codes in `notebook.tex`
8. Run `./run.sh build-notebook` to generate the notebook
9. Submit a pull request
10. Tag someone to review your code
11. Merge your PR only after receiving at least 1 approval from a reviewer

### Tests

We use [GoogleTest](https://github.com/google/googletest) for writing tests for C++.

#### Adding tests

- Add tests in the `/tests` directory. Say, `hello_test.cc`.
- Add the following to `/tests/CMakeLists.txt`:
```

```shell
add_executable([Name of Test] /path/to/test/hello_test.cc)
target_link_libraries([Name of Test] gtest_main)
gtest_discover_tests([Name of Test])
```
#### Testing
- First, go to `/tests/`
```
cd tests
```
- Then build the tests
```
cmake -S . -B build && cmake --build build
```
- Go to `build/`
```
cd build
```
- And finally, run the tests
```
ctest

#### Running the tests

Simply run:

```shell
./run.sh test
```

### (sub)(sub)Section Syntax:
### (sub)(sub)Section Syntax

- <span style="color:red">Red</span>: copy-pasted / non-tested code.
- <span style="color:black">Black</span>: either no code yet or we intentionally removed it from the default format of the team notebook.
- To color a (sub)(sub)section, simple use `(sub)(sub)section(COLOR)`
- For example, `subsectionBlack` gets you a black-colored subsection

### Todo

- Add layout.txt
- Add more tests
- Add implementation of:
Expand All @@ -109,10 +131,18 @@ ctest
- Add benchmarking with [Google Benchmark](https://github.com/google/benchmark)

## Maintainers

### Lead Maintainer

- [Franz Louis Cesista](https://github.com/leloykun)
- World Finalist on the [International Collegiate Programming Contest](https://icpc.global/)
- Software Engineer @ [Expedock](https://www.expedock.com/)
- 2x World Finalist on the [International Collegiate Programming Contest](https://icpc.global/)
- 2x Wolrd Finalist on the [International Olympiad in Informatics](https://ioinformatics.org/)
- Machine Learning Research Engineer @ [Expedock](https://www.expedock.com/)
- BS Mathematics @ Ateneo de Manila

### Contributors

- Ateneo's Programming Varsity Alumni
- [Justin M. Tan](https://github.com/bullybutcher)
- [Raphael Jose A. Montemayor](https://github.com/rap2montemayor)
- [Mark Kevin A. Ong Yiu](https://github.com/ongyiumark)
6 changes: 0 additions & 6 deletions notebook/Makefile

This file was deleted.

22 changes: 22 additions & 0 deletions notebook/build_notebook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
while getopts n: flag
do
case "${flag}" in
n) teamname=${OPTARG};;
esac
done

rm -rf *.{aux,log,toc,fls,fdb_latexmk} _code/ _docs/
python3 preprocess.py
# python3 build_tex.py

echo "Building truncated notebook for team $teamname..."
pdflatex -shell-escape -jobname="notebook-trunc" "\def\ICPCCONFIG{1} \def\TEAMNAME{$teamname} \input{notebook.tex}"
pdflatex -shell-escape -jobname="notebook-trunc" "\def\ICPCCONFIG{1} \def\TEAMNAME{$teamname} \input{notebook.tex}"
echo "Finished building truncated notebook for team $teamname."

echo "Building full notebook for team $teamname..."
pdflatex -shell-escape "\def\ICPCCONFIG{1} \def\TEAMNAME{$teamname} \input{notebook.tex}"
pdflatex -shell-escape "\def\ICPCCONFIG{1} \def\TEAMNAME{$teamname} \input{notebook.tex}"
echo "Finished building full notebook for team $teamname."

rm -rf *.{aux,log,toc,fls,fdb_latexmk} _minted-notebook*
113 changes: 69 additions & 44 deletions notebook/build_tex.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,71 @@
import os

for path, dirs, files in os.walk('./structure'):
for f in files:
if not f.endswith('.md'): continue

p = os.path.join(path, f)
fout_tex = os.path.join("tex", '.'.join(f.split('.')[:-1]) + '.tex')
print(fout_tex)

try:
os.makedirs(os.path.dirname(fout_tex))
print("Created file", fout_tex)
except:
print("Couldn't create file", fout_tex)
pass

dat = [line for line in open(p).read().splitlines()]

with open(fout_tex, 'w') as out:
print("\\section{{{}}}".format(dat[0]), file=out)
for line in dat[1:]:
num_spaces = len(line) - len(line.lstrip()) + 2
subs = num_spaces//2
line = line.lstrip()[2:]
blocks = line.split('|')

if "comment" in blocks: continue

if (line.endswith(".cpp") or line.endswith('.java') or
line.endswith('.sh') or line.endswith('.py')):

fdocs = os.path.join("_docs", f[:-3], '.'.join(blocks[-1].split('.')[:-1]) + '.md')
with open(fdocs, 'r') as fdocs_:
for doc_line in fdocs_.readlines():
if len(doc_line.strip()) == 0: continue
print(" "*num_spaces + doc_line, end="", file=out)

print(" "*num_spaces + "\\code{{{}/{}}}".format(f[:-3], blocks[-1]), file=out)
else:
if "black" in blocks:
print(" "*num_spaces + "\\" + "sub" * subs + "sectionBlack{{{}}}".format(blocks[-1]), file=out)
elif "red" in blocks:
print(" "*num_spaces + "\\" + "sub" * subs + "sectionRed{{{}}}".format(blocks[-1]), file=out)
else:
print(" "*num_spaces + "\\" + "sub" * subs + "section{{{}}}".format(blocks[-1]), file=out)
for path, dirs, files in os.walk("./structure"):
for f in files:
if not f.endswith(".md"):
continue

p = os.path.join(path, f)
fout_tex = os.path.join("tex", ".".join(f.split(".")[:-1]) + ".tex")
print(fout_tex)

os.makedirs(os.path.dirname(fout_tex), exist_ok=True)

dat = [line for line in open(p).read().splitlines()]

with open(fout_tex, "w") as out:
print("\\section{{{}}}".format(dat[0]), file=out)
for line in dat[1:]:
num_spaces = len(line) - len(line.lstrip()) + 2
subs = num_spaces // 2
line = line.lstrip()[2:]
blocks = line.split("|")

if "comment" in blocks:
continue

if (
line.endswith(".cpp")
or line.endswith(".java")
or line.endswith(".sh")
or line.endswith(".py")
):

fdocs = os.path.join(
"_docs", f[:-3], ".".join(blocks[-1].split(".")[:-1]) + ".md"
)
with open(fdocs, "r") as fdocs_:
for doc_line in fdocs_.readlines():
if len(doc_line.strip()) == 0:
continue
print(" " * num_spaces + doc_line, end="", file=out)

print(
" " * num_spaces + "\\code{{{}/{}}}".format(f[:-3], blocks[-1]),
file=out,
)
else:
if "black" in blocks:
print(
" " * num_spaces
+ "\\"
+ "sub" * subs
+ "sectionBlack{{{}}}".format(blocks[-1]),
file=out,
)
elif "red" in blocks:
print(
" " * num_spaces
+ "\\"
+ "sub" * subs
+ "sectionRed{{{}}}".format(blocks[-1]),
file=out,
)
else:
print(
" " * num_spaces
+ "\\"
+ "sub" * subs
+ "section{{{}}}".format(blocks[-1]),
file=out,
)
Loading