From 1c1346689eb51bc620210f2c8761881e48f25ca9 Mon Sep 17 00:00:00 2001
From: Barrett Ruth
Date: Sun, 23 Feb 2025 18:41:56 -0500
Subject: [PATCH] feat(cses): more problems
---
posts/algorithms/cp-log.html | 193 ++++++++++++++++++-----------------
styles/post.css | 1 +
2 files changed, 103 insertions(+), 91 deletions(-)
diff --git a/posts/algorithms/cp-log.html b/posts/algorithms/cp-log.html
index fe30e69..e905a1f 100644
--- a/posts/algorithms/cp-log.html
+++ b/posts/algorithms/cp-log.html
@@ -191,97 +191,108 @@
Everyone recommends CSES so I started with it, doing the first 8
problems.
-
- Trivial, but I forgot to print 1 at the end.
-
- Return the exactly correct answer.
-
-
- N/A
-
- Use invariants.
-
-
- Run through one iteration of the algorithm. Here, I erroneously
- added x - last to a quantity,
- after manipulating x.
-
-
-
- I'd seen this problem before yet struggled.
- Fully understand the problem constraints. In this case, While
- I understood the definition of a permissible permutation, I didn't
- fully internalize that you could place number wherever you
- want. Instead, I was locked in on placing some x at
- i, i + 2, i + 4, .... Further, the fact that I didn't
- immediately recognize this solution means I need to improve at
- upsolving and reviewing problems.
-
-
-
- Absolutely disastrous. I continually just f*dged with the offsets I
- was adding to my strategy until I happened to get the answer right.
- Don't guess. Also,
- don't be lazy—if an algorithm works, focus, write it out,
- and enjoy being correct.
-
-
-
- Required 2 hints from Sam Altman. git gud at combinatorics.
- Use the paradigm "count good, remove bad." Lock in less on counting
- specifics—instead, consider what objects
- mean in aggregate. In this case, a \(2\times3\) grid
- represents an "area" of attack, contributing 2 bad knight pairs.
- This is much easier to digest then attempting to remove overcounting
- per-knight. Fundamentally, the problem involves placing 2 knights,
- so breaking it down 2 knights at a time is the most intuitive take.
-
-
-
- Don't lock in on one approach. Here, this is dp. The fact
- that I knew the idea of partitioning the first \(n\) numbers into
- two groups of size \(\frac{n(n+1)}{4}\) but failed to recognize the
- greedy approach means I didn't grasp the fundamental arithmetic of
- the problem, nor the greedy idea: every number must go into a set.
- If you add the largest number possible to set 1 to not exceed the
- target, this number can always be formed in the other set by
- choosing \(1\) and \(x-1\). git gud at greedy.
-
+
+ -
+ weird algorithm: Trivial, but I forgot to print 1 at the end.
+ Return the exactly correct answer.
+
+ -
+
+ missing number : N/A
+
+ -
+
+ repetitions : Use invariants.
+
+ -
+
+ increasing array : Run through one iteration of the algorithm. Here, I erroneously
+ added
x - last to a quantity,
+ after manipulating x.
+
+ -
+ permutations: I'd seen this problem before yet struggled.
+ Fully understand the problem constraints. In this case,
+ While I understood the definition of a permissible permutation, I
+ didn't fully internalize that you could place number
+ wherever you want. Instead, I was locked in on placing some
+
x at i, i + 2, i + 4, .... Further, the
+ fact that I didn't immediately recognize this solution means I
+ need to improve at upsolving and reviewing problems.
+
+ -
+ permutations: Absolutely disastrous. I continually just f*dged with the
+ offsets I was adding to my strategy until I happened to get the
+ answer right. Don't guess. Also,
+ don't be lazy—if an algorithm works, focus, write it out,
+ and enjoy being correct.
+
+ -
+ two knights: Required 2 hints from Sam Altman.
+ git gud at combinatorics. Use the paradigm "count good,
+ remove bad." Lock in less on counting specifics—instead,
+ consider what objects mean in aggregate. In this case, a
+ \(2\times3\) grid represents an "area" of attack, contributing 2
+ bad knight pairs. This is much easier to digest then attempting to
+ remove overcounting per-knight. Fundamentally, the problem
+ involves placing 2 knights, so breaking it down 2 knights at a
+ time is the most intuitive take.
+
+ -
+ two sets: Don't lock in on one approach. Here, this is dp. The
+ fact that I knew the idea of partitioning the first \(n\) numbers
+ into two groups of size \(\frac{n(n+1)}{4}\) but failed to
+ recognize the greedy approach means I didn't grasp the fundamental
+ arithmetic of the problem, nor the greedy idea: every number must
+ go into a set. If you add the largest number possible to set 1 to
+ not exceed the target, this number can always be formed in the
+ other set by choosing \(1\) and \(x-1\). git gud at greedy.
+
+
+ more cses—22/2/2025
+
+ -
+ gray code: Missed the pattern + gave up too late
+
+ -
+ towers of hanoi: Recursive grasp is limp—missed the idea.
+ Math/proof grasp too—still don't understand how its
+ \(2^n\).
+
+ -
+ apple division: I got distracted by the idea that it was NP-hard. Even when Sam
+ Altman told me it was DP, I failed to simplify it to "add every
+ element either to one or the other set".
+
+ -
+ digit queries:
+ got the idea + time complexity quickly, but the
+ math-based implementation is weak. Jumped into the code
+ before outlining a strict plan.
+
+
diff --git a/styles/post.css b/styles/post.css
index fb2e73a..c883b7e 100644
--- a/styles/post.css
+++ b/styles/post.css
@@ -15,6 +15,7 @@ header {
ul {
list-style: unset;
+ list-style-type: "- ";
}
li {