Skip to content

Commit 115a681

Browse files
authored
feat: add docusaurus website (#126)
1 parent 8a4959e commit 115a681

18 files changed

+16045
-0
lines changed

.github/workflows/gh_pages_deploy.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Deploy Docusaurus to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: "lts/hydrogen"
20+
21+
- name: Navigate to website folder
22+
working-directory: ./website
23+
run: echo "Now in the website directory."
24+
25+
- name: Install dependencies
26+
working-directory: ./website
27+
run: npm install
28+
29+
- name: Build Docusaurus
30+
working-directory: ./website
31+
run: npm run build
32+
33+
- name: Deploy to GitHub Pages
34+
uses: peaceiris/actions-gh-pages@v3
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
publish_dir: ./website/build
38+
publish_branch: gh-pages
39+
40+
- name: Notify success
41+
run: echo "Deployment successful on GitHub Pages."

website/.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://github.com/github/linguist/blob/master/docs/overrides.md#using-gitattributes
2+
*.css linguist-vendored
3+
*.js linguist-vendored

website/.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Luis Miguel Báez
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

website/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

website/babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};

website/docs/intro.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
sidebar_position: 1
3+
sidebar_label: Intro
4+
---
5+
6+
# Welcome to My Cpp Algorithm Snippets Repository
7+
8+
This repository serves as a comprehensive collection of code snippets, mathematical formulas, and essential properties commonly utilized in competitive programming.
9+
Here, you will find a variety of resources designed to enhance your problem-solving capabilities and streamline your programming workflow.
10+
11+
> **Note:** This documentation is created with the assistance of ChatGPT and similar tools.
12+
13+
## ⚠️ Disclaimer
14+
15+
This repository is intended for educational purposes and may contain inaccuracies or incomplete information.
16+
17+
Use the content at your own discretion and responsibility as examples.
18+
19+
## Repository Contents
20+
21+
**Code Snippets**: A curated list of reusable code snippets for various programming tasks and algorithms.
22+
**Mathematical Formulas**: A collection of commonly used mathematical formulas that are essential in competitive programming.
23+
**Properties and Theorems**: Key mathematical properties and theorems relevant to algorithm design and analysis.
24+
25+
## Contributions
26+
27+
Contributions from fellow programmers and enthusiasts are highly encouraged.
28+
Feel free to submit pull requests or open issues to discuss ideas, share additional resources, or suggest enhancements!
29+
30+
## Getting Started
31+
32+
To begin, explore the folders containing specific code snippets, mathematical formulas, or properties relevant to competitive programming.
33+
Each section is organized to facilitate easy navigation and reference.
34+
35+
Thank you for visiting!

website/docs/math/_category_.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"label": "Math",
3+
"position": 3,
4+
"link": {
5+
"type": "generated-index"
6+
}
7+
}

website/docs/math/gcd-properties.md

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# GCD Properties
6+
7+
- **Blueprint of Numbers:** The GCD (Greatest Common Divisor) of a set of numbers can be thought of as a blueprint of those numbers. If you keep adding the GCD, you can make all numbers that belong to that set.
8+
9+
- **Common Divisors:** Every common divisor of $a$ and $b$ is a divisor of $\gcd(a,b)$.
10+
11+
- **Linear Combination:** $\gcd(a,b)$, where both $a$ and $b$ are non-zero, can also be defined as the smallest positive integer $d$ which can be expressed as a linear combination of $a$ and $b$ in the form
12+
13+
$$
14+
d = a \cdot p + b \cdot q
15+
$$
16+
17+
where both $p$ and $q$ are integers.
18+
19+
- **GCD with Zero:**
20+
21+
$$
22+
\gcd(a, 0) = |a|, \text{ for } a \neq 0
23+
$$
24+
25+
since any number is a divisor of 0, and the greatest divisor of $a$ is $|a|$.
26+
27+
- **Division Property:** If $a$ divides $b \cdot c$ and $\gcd(a,b) = d$, then
28+
29+
$$
30+
\frac{a}{d} \text{ divides } c
31+
$$
32+
33+
- **Scaling Property:** If $m$ is a non-negative integer, then
34+
35+
$$
36+
\gcd(m \cdot a, m \cdot b) = m \cdot \gcd(a, b)
37+
$$
38+
39+
It also follows from this property that if $\gcd(a,b) = g$, then
40+
41+
$$
42+
\frac{a}{g} \text{ and } \frac{b}{g} \text{ should be coprime.}
43+
$$
44+
45+
- **Translation Property:** If $m$ is any integer,
46+
47+
$$
48+
\gcd(a,b) = \gcd(a + m \cdot b, b)
49+
$$
50+
51+
- **Euclidean Algorithm:** The GCD can be found using the Euclidean algorithm:
52+
53+
$$
54+
\gcd(a, b) = \gcd(b, a \mod b)
55+
$$
56+
57+
- **Common Divisor Scaling:** If $m$ is a positive common divisor of $a$ and $b$, then
58+
59+
$$
60+
\gcd\left(\frac{a}{m}, \frac{b}{m}\right) = \frac{\gcd(a, b)}{m}
61+
$$
62+
63+
- **Multiplicative Function:** The GCD is a multiplicative function. That is, if $a_1$ and $a_2$ are coprime,
64+
65+
$$
66+
\gcd(a_1 \cdot a_2, b) = \gcd(a_1, b) \cdot \gcd(a_2, b)
67+
$$
68+
69+
In particular, recalling that GCD is a positive integer-valued function, we obtain that
70+
71+
$$
72+
\gcd(a, b \cdot c) = 1 \text{ if and only if } \gcd(a, b) = 1 \text{ and } \gcd(a, c) = 1.
73+
$$
74+
75+
If the GCD is one, then they need not be coprime to distribute the GCD; moreover, each GCD individually should also be 1.
76+
77+
- **Commutative Property:** The GCD is a commutative function:
78+
79+
$$
80+
\gcd(a, b) = \gcd(b, a)
81+
$$
82+
83+
- **Associative Property:** The GCD is an associative function:
84+
85+
$$
86+
\gcd(a, \gcd(b, c)) = \gcd(\gcd(a, b), c)
87+
$$
88+
89+
Thus,
90+
91+
$$
92+
\gcd(a, b, c, \ldots)
93+
$$
94+
95+
can be used to denote the GCD of multiple arguments.
96+
97+
- **Relation with LCM:** $\gcd(a, b)$ is closely related to the least common multiple $\operatorname{lcm}(a, b)$: we have
98+
99+
100+
$$
101+
\gcd(a, b) \cdot \operatorname{lcm}(a, b) = |a \cdot b|
102+
$$
103+
- **the Subtraction Property of GCD or Substitution Lemma:** It forms one of the foundational principles of the Euclidean Algorithm, which leverages the idea of subtracting the smaller number from the larger one to reduce the problem of finding the GCD to smaller numbers.
104+
In general terms, this property expresses that the GCD remains unchanged when multiples of one number are subtracted from the other. Thus, we can state:
105+
106+
$$
107+
\gcd(a, b) = \gcd(a - b, b)
108+
$$
109+
110+
- **Distributivity Versions:** The following versions of distributivity hold true:
111+
112+
$$
113+
\gcd(a, \operatorname{lcm}(b, c)) = \operatorname{lcm}(\gcd(a, b), \gcd(a, c))
114+
$$
115+
116+
$$
117+
\operatorname{lcm}(a, \gcd(b, c)) = \gcd(\operatorname{lcm}(a, b), \operatorname{lcm}(a, c))
118+
$$
119+
120+
- **Prime Factorization:** If we have the unique prime factorizations of $a = p_1^{e_1} p_2^{e_2} \cdots p_m^{e_m}$ and $b = p_1^{f_1} p_2^{f_2} \cdots p_m^{f_m}$, where $e_i \geq 0$ and $f_i \geq 0$, then the GCD of $a$ and $b$ is:
121+
122+
$$
123+
\gcd(a,b) = p_1^{\min(e_1,f_1)} p_2^{\min(e_2,f_2)} \cdots p_m^{\min(e_m,f_m)}
124+
$$
125+
126+
- **Cartesian Coordinate System Interpretation:** In a Cartesian coordinate system, $\gcd(a, b)$ can be interpreted as the number of segments between points with integral coordinates on the straight line segment joining the points $(0, 0)$ and $(a, b)$.
127+
128+
- **Euclidean Algorithm in Base $n$:** For non-negative integers $a$ and $b$, where $a$ and $b$ are not both zero, provable by considering the Euclidean algorithm in base $n$, it simply states that:
129+
130+
$$
131+
\gcd(n^a - 1, n^b - 1) = n^{\gcd(a, b)} - 1
132+
$$
133+
134+
If you want an informal proof, think of numbers in base 2. We are calculating GCDs of numbers which contain all continuous 1s in their binary representations. For example: 001111 and 000011; their GCD can be the greatest common length, which in this case is 2. Thus, the GCD becomes 000011. Think of numbers in terms of length; maybe you get the idea.
135+
136+
- **Euler's Totient Function Identity:** An identity involving Euler's totient function:
137+
138+
$$
139+
\gcd(a,b) = \sum \phi(k)
140+
$$
141+
142+
where $k$ are all common divisors of $a$ and $b$.
143+

0 commit comments

Comments
 (0)