Skip to content

Commit

Permalink
Added debug and r-stretch
Browse files Browse the repository at this point in the history
  • Loading branch information
MartenBE committed Sep 9, 2024
1 parent 6e34ea0 commit 24401e7
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 60 deletions.
2 changes: 2 additions & 0 deletions docs/c1.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ _Tip: Editors with markdown support often fix these numbers automatically._

## Citation

<!-- Add 2 spaces at the end of a line to insert a newline. -->

Some pretty quote:

> The problem with 83% of the quotes found on the internet is, that they are not true.
Expand Down
8 changes: 7 additions & 1 deletion docs/c2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ title: "Chapter 2 - Advanced examples."

## Resizing images

You can specify the exact height and width using some HTML magic. Very handy if the image is too large or too small.
You can tell an image to shrink to or fill the screen by using [`r-stretch`](https://revealjs.com/layout/#stretch). Very handy if the image is too large or too small!

<img src="./img/campus-schoonmeersen.jpg" class="r-stretch" />

---

You can also specify the exact height and width using HTML.

<img src="./img/campus-schoonmeersen.jpg" height="150" /> <img src="./img/campus-schoonmeersen.jpg" width="500" /> <img src="./img/campus-schoonmeersen.jpg" style="height: 450px" />

Expand Down
277 changes: 218 additions & 59 deletions docs/debug/c3.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,89 +36,248 @@ These slides are used for debugging, otherwise there is nothing to see here ...

---

## Unordered list + Image
## Margins before/after text

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Margins before/after list

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

- Test 1
- Test 2
- Test 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Margins before/after list

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

- Test 1
- Test 2
- Test 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Margins before/after quote

![w:auto h:auto](../img/matrix-code.jpg)
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
> ~ Someone
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Ordered list + Images
## Margins before/after math

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

1. Test 1
1. Test 2
$$
S_n(x)=\sum_{k=1}^n \frac{\sin(kx)}{k} \gt 0\quad (n\geq 1,\quad 0 \lt x \lt \pi)
$$

<!-- ![](./img/test-screen.jpg) -->
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Long code
## Margins before/after table

```cpp []
class knuth_morris_pratt
{
public:
knuth_morris_pratt(const std::string_view& pattern) : m_pattern{pattern}, m_prefix_array(std::ssize(pattern))
{
assert(!m_pattern.empty());
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

m_prefix_array[0] = 0;
| abc | abc |
| --- | --- |
| xyz | 123 |
| xyz | 123 |

std::ptrdiff_t prefix_length = 0;
for (std::ptrdiff_t i = 1; i < std::ssize(m_prefix_array); i++)
{
while ((prefix_length > 0) && (m_pattern[prefix_length] != m_pattern[i]))
{
prefix_length = m_prefix_array[i];
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

if (m_pattern[prefix_length] == m_pattern[i])
{
prefix_length++;
}
---

m_prefix_array[i] = prefix_length;
}
}
## Margins before/after image

std::vector<std::ptrdiff_t> search(const std::string_view& text) const
{
std::vector<std::ptrdiff_t> found_indices;
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

if (text.empty())
{
return found_indices;
}
![](../img/hello.webp)

std::ptrdiff_t amount_matched_chars = 0;
for (std::ptrdiff_t i = 0; i < std::ssize(text); i++)
{
while ((amount_matched_chars > 0) && (m_pattern[amount_matched_chars] != text[i]))
{
amount_matched_chars = m_prefix_array[amount_matched_chars - 1];
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

if (m_pattern[amount_matched_chars] == text[i])
{
amount_matched_chars++;
}
---

if (amount_matched_chars == std::ssize(m_pattern))
{
found_indices.push_back(i - std::ssize(m_pattern) + 1);
amount_matched_chars = m_prefix_array[amount_matched_chars - 1];
}
}
## Margins before/after code

return found_indices;
}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

private:
std::string_view m_pattern;
std::vector<std::ptrdiff_t> m_prefix_array;
};
```python
def sum(a, b):
c = a + b
return c
```

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Margins before/after video

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

<iframe width="560" height="315" src="https://www.youtube.com/embed/sGF6bOi1NfA?si=Xolnp5XjGsdLB_8Q" allowfullscreen></iframe>

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

---

## Multicolumn overflow

<div class="multicolumn">
<div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

</div>
<div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

</div>
<div>

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

</div>
</div>

---

## Large code base

```python [10|30|60]
# Knuth-Morris-Pratt (KMP) Algorithm for Pattern Matching

# Function to create the Longest Prefix Suffix (LPS) array
def compute_lps_array(pattern):
length = 0 # length of the previous longest prefix suffix
lps = [0] * len(pattern) # lps[i] is the length of the longest prefix suffix of pattern[0...i]
i = 1 # Start from the second character of the pattern

# Loop to calculate lps[i] for i = 1 to len(pattern) - 1
while i < len(pattern):
if pattern[i] == pattern[length]:
length += 1
lps[i] = length
i += 1
else:
if length != 0:
length = lps[length - 1]
else:
lps[i] = 0
i += 1
return lps

# Function implementing the KMP algorithm
def kmp_search(text, pattern):
# Get the length of text and pattern
n = len(text)
m = len(pattern)

# Preprocess the pattern to compute the lps array
lps = compute_lps_array(pattern)

i = 0 # index for text[]
j = 0 # index for pattern[]

# List to store the starting indices of pattern matches
match_positions = []

while i < n:
if pattern[j] == text[i]:
i += 1
j += 1

if j == m:
# Pattern found, record the starting index
match_positions.append(i - j)
j = lps[j - 1] # Reset j using the lps array

elif i < n and pattern[j] != text[i]:
# Mismatch after j matches
if j != 0:
j = lps[j - 1]
else:
i += 1

return match_positions

# Example usage
if __name__ == "__main__":
text = "ababcabcabababd"
pattern = "ababd"

result = kmp_search(text, pattern)

if result:
print(f"Pattern found at indices: {result}")
else:
print("Pattern not found in the text.")
```

---

## Single page large image (fit)

<img src="../img/screen-test-large.jpg" class="r-stretch" />

---

## Single page small image (fit)

<img src="../img/hello.webp" class="r-stretch" />

---

## Multicolumn images

<div class="multicolumn">

<div>

![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)

</div>

<div>

![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)

</div>

<div>

![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)
![](../img/screen-test-large.jpg)

</div>

</div>

---

# The end
Binary file added docs/img/screen-test-large.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/screen-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 24401e7

Please sign in to comment.