remove react-katex

helps reduce bundle size; trying to eliminate katex entirely
This commit is contained in:
Nathan Wang 2020-07-15 17:57:00 -07:00
parent 2a6348f62d
commit 5a28057def
6 changed files with 162 additions and 56 deletions

View file

@ -121,28 +121,38 @@ $$
<center>
<table>
<thead>
<tr>
<th>Index <IM>i</IM></th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>
</thead>
<tbody>
<tr>
<td><IM>{`\\texttt{arr}[i]`}</IM></td>
<td>1</td>
<td className="bg-yellow-100">6</td>
<td className="bg-yellow-100">4</td>
<td className="bg-yellow-100">2</td>
<td className="bg-yellow-100">5</td>
<td>3</td>
</tr>
</tbody>
<thead>
<tr>
<th>
<!-- extremely dumb formatting should be fixed by better mdx parser in mdx 2.0 -->
Index $ijkl$
</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>
</thead>
<tbody>
<tr>
<td>
$\texttt{arr}[i]$
</td>
<td>1</td>
<td className="bg-yellow-100">6</td>
<td className="bg-yellow-100">4</td>
<td className="bg-yellow-100">2</td>
<td className="bg-yellow-100">5</td>
<td>3</td>
</tr>
</tbody>
</table>
</center>
@ -155,30 +165,38 @@ $$
<center>
<table>
<thead>
<tr>
<th>Index <IM>i</IM></th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>
</thead>
<tbody>
<tr>
<td><IM>{`\\texttt{prefix}[i]`}</IM></td>
<td className="bg-red-100">0</td>
<td className="bg-red-100">1</td>
<td className="bg-green-100">7</td>
<td className="bg-green-100">11</td>
<td className="bg-green-100">13</td>
<td className="bg-green-100">18</td>
<td>21</td>
</tr>
</tbody>
<thead>
<tr>
<th>
Index $i$
</th>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</tr>
</thead>
<tbody>
<tr>
<td>
$\texttt{prefix}[i]$
</td>
<td className="bg-red-100">0</td>
<td className="bg-red-100">1</td>
<td className="bg-green-100">7</td>
<td className="bg-green-100">11</td>
<td className="bg-green-100">13</td>
<td className="bg-green-100">18</td>
<td>21</td>
</tr>
</tbody>
</table>
</center>
@ -198,7 +216,9 @@ Now we'll look at some extensions.
This problem has a solution known as [Kadane's Algorithm](https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane's_algorithm). Please don't use that solution; try to solve it with prefix sums.
<spoiler title="Why are the two methods equivalent?">
Consider the desired maximum subarray. As you go along from left to right, the prefix sum solution will mark the start of that subarray as the "current minimum prefix sum". Kadane's Algorithm, on the other hand, will set the current value to 0 at that point. As both solutions iterate through the array, they eventually find the right side of the maximum sum, and they find the answer to the problem at that location. In essence, Kadane's Algorithm stores the maximum sum of a subarray that ends at the current location (which is what the prefix sum solution calculates on each iteration), but it calculates this value greedily instead.
Consider the desired maximum subarray. As you go along from left to right, the prefix sum solution will mark the start of that subarray as the "current minimum prefix sum". Kadane's Algorithm, on the other hand, will set the current value to 0 at that point. As both solutions iterate through the array, they eventually find the right side of the maximum sum, and they find the answer to the problem at that location. In essence, Kadane's Algorithm stores the maximum sum of a subarray that ends at the current location (which is what the prefix sum solution calculates on each iteration), but it calculates this value greedily instead.
</spoiler>
## Prefix Minimum, XOR, etc.

View file

@ -99,6 +99,7 @@ export const plugins = [
// cookieDomain: "example.com",
},
},
'gatsby-plugin-webpack-bundle-analyser-v2',
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,

View file

@ -38,7 +38,6 @@
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-helmet": "^6.1.0",
"react-katex": "^2.0.2",
"react-transition-group": "^4.4.1",
"rehype-react": "^6.0.0",
"remark": "^12.0.0",
@ -50,6 +49,7 @@
"typescript": "^3.9.5"
},
"devDependencies": {
"gatsby-plugin-webpack-bundle-analyser-v2": "^1.1.10",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5"

View file

@ -4,7 +4,6 @@ import SpoilerComponent from './SpoilerComponent';
import { ProblemsListComponent } from './Problems';
import { ResourceComponent, ResourcesListComponent } from './Resources';
import CodeBlock from './CodeBlock';
import { InlineMath } from 'react-katex';
import classNames from 'classnames';
import Asterisk from '../tooltip/Asterisk';
import TextTooltip from '../tooltip/TextTooltip';
@ -107,7 +106,6 @@ const components = {
className="font-mono inline bg-gray-200 rounded px-1 py-05"
/>
),
IM: ({ children }) => <InlineMath>{children}</InlineMath>,
LanguageSection: LanguageSection,
CPPSection: CPPSection,
JavaSection: JavaSection,
@ -117,10 +115,15 @@ const components = {
table: ({ className, ...props }) => (
<table
{...props}
className={classNames('text-base border-gray-600', className)}
className={classNames(
'text-base border-gray-600 no-bottom-margin',
className
)}
/>
),
th: props => <th {...props} className="border py-1 px-3" />,
th: ({ className, ...props }) => (
<th {...props} className={classNames('border py-1 px-3', className)} />
),
td: ({ className, ...props }) => (
<td {...props} className={classNames('border py-1 px-3', className)} />
),

View file

@ -1029,6 +1029,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.10.1":
version "7.10.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.10.5.tgz#303d8bd440ecd5a491eae6117fd3367698674c5c"
integrity sha512-otddXKhdNn7d0ptoFRHtMLa8LqDxLYwTjB4nYgM1yy5N6gU/MUf8zqyyLltCH3yAVitBzmwK4us+DD0l/MauAg==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/standalone@^7.10.3":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/standalone/-/standalone-7.10.3.tgz#aaabbf0fcfc82d595d3e1b9467b201d1a33a6e64"
@ -2359,7 +2366,7 @@ acorn-node@^1.6.1:
acorn-walk "^7.0.0"
xtend "^4.0.2"
acorn-walk@^7.0.0:
acorn-walk@^7.0.0, acorn-walk@^7.1.1:
version "7.2.0"
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc"
integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==
@ -3144,6 +3151,16 @@ better-queue@^3.8.10:
node-eta "^0.9.0"
uuid "^3.0.0"
bfj@^6.1.1:
version "6.1.2"
resolved "https://registry.yarnpkg.com/bfj/-/bfj-6.1.2.tgz#325c861a822bcb358a41c78a33b8e6e2086dde7f"
integrity sha512-BmBJa4Lip6BPRINSZ0BPEIfB1wUY/9rwbwvIHQA1KjX9om29B6id0wnWXq7m3bn5JrUVjeOTnVuhPT1FiHwPGw==
dependencies:
bluebird "^3.5.5"
check-types "^8.0.3"
hoopy "^0.1.4"
tryer "^1.0.1"
big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
@ -3815,6 +3832,11 @@ charenc@~0.0.1:
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
integrity sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=
check-types@^8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552"
integrity sha512-YpeKZngUmG65rLudJ4taU7VLkOCTMhNl/u4ctNC56LQS/zJTyNH0Lrtwm1tfTsbLlwvlfsA2d1c8vCf/Kh2KwQ==
cheerio@^0.22.0:
version "0.22.0"
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e"
@ -4122,7 +4144,7 @@ command-exists@^1.2.4:
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==
commander@^2.19.0, commander@^2.20.0, commander@^2.20.3:
commander@^2.18.0, commander@^2.19.0, commander@^2.20.0, commander@^2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
@ -5403,6 +5425,11 @@ ee-first@1.1.1:
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
ejs@^2.6.1:
version "2.7.4"
resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.7.4.tgz#48661287573dcc53e366c7a1ae52c3a120eec9ba"
integrity sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==
electron-to-chromium@^1.3.413:
version "1.3.480"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.480.tgz#190ae45074578349a4c4f336fba29e76b20e9ef5"
@ -6039,7 +6066,7 @@ express-graphql@^0.9.0:
http-errors "^1.7.3"
raw-body "^2.4.1"
express@^4.17.1:
express@^4.16.3, express@^4.17.1:
version "4.17.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134"
integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==
@ -6373,6 +6400,11 @@ filesize@3.5.11:
resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee"
integrity sha512-ZH7loueKBoDb7yG9esn1U+fgq7BzlzW6NRi5/rMdxIZ05dj7GFD/Xc5rq2CDt5Yq86CyfSYVyx4242QQNZbx1g==
filesize@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.6.1.tgz#090bb3ee01b6f801a8a8be99d31710b3422bb317"
integrity sha512-7KjR1vv6qnicaPMi1iiTcI85CyYwRO/PSFCu6SvqL8jN2Wjt/NIYQTFtFs7fSDCYOstUkEWIQGFUg5YZQfjlcg==
fill-range@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
@ -6880,6 +6912,14 @@ gatsby-plugin-typescript@^2.4.8:
"@babel/runtime" "^7.10.3"
babel-plugin-remove-graphql-queries "^2.9.7"
gatsby-plugin-webpack-bundle-analyser-v2@^1.1.10:
version "1.1.10"
resolved "https://registry.yarnpkg.com/gatsby-plugin-webpack-bundle-analyser-v2/-/gatsby-plugin-webpack-bundle-analyser-v2-1.1.10.tgz#756ad6c7e01387d6044a26d7f7f6821a8e31f49a"
integrity sha512-VQtMIRcflAlMpauQZy/VnCb5SzTWhYw1jKZaVwAm+oaIdHav8xCAyg9hoQ849x46dUdk8/H3dnz5U6h+Z2MbLA==
dependencies:
"@babel/runtime" "^7.10.1"
webpack-bundle-analyzer "^3.8.0"
gatsby-react-router-scroll@^3.0.7:
version "3.0.7"
resolved "https://registry.yarnpkg.com/gatsby-react-router-scroll/-/gatsby-react-router-scroll-3.0.7.tgz#53e9e4e81dfde94c23d724f8e6b4778db9d7edb1"
@ -7681,6 +7721,14 @@ gzip-size@3.0.0:
dependencies:
duplexer "^0.1.1"
gzip-size@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-5.1.1.tgz#cb9bee692f87c0612b232840a873904e4c135274"
integrity sha512-FNHi6mmoHvs1mxZAds4PpdCS6QG8B4C1krxJsMutgxl5t3+GlRTzzI3NEkifXx2pVsOvJdOGSmIgDhQ55FwdPA==
dependencies:
duplexer "^0.1.1"
pify "^4.0.1"
handle-thing@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e"
@ -8042,6 +8090,11 @@ homedir-polyfill@^1.0.1:
dependencies:
parse-passwd "^1.0.0"
hoopy@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d"
integrity sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==
hosted-git-info@^2.1.4:
version "2.8.8"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
@ -10879,6 +10932,11 @@ opencollective-postinstall@^2.0.2:
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259"
integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==
opener@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed"
integrity sha512-goYSy5c2UXE4Ra1xixabeVh1guIX/ZV/YokJksb6q2lubWu6UbvPQ20p542/sFIll1nl8JnCyK9oBaOcCWXwvA==
opentracing@^0.14.4:
version "0.14.4"
resolved "https://registry.yarnpkg.com/opentracing/-/opentracing-0.14.4.tgz#a113408ea740da3a90fde5b3b0011a375c2e4268"
@ -14703,6 +14761,11 @@ trough@^1.0.0:
resolved "https://registry.yarnpkg.com/true-case-path/-/true-case-path-2.2.1.tgz#c5bf04a5bbec3fd118be4084461b3a27c4d796bf"
integrity sha512-0z3j8R7MCjy10kc/g+qg7Ln3alJTodw9aDuVWZa3uiWqfuBMKeAeP2ocWcxoyM3D73yz3Jt/Pu4qPr4wHSdB/Q==
tryer@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
ts-invariant@^0.4.0:
version "0.4.4"
resolved "https://registry.yarnpkg.com/ts-invariant/-/ts-invariant-0.4.4.tgz#97a523518688f93aafad01b0e80eb803eb2abd86"
@ -15477,6 +15540,25 @@ web-namespaces@^1.0.0, web-namespaces@^1.1.2:
resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.4.tgz#bc98a3de60dadd7faefc403d1076d529f5e030ec"
integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==
webpack-bundle-analyzer@^3.8.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-3.8.0.tgz#ce6b3f908daf069fd1f7266f692cbb3bded9ba16"
integrity sha512-PODQhAYVEourCcOuU+NiYI7WdR8QyELZGgPvB1y2tjbUpbmcQOt5Q7jEK+ttd5se0KSBKD9SXHCEozS++Wllmw==
dependencies:
acorn "^7.1.1"
acorn-walk "^7.1.1"
bfj "^6.1.1"
chalk "^2.4.1"
commander "^2.18.0"
ejs "^2.6.1"
express "^4.16.3"
filesize "^3.6.1"
gzip-size "^5.0.0"
lodash "^4.17.15"
mkdirp "^0.5.1"
opener "^1.5.1"
ws "^6.0.0"
webpack-dev-middleware@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-3.7.2.tgz#0019c3db716e3fa5cecbf64f2ab88a74bab331f3"
@ -15897,7 +15979,7 @@ ws@^5.2.0:
dependencies:
async-limiter "~1.0.0"
ws@^6.2.1:
ws@^6.0.0, ws@^6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-6.2.1.tgz#442fdf0a47ed64f59b6a5d8ff130f4748ed524fb"
integrity sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==