A course handout: math definitions, a comparison table, two implementations in code tabs, a diagram
of the algorithm and a quiz whose answers appear step by step.
The demo
Try it
On the last slide, press →: each question and its answer appear in turn.
Click the code group tabs.
Search for a word of the deck (⌘K): you land on the right slide.
Source code
---
title : Lorem Ipsum Course
author : Lorem Academy
description : "A course handout with KaTeX formulas, tabbed code, a Mermaid diagram and progressive steps."
lang : en
---
--- layout=cover
# Lorem Ipsum Course
### Lectio III — dolor sit amet
--- layout=section
# 1. Lorem notatio
---
# Definitio
Lorem ipsum $f(n) = O(g(n))$ dolor sit amet $c > 0$ et $n_0$ :
$$
\forall n \geq n_0,\quad f(n) \leq c \cdot g(n)
$$
:::callout{type=info title="Nota bene"}
Lorem ipsum dolor sit amet, **consectetur** adipiscing elit.
:::
:::notes
Sed do eiusmod tempor incididunt ut labore et dolore.
:::
---
# Tabula lorem
| Lorem | Ipsum | n = 10⁶ |
| --- | --- | --- |
| $O(1)$ | dolor sit | instans |
| $O(\log n)$ | amet consectetur | 20 |
| $O(n)$ | adipiscing elit | 10⁶ |
| $O(n \log n)$ | sed do eiusmod | 2 × 10⁷ |
| $O(n^2)$ | tempor incididunt | 10¹² |
--- layout=section
# 2. Exemplum
---
# Duo exempla
:::code-group
```ts title="Lorem — O(n)"
function lorem ( items : number [], x : number ) {
for ( let i = 0 ; i < items. length ; i ++ ) {
if (items[i] === x) return i
}
return - 1
}
```
```ts title="Ipsum — O(log n)"
function ipsum ( sorted : number [], x : number ) {
let lo = 0 , hi = sorted. length - 1
while (lo <= hi) {
const mid = (lo + hi) >> 1
if (sorted[mid] === x) return mid
sorted[mid] < x ? (lo = mid + 1 ) : (hi = mid - 1 )
}
return - 1
}
```
:::
---
# Dichotomia lorem
```mermaid title="Lorem ipsum dichotomia"
graph LR
A["[1 … 100]"] -->|50 > 42| B["[1 … 49]"]
B -->|25 < 42| C["[26 … 49]"]
C -->|37 < 42| D["[38 … 49]"]
D -->|43 > 42| E["[38 … 42]"]
E --> F((42))
```
---
# Quaestiones
:::step
**Q1.** Lorem ipsum dolor sit amet?
:::
:::step
→ $O(n \log n)$ : consectetur adipiscing elit.
:::
:::step
**Q2.** Sed do eiusmod tempor incididunt?
:::
:::step
→ $O(n \log n + k \log n)$, ut labore et dolore magna aliqua.
:::