Skip to content

Commit 529772e

Browse files
committed
update lectures
1 parent 7315360 commit 529772e

34 files changed

+482
-564
lines changed

algo4dfm/ai-programming.md

Lines changed: 81 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ class: typo, typo-selection
66
count: false
77
class: nord-dark, middle, center
88

9-
# Lecture 2b: Programming in the Age of AI 🤖
9+
# 📚 Lecture 2b: Programming in the Age of AI 🤖
1010

11-
@luk036
11+
@luk036
1212

13-
2024-09-11
13+
📅 2024-09-11
1414

1515
---
1616

1717
![image](figs/the-earth-is-flat.png)
1818

1919
---
2020

21-
## Coding Tips 💡
21+
## 💻 Coding Tips 💡
2222

2323
.pull-left[
2424

25-
- Test, test, test!!!
26-
- Write cleaner code
27-
- Refactor repeat codes
28-
- Object oriented programming
29-
- Generic programming
30-
- Design Pattern
31-
- Coroutine is your friend
32-
- Learn from good codes, not bad ones.
33-
- The last rescue: Google search.
25+
- 🧪 Test, test, test!!!
26+
- Write cleaner code
27+
- 🔄 Refactor repeat codes
28+
- 🧩 Object-oriented programming
29+
- 🧠 Generic programming
30+
- 🏗️ Design Patterns
31+
- 🔄 Coroutines are your friends
32+
- 📚 Learn from good code, not bad ones
33+
- 🔍 The last resort: Google search
3434

3535
] .pull-right[
3636

@@ -44,27 +44,31 @@ class: nord-dark, middle, center
4444

4545
---
4646

47-
## Code generation
47+
## 🤖 AI Code Generation Tools
4848

49-
- AWS CodeWhisperer
50-
- generate testing code
51-
- Cody AI
49+
- **AWS CodeWhisperer**
50+
- Automated test generation
51+
- **Cody AI** (Sourcegraph)
5252

5353
---
5454

55-
## Documentation generation
55+
## 📝 Documentation Generation
5656

57-
Mintlify (VSCode's extension)
57+
**Mintlify** (VSCode extension)
5858

59-
- Naming
60-
- a, i, p, n ❌
61-
- A x = b
62-
- x: unknown, x_axis
63-
- x, y, z
59+
### Naming Best Practices:
60+
- Avoid single-letter names ❌
61+
`a, i, p, n`
62+
- Example equation:
63+
`A x = b`
64+
- Good names:
65+
`x: unknown, x_axis`
66+
- Coordinate variables:
67+
`x, y, z`
6468

6569
---
6670

67-
## Use better variable names
71+
## 📛 Better Naming Conventions
6872

6973
- p: point, polygon, polynomial, prev
7074
- t: time, target, temp
@@ -83,26 +87,26 @@ Mintlify (VSCode's extension)
8387

8488
---
8589

86-
## 🚀 Performance Tips 💡
90+
## 🚀 Performance Optimization Tips
8791

88-
- Avoid string comparison
89-
- Use sentinel
90-
- Use cheaper measure, avoid `sqrt()`, `sin()`, `cos()`
91-
- Lazy evaluation
92-
- Table lookup
93-
- Avoid sequence search:
94-
- Backward pointers
95-
- Hash Table/Dictionary/Map
92+
- 🚫 Avoid string comparisons
93+
- 🛡️ Use sentinel values
94+
- Use cheaper computations (avoid `sqrt()`, `sin()`, `cos()`)
95+
- 🦥 Lazy evaluation
96+
- 📚 Table lookups
97+
- 🔍 Avoid sequence searches:
98+
- 🔙 Backward pointers
99+
- Hash Tables/Dictionaries/Maps
96100

97101
---
98102

99-
## Avoid string comparison
103+
## 🚫 Avoid String Comparisons
100104

101105
.pull-left[
102106

103-
Bad 👎:
107+
### Bad Practice 👎
104108

105-
```{.python}
109+
```python
106110
if pin == "input":
107111
# ...
108112
elif pin == "output":
@@ -119,39 +123,38 @@ else:
119123

120124
.pull-right[
121125

122-
Better ⚡:
126+
### Better Practice ⚡
123127

124-
```{.python}
125-
pin_type = dict({"input":0},
126-
{"output":1}, {"in_out":2},
127-
{"dont_care":3})
128-
...
128+
```python
129+
pin_type = {
130+
"input": 0,
131+
"output": 1,
132+
"in_out": 2,
133+
"dont_care": 3
134+
}
129135
id = pin_type.get(pin, -1)
136+
130137
if id == 0:
131138
# ...
132139
elif id == 1:
133140
# ...
134-
elif id == 2:
135-
# ...
136-
elif id == 3:
137-
# ...
138141
else:
139-
# ...
142+
# ... (rest of conditions)
140143
```
141144

142145
]
143146

144147
---
145148

146-
## Use Sentinel
149+
## 🛡️ Sentinel Pattern
147150

148151
.pull-left[
149152

150-
Bad 👎:
153+
### Suboptimal 👎
151154

152155
.font-sm.mb-xs[
153156

154-
```{.python}
157+
```python
155158
max = 0
156159
bckt = [Dllist() for _ in range(high)]
157160
# ...
@@ -166,37 +169,36 @@ def popleft():
166169

167170
] .pull-right[
168171

169-
Better ⚡:
172+
### Optimized ⚡
170173

171174
.font-sm.mb-xs[
172175

173-
```{.python}
176+
```python
174177
max = 0
175178
sentinel = Dllink()
176179
bckt = [Dllist() for _ in range(high+1)]
177-
bckt[0].append(sentinel) # sentinel
178-
# ...
180+
bckt[0].append(sentinel) # Sentinel
181+
179182
def popleft():
180183
res = bckt[max].popleft()
181184
while bckt[max].empty():
182185
max -= 1
183186
return res
184-
# Saved a boundary check `max >= 0`
187+
# Eliminated boundary check
185188
```
186-
187189
]
188190

189191
]
190192

191193
---
192194

193-
## Use cheaper measure
195+
## ⚡ Cheaper Computations
194196

195197
.pull-left[
196198

197-
Bad 👎:
199+
### Inefficient 👎
198200

199-
```{.python}
201+
```python
200202
mind = 10000
201203
maxd = 0
202204
for u, v in G.edges():
@@ -207,16 +209,18 @@ for u, v in G.edges():
207209
return maxd - mind
208210
```
209211

210-
] .pull-right[
212+
]
211213

212-
Better ⚡:
214+
.pull-right[
213215

214-
```{.python}
216+
### Optimized ⚡
217+
218+
```python
215219
minq = 10000
216220
maxq = 0
217221
for u, v in G.edges():
218222
t = vec[u] - vec[v]
219-
q = t.dot(t)
223+
q = t.dot(t) # Cheaper
220224
if minq > q: minq = q
221225
if maxq < q: maxq = q
222226
return sqrt(maxq) - sqrt(minq)
@@ -226,51 +230,49 @@ return sqrt(maxq) - sqrt(minq)
226230

227231
---
228232

229-
## Another Example
233+
## Another Optimization Example
230234

231235
.pull-left[
232236

233-
Bad 👎:
237+
### Inefficient 👎
234238

235-
```{.python}
239+
```python
236240
mind = 10000
237241
maxd = 0
238242
for u, v in G.edges():
239243
t = 1 - vec[u].dot(vec[v])
240244
d = arcsin(sqrt(t))
241245
if mind > d: mind = d
242246
if maxd < d: maxd = d
243-
244247
return maxd - mind
245248
```
246249

247-
] .pull-right[
250+
]
248251

249-
Better ⚡:
252+
.pull-right[
250253

251-
```{.python}
254+
### Optimized ⚡
255+
256+
```python
252257
minq = 10000
253258
maxq = 0
254259
for u, v in G.edges():
255260
q = 1 - vec[u].dot(vec[v])
256261
if minq > q: minq = q
257262
if maxq < q: maxq = q
258-
259263
return arcsin(sqrt(maxq)) \
260-
- arcsin(sqrt(minq))
264+
- arcsin(sqrt(minq))
261265
```
262266

263267
]
264268

265269
---
266270

267-
## Optimization Tips 💡
268-
269-
- Convex optimization
270-
271-
- Network optimization
271+
## 🧮 Advanced Optimization Techniques
272272

273-
- Primal-dual paradigm
273+
- 🌰 Convex optimization
274+
- 🖧 Network optimization
275+
- ☯ Primal-dual paradigm
274276

275277
---
276278

algo4dfm/algorithm.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
class: nord-dark, middle, center
2828

29-
# Lecture 2e: Algorithmic Paradigms
29+
# 📚 Lecture 2e: Algorithmic Paradigms
3030

3131
@luk036
3232

33-
2024-11-13
33+
📅 2024-11-13
3434

3535
---
3636

algo4dfm/algorithm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class: typo, typo-selection
55

66
class: nord-dark, middle, center
77

8-
# Lecture 2e: Algorithmic Paradigms
8+
# 📚 Lecture 2e: Algorithmic Paradigms
99

1010
@luk036
1111

algo4dfm/algorithm2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class: typo, typo-selection
66
count: false
77
class: nord-dark, middle, center
88

9-
# Lecture 2e: Algorithmic Paradigms
9+
# 📚 Lecture 2e: Algorithmic Paradigms
1010

1111
@luk036
1212

algo4dfm/complexity.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
@luk036
3434

35-
2024-11-13
35+
📅 2024-11-13
3636

3737
---
3838

algo4dfm/complexity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class: typo, typo-selection
55

66
class: nord-dark, middle, center
77

8-
# Lecture 2d: Complexity Theory
8+
# 📚 Lecture 2d: Complexity Theory
99

1010
@luk036
1111

algo4dfm/cvx-prog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class: typo, typo-selection
66
count: false
77
class: nord-dark, middle, center
88

9-
# Lecture 2c: Introduction to Convex Programming
9+
# 📚 Lecture 2c: Introduction to Convex Programming
1010

1111
.pull-left[
1212

0 commit comments

Comments
 (0)