diff options
Diffstat (limited to 'slides/presentations/basic-math-in-programming/default.pug')
| -rw-r--r-- | slides/presentations/basic-math-in-programming/default.pug | 206 |
1 files changed, 0 insertions, 206 deletions
diff --git a/slides/presentations/basic-math-in-programming/default.pug b/slides/presentations/basic-math-in-programming/default.pug deleted file mode 100644 index 7ca262b..0000000 --- a/slides/presentations/basic-math-in-programming/default.pug +++ /dev/null | |||
| @@ -1,206 +0,0 @@ | |||
| 1 | section | ||
| 2 | h1 Why understanding of basic math is important for computer programing | ||
| 3 | p September 21, 2018, rev2 | ||
| 4 | a(href="https://twitter.com/mitjafelicijan") @mitjafelicijan | ||
| 5 | |||
| 6 | section | ||
| 7 | h2 Agenda | ||
| 8 | ol | ||
| 9 | li Levenshtein distance | ||
| 10 | li Shortest path algorithm | ||
| 11 | li Distance Formula | ||
| 12 | li | ||
| 13 | |||
| 14 | section.center | ||
| 15 | q We Cannot Solve Our Problems With The Same Thinking We Used When We Created Them. | ||
| 16 | footer — Albert Einstein | ||
| 17 | |||
| 18 | section | ||
| 19 | h2 How we usually find solutions and why this is problematic? | ||
| 20 | |||
| 21 | ul | ||
| 22 | li We search for code example instead of algorithms. | ||
| 23 | li We copy and paste and do testing on trial&error principle. | ||
| 24 | li We don't take enough time to properly understand problem we a re trying to solve. | ||
| 25 | li Brute force solutions we make are usually not optimized | ||
| 26 | |||
| 27 | section | ||
| 28 | h2 Levenshtein distance | ||
| 29 | p The Levenshtein distance is a string metric for measuring difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (i.e. insertions, deletions or substitutions) required to change one word into the other. | ||
| 30 | |||
| 31 | hr | ||
| 32 | |||
| 33 | div.center | ||
| 34 | img(src="levenshtein-distance.svg", height="150") | ||
| 35 | |||
| 36 | hr | ||
| 37 | |||
| 38 | div.center | ||
| 39 | img(src="test.png") | ||
| 40 | |||
| 41 | hr | ||
| 42 | |||
| 43 | pre | ||
| 44 | code.language-python | ||
| 45 | | def levenshtein(seq1, seq2): | ||
| 46 | | oneago = None | ||
| 47 | | thisrow = range(1, len(seq2) + 1) + [0] | ||
| 48 | | for x in xrange(len(seq1)): | ||
| 49 | | twoago, oneago, thisrow = oneago, thisrow, [0] * len(seq2) + [x + 1] | ||
| 50 | | for y in xrange(len(seq2)): | ||
| 51 | | delcost = oneago[y] + 1 | ||
| 52 | | addcost = thisrow[y - 1] + 1 | ||
| 53 | | subcost = oneago[y - 1] + (seq1[x] != seq2[y]) | ||
| 54 | | thisrow[y] = min(delcost, addcost, subcost) | ||
| 55 | | return thisrow[len(seq2) - 1] | ||
| 56 | |||
| 57 | |||
| 58 | hr | ||
| 59 | |||
| 60 | h4 Going further | ||
| 61 | ul | ||
| 62 | li | ||
| 63 | a(href="https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance") https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance | ||
| 64 | li | ||
| 65 | a(href="https://en.wikipedia.org/wiki/Levenshtein_distance") https://en.wikipedia.org/wiki/Levenshtein_distance | ||
| 66 | li | ||
| 67 | a(href="https://rosettacode.org/wiki/Levenshtein_distance") https://rosettacode.org/wiki/Levenshtein_distance | ||
| 68 | |||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | section | ||
| 81 | h2 Basic linear algebra | ||
| 82 | |||
| 83 | pre | ||
| 84 | code.language-css | ||
| 85 | | body { | ||
| 86 | | background: black; | ||
| 87 | | } | ||
| 88 | |||
| 89 | pre | ||
| 90 | code.language-javascript | ||
| 91 | | $(document).ready(function() { | ||
| 92 | | $('pre code').each(function(i, block) { | ||
| 93 | | hljs.highlightBlock(block); | ||
| 94 | | }); | ||
| 95 | | }); | ||
| 96 | |||
| 97 | hr | ||
| 98 | figcaption.right Step 1: Finding nearest point | ||
| 99 | |||
| 100 | div.center | ||
| 101 | img(src="drawing1.svg") | ||
| 102 | |||
| 103 | hr | ||
| 104 | figcaption.right Step 1: Finding nearest point | ||
| 105 | |||
| 106 | $$ \large{ \mathbb{R}^2 ∈ \vec{a} \bar{a} } $$ | ||
| 107 | $$ \large{ e^{i\pi} + 1 = 0 } $$ | ||
| 108 | $$ \large{ x = {-b \pm \sqrt{b^2-4ac} \over 2a} } $$ | ||
| 109 | |||
| 110 | hr | ||
| 111 | figcaption.right Step 2: Finding nearest point | ||
| 112 | |||
| 113 | pre | ||
| 114 | code.language-python | ||
| 115 | | fruits = ["apple", "banana", "cherry"] | ||
| 116 | | for x in fruits: | ||
| 117 | | if x == "banana": | ||
| 118 | | break | ||
| 119 | | print(x) | ||
| 120 | |||
| 121 | hr | ||
| 122 | figcaption.right Finding nearest point | ||
| 123 | |||
| 124 | $$ \large{ \mathbb{R}^2 ∈ \vec{a} \bar{a} } $$ | ||
| 125 | $$ \large{ e^{i\pi} + 1 = 0 } $$ | ||
| 126 | $$ \large{ x = {-b \pm \sqrt{b^2-4ac} \over 2a} } $$ | ||
| 127 | |||
| 128 | hr | ||
| 129 | figcaption.right Finding nearest point | ||
| 130 | |||
| 131 | pre | ||
| 132 | code.language-c | ||
| 133 | | #include <stdio.h> | ||
| 134 | | int main () { | ||
| 135 | | for( ; ; ) { | ||
| 136 | | printf("This loop will run forever.\n"); | ||
| 137 | | } | ||
| 138 | | return 0; | ||
| 139 | | } | ||
| 140 | |||
| 141 | hr | ||
| 142 | figcaption.right Finding nearest point | ||
| 143 | |||
| 144 | pre | ||
| 145 | code.language-python | ||
| 146 | | fruits = ["apple", "banana", "cherry"] | ||
| 147 | | for x in fruits: | ||
| 148 | | if x == "banana": | ||
| 149 | | break | ||
| 150 | | print(x) | ||
| 151 | |||
| 152 | hr | ||
| 153 | figcaption.right Finding nearest point | ||
| 154 | |||
| 155 | pre | ||
| 156 | code.language-sql | ||
| 157 | | SELECT `CustomerName`, `City` FROM `Customers`; | ||
| 158 | |||
| 159 | hr | ||
| 160 | figcaption.right Finding nearest point | ||
| 161 | |||
| 162 | pre | ||
| 163 | code.language-go | ||
| 164 | | package main | ||
| 165 | | import "fmt" | ||
| 166 | | func main() { | ||
| 167 | | sum := 0 | ||
| 168 | | for i := 0; i < 10; i++ { | ||
| 169 | | sum += i | ||
| 170 | | } | ||
| 171 | | fmt.Println(sum) | ||
| 172 | | } | ||
| 173 | |||
| 174 | hr | ||
| 175 | figcaption.right Finding nearest point | ||
| 176 | |||
| 177 | pre | ||
| 178 | code.language-javascript | ||
| 179 | | $(document).ready(function() { | ||
| 180 | | $('pre code').each(function(i, block) { | ||
| 181 | | hljs.highlightBlock(block); | ||
| 182 | | }); | ||
| 183 | | }); | ||
| 184 | |||
| 185 | hr | ||
| 186 | figcaption.right Finding nearest point | ||
| 187 | |||
| 188 | pre | ||
| 189 | code.language-css | ||
| 190 | | body { | ||
| 191 | | background: black; | ||
| 192 | | } | ||
| 193 | |||
| 194 | section | ||
| 195 | h3 Grid example | ||
| 196 | div.grid.col-1-1 | ||
| 197 | div Lipsum | ||
| 198 | div Lipsum | ||
| 199 | |||
| 200 | div.grid.col-2-1 | ||
| 201 | div Lipsum | ||
| 202 | div Lipsum | ||
| 203 | |||
| 204 | div.grid.col-1-2 | ||
| 205 | div Lipsum | ||
| 206 | div Lipsum | ||
