├── .obsidian
├── app.json
├── appearance.json
├── core-plugins.json
├── hotkeys.json
├── snippets
│ └── obsidian.css
└── workspace
├── Archive
├── README - Copy (2).md
└── README - Copy.md
├── Code
├── 1-1-Introduction
│ ├── 1-python-refresher.py
│ ├── 2-control-structures.py
│ ├── 3-control-structures-ex2.py
│ ├── 4-generators.py
│ ├── 5-factorial.py
│ ├── 6-Sudoku.py
│ ├── 7-class.py
│ ├── 8-my thoughts.py
│ └── token.txt
├── 1-2-Solve problems
│ └── Age.py
├── 1-3-Efficiency
│ └── Effciency_Notes.docx
├── 1-4_Project
│ ├── .DS_Store
│ ├── Task0.py
│ ├── Task1.py
│ ├── Task2.py
│ ├── Task3.py
│ ├── Task4.py
│ ├── calls.csv
│ ├── test1.py
│ └── texts.csv
├── 3-Algorithms
│ ├── 1-comparison.py
│ ├── greedyATM.py
│ ├── greedyNumOperations.py
│ ├── greedyTrain.py
│ └── sorting_algorithm.py
├── 6-Dynamic-Programming
│ ├── 001_Knapsack problem.py
│ ├── fibionachi.py
│ └── stock_prices.py
└── 7-Technical Interview
│ ├── Python1.py
│ ├── Question1.py
│ └── Question2.py
├── LICENSE
├── README.md
├── code
└── Python_OBB_One_Notebook_for_all.ipynb
├── media
├── 1f11fb9b2ed3eb432764db5635531f54.png
├── 28a37a2c4d8794faa0b22686c21cbece.png
├── 2aab5b68c0b0e7ea62486cfe66e08caa.png
├── 393309480a114e09e85165f26cfdf15d.png
├── 426dc47adbe8aa35d9ca78e2e77905be.png
├── 44d46f063fca4872104e6edb1a26e63d.png
├── 4a3923fde43ff67cc4066b14626677b0.png
├── 4c958b1e2b2f2c7a5c54dc66945872db.png
├── 4def5b724f6f15c6b099ce425f8c4e09.png
├── 4fe578f16ea7ad1e9fd04d71fdea444a.png
├── 5a7c7e913b6193df10c1bd43504915d2.png
├── 807b5c8aee182baaa1713c01e98994f9.png
├── 8772bf182b4a29b45fa854704118a58d.png
├── 9475b959311dc362995bdb778c55234b.png
├── 979a59ecbdab5b700013dbe7875b4603.png
├── 9beca1381c793944285f552ff3a4842c.png
├── Double.png
├── aafcce2fa1d4355bed1f9c7f5850c437.png
├── aedaa435d36c4f0f3cbf29d50034fdd2.png
├── array.png.md
├── arrays.png
├── b41c1c2d2548c9e6940e3506ec84f34f.png
├── best.png
├── c018057d901372ab5b57e93742036550.png
├── c75f1ae6443175cde6bff55aaa014eda.png
├── d5e6c36b1d10faaaf0d1ae40e3182cca.png
├── d60404983770ccf9700e87bf00057d26.png
├── dab72f2bab27818a10403e79984d290a.png
├── efb964d97b2648ca21e04162697e01e1.png
├── fb4c847451ca46a38339e5be359320a9.png
├── fea061ac8378d67ca943d89b8a692000.png
├── linked.png
├── outline.png
├── runfi.png
├── runtime.png
├── sol.png
└── types.png
└── ~WRL2750.tmp
/.obsidian/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "obsidianCss": true,
3 | "isSidebarCollapsed": false,
4 | "isRightSidedockCollapsed": true,
5 | "lastOpenSidebarTab": "File explorer",
6 | "lastOpenRightSidedockTab": "Backlinks",
7 | "promptDelete": false,
8 | "alwaysUpdateLinks": true,
9 | "attachmentFolderPath": "/",
10 | "foldHeading": false,
11 | "showLineNumber": false,
12 | "vimMode": false,
13 | "newFileLocation": "current",
14 | "enabledPlugins": [],
15 | "spellcheck": false,
16 | "spellcheckDictionary": [
17 | "Porche"
18 | ],
19 | "readableLineLength": false,
20 | "pdfExportSettings": {
21 | "pageSize": "Letter",
22 | "landscape": false,
23 | "margin": "0",
24 | "downscalePercent": 100
25 | },
26 | "legacyEditor": false,
27 | "livePreview": true,
28 | "defaultViewMode": "source"
29 | }
--------------------------------------------------------------------------------
/.obsidian/appearance.json:
--------------------------------------------------------------------------------
1 | {
2 | "theme": "moonstone",
3 | "baseFontSize": 10,
4 | "enabledCssSnippets": [
5 | "obsidian"
6 | ]
7 | }
--------------------------------------------------------------------------------
/.obsidian/core-plugins.json:
--------------------------------------------------------------------------------
1 | [
2 | "file-explorer",
3 | "global-search",
4 | "switcher",
5 | "graph",
6 | "backlink",
7 | "page-preview",
8 | "note-composer",
9 | "command-palette",
10 | "editor-status",
11 | "markdown-importer",
12 | "outline",
13 | "word-count",
14 | "open-with-default-app",
15 | "file-recovery"
16 | ]
--------------------------------------------------------------------------------
/.obsidian/hotkeys.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.obsidian/snippets/obsidian.css:
--------------------------------------------------------------------------------
1 | .theme-light
2 | {
3 | --background-primary: #FBFBFB;
4 | --background-primary-alt: #FBFBFB;
5 | --background-secondary: #FBFBFB;
6 | --background-secondary-alt: #2E3236;
7 | --text-normal: #333;
8 | --text-faint: #B2B2B2;
9 | --text-title-h1: #333;
10 | --text-title-h2: #333;
11 | --text-title-h3: #333;
12 | --text-title-h4: #333;
13 | --text-title-h5: #333;
14 | --text-link: #B4B4B4;
15 | --text-a: #db4d52;
16 | --text-a-hover: #db4d52;
17 | --text-mark: #D3FFA4;
18 | --pre-code: #FFFFFF;
19 | --interactive-accent: #92A1A1;
20 | --interactive-before: #5e6565;
21 | --background-modifier-border: #92a1a17a;
22 | --blockquote-border: #009FFD;
23 | --tag-background: #A7B0B3;
24 | --interactive-accent-rgb: #db4d52;
25 | --font-family-editor: Calibri, "Calibri";
26 | --font-family-preview: Calibri, "Calibri";
27 | }
28 |
29 | .theme-dark
30 | {
31 | --background-primary: #1E2022;
32 | --background-primary-alt: #1E2022;
33 | --background-secondary: #1E2022;
34 | --background-secondary-alt: #2E3236;
35 | --text-normal: #DDDDDD;
36 | --text-faint: #B2B2B2;
37 | --text-title-h1: #CBDBE5;
38 | --text-title-h2: #CBDBE5;
39 | --text-title-h3: #CBDBE5;
40 | --text-title-h4: #CBDBE5;
41 | --text-title-h5: #CBDBE5;
42 | --text-link: #B4B4B4;
43 | --text-a: #6BCAFB;
44 | --text-a-hover: #6BCAFB;
45 | --text-mark: #263D92;
46 | --pre-code: #252525;
47 | --interactive-accent: #92A1A1;
48 | --interactive-before: #5e6565;
49 | --background-modifier-border: #92a1a17a;
50 | --blockquote-border: #4AA8FB;
51 | --tag-background: #A7B0B3;
52 | --interactive-accent-rgb: #6BCAFB;
53 | --font-family-editor: Avenir, "Avenir Next";
54 | --font-family-preview: Avenir, "Avenir Next";
55 | }
56 |
57 |
58 | #graph-view-canvas .links
59 | {
60 | stroke: var(--interactive-accent-rgb) !important;
61 | }
62 |
63 | strong,
64 | .cm-strong
65 | {
66 | color: var(--tax-normal);
67 | font-weight: 900 !important;
68 | }
69 |
70 | em {
71 | color: var(--tax-normal);
72 | }
73 |
74 | s {
75 | color: var(--tag-background);
76 | }
77 |
78 | mark
79 | {
80 | background-color: var(--text-mark) !important;
81 | color: var(--text-normal);
82 | padding: 2px 2px 2px 2px;
83 | }
84 |
85 | /**********************/
86 | /* links and brackets */
87 | /**********************/
88 |
89 | /* link */
90 | a,
91 | .internal-link,
92 | .cm-hmd-internal-link,
93 | .cm-link,
94 | .cm-formatting-link
95 | {
96 | color: var(--text-a) !important;
97 | text-decoration: none !important;
98 | font-family: var(--font-family-preview) !important;
99 | }
100 |
101 | a.view-action
102 | {
103 | color: var(--text-faint) !important;
104 | }
105 |
106 | /* link hover color */
107 | a:hover,
108 | .internal-link:hover
109 | {
110 | color: var(--text-a-hover) !important;
111 | text-decoration: none !important;
112 | }
113 |
114 | /* make external links italics to differentiate */
115 | a:not(.internal-link) {
116 | font-style: italic;
117 | }
118 |
119 | /* blockquote */
120 | .cm-quote /* for editor */
121 | {
122 | color: var(--text-normal) !important;
123 | }
124 |
125 | blockquote /* for preview */
126 | {
127 | border-color: var(--blockquote-border) !important;
128 | border-top-width: 0px !important;
129 | border-bottom-width: 0px !important;
130 | border-right-width: 0px !important;
131 | border-left-width: 2px !important;
132 | }
133 |
134 | /* icons at top of panes*/
135 | .file-view-actions a
136 | {
137 | color: var(--text-faint) !important;
138 | }
139 |
140 | .file-view-actions a:hover
141 | {
142 | color: var(--text-normal) !important;
143 | }
144 |
145 | /* make it clear when a pane is pinned */
146 | .view-action.mod-pin-leaf.is-active
147 | {
148 | color: var(--text-a) !important;
149 | }
150 |
151 | /* editor markdown wrapping colors */
152 | .cm-tag,
153 | .cm-strikethrough,
154 | .cm-formatting-strong,
155 | .cm-formatting-em,
156 | .cm-formatting-code
157 | {
158 | color: var(--text-faint) !important;
159 | }
160 |
161 | /* editor list characters */
162 | .cm-formatting-list
163 | {
164 | color: var(--blockquote-border) !important;
165 | }
166 |
167 | /************************************/
168 | /* lists in preview (h/t @deathau) */
169 | /************************************/
170 |
171 | /* bullet lists */
172 | ul { list-style: none; }
173 | li > p {
174 | display: inline-block;
175 | margin-top: 0;
176 | margin-bottom: 0;
177 | }
178 |
179 | ul li:not(.task-list-item)::before {
180 | content: "•";
181 | color: var(--blockquote-border);
182 | display: inline-block;
183 | width: 1em;
184 | margin-left: -2em;
185 | padding:0;
186 | font-weight: bold;
187 | text-shadow: 0 0 0.5em var(--accent-2);
188 | }
189 | ul ul li:not(.task-list-item)::before {
190 | content: "•"
191 | }
192 | ul ul ul li:not(.task-list-item)::before {
193 | content: "•"
194 | }
195 |
196 | /* numbered lists */
197 | ol {list-style: none; counter-reset: li}
198 | ol > li {
199 | counter-increment: li;
200 | }
201 | ol > li:not(.task-list-item)::before,
202 | ul ol > li:not(.task-list-item)::before,
203 | ul ul ol > li:not(.task-list-item)::before,
204 | ul ul ul ol > li:not(.task-list-item)::before {
205 | content: "." counter(li);
206 | color: var(--blockquote-border);
207 | font-weight:normal;
208 | display: inline-block;
209 | width: 1em;
210 | margin-left: -1.5em;
211 | margin-right: 0.5em;
212 | text-align: right;
213 | direction: rtl;
214 | word-wrap: none;
215 | overflow: visible;
216 | word-break: keep-all;
217 | }
218 |
219 | /* task lists! (I'm proud of this, but could use improvement) */
220 | .markdown-preview-view .task-list-item-checkbox {
221 | -webkit-appearance: none;
222 | box-sizing: border-box;
223 | border: 1px solid var(--tag-background);
224 | border-radius: 3px;
225 | position: relative;
226 | width: 1.25em;
227 | height: 1.25em;
228 | margin: 0;
229 | cursor: pointer;
230 | color: var(--text-normal);
231 | font-weight: 600;
232 | }
233 | .markdown-preview-view .task-list-item-checkbox:checked::before {
234 | content: '✓';
235 | position: absolute;
236 | font-size:1em;
237 | line-height: 1em;
238 | width:1.1em;
239 | text-align:center;
240 | border-radius: 2px;
241 | cursor: pointer;
242 | }
243 |
244 | /* code blocks in preview */
245 | pre code
246 | {
247 | padding: 20px !important;
248 | line-height: normal;
249 | display: block;
250 | background-color: var(--pre-code) !important;
251 | color: var(--text-normal) !important;
252 | }
253 |
254 | .markdown-preview-view pre
255 | {
256 | padding: 0px !important;
257 | }
258 |
259 | /* in-line code for editor and preview and code block for editor*/
260 | code,
261 | .cm-inline-code
262 | {
263 | background-color: var(--pre-code) !important;
264 | color: var(--text-normal) !important;
265 | bottom: 0px !important;
266 | padding: 1px;
267 | }
268 |
269 | /* code and code blocks for preview */
270 | .markdown-preview-view code
271 | {
272 | font-size: 13.5px;
273 | }
274 |
275 | /**********/
276 | /* tables */
277 | /**********/
278 | th
279 | {
280 | font-weight: 800 !important;
281 | }
282 |
283 | thead
284 | {
285 | border-bottom: 3px solid var(--background-modifier-border);
286 | }
287 |
288 | .table
289 | {
290 | background-color: var(--background-secondary-alt);
291 | border: 1px solid var(--background-modifier-border);
292 | padding: 4px;
293 | line-height: normal;
294 | display: block;
295 | border-top-left-radius: 4px;
296 | border-top-right-radius: 4px;
297 | border-bottom-right-radius: 4px;
298 | border-bottom-left-radius: 4px;
299 | }
300 |
301 | /* embedded images */
302 | img
303 | {
304 | display: block;
305 | margin-left: auto;
306 | margin-right: auto;
307 | }
308 |
309 | /* horizontal line in preview */
310 | .markdown-preview-view hr
311 | {
312 | background-color: var(--text-link);
313 | }
314 |
315 | /* checkboxes */
316 | .markdown-preview-view .task-list-item-checkbox
317 | {
318 | top: 0px;
319 | }
320 |
321 | /* match cursor color to theme */
322 | .CodeMirror-cursor
323 | {
324 | border-left: 2px solid var(--blockquote-border);
325 | }
326 |
327 | /********/
328 | /* tags */
329 | /********/
330 |
331 | /* text of the tag in editor */
332 | .cm-s-obsidian span.cm-hashtag-end {
333 | color: var(--pre-code);
334 | background-color: var(--tag-background);
335 | text-decoration: none;
336 | border-radius: 0 10px 10px 0px;
337 | padding: 1px 5px 1px 0px;
338 | }
339 |
340 | /* text of the actual hashtag in the editor */
341 | .cm-s-obsidian span.cm-hashtag-begin {
342 | color: var(--pre-code);
343 | background-color: var(--tag-background);
344 | text-decoration: none;
345 | border-radius: 10px 0 0 10px;
346 | padding: 1px 0px 2px 5px;
347 | }
348 |
349 | /* entire tag in preview */
350 | a.tag
351 | {
352 | font-style: normal;
353 | color: var(--pre-code) !important;
354 | background-color: var(--tag-background);
355 | text-decoration: none;
356 | border-radius: 10px;
357 | padding: 1px 5px 1px 5px;
358 | }
359 |
360 | /*************/
361 | /* side dock */
362 | /*************/
363 |
364 | /* side dock text, like file names and backlink context */
365 | .side-dock-panels-container *
366 | {
367 | font-size: 13px !important;
368 | }
369 |
370 | /* side dock titles at top */
371 | .side-dock-title
372 | {
373 |
374 | font-size: 20px !important;
375 | font-weight: 800 !important;
376 | }
377 |
378 | /* hover actions on side dock navigation */
379 | .side-dock-ribbon-tab:hover,
380 | .side-dock-ribbon-tab-inner:hover,
381 | .side-dock-ribbon-action:hover,
382 | .side-dock-ribbon-action.is-active:hover,
383 | .nav-action-button:hover,
384 | .side-dock-collapse-btn:hover
385 | {
386 | color: var(--text-a);
387 | }
388 |
389 | /* non-hover actions on side dock navigation */
390 | .side-dock-ribbon-tab,
391 | .side-dock-ribbon-tab-inner,
392 | .side-dock-ribbon-action,
393 | .side-dock-ribbon-action.is-active,
394 | .nav-action-button,
395 | .side-dock-collapse-btn
396 | {
397 | color: var(--text-faint);
398 | }
399 |
400 | /* quick switcher item currently selected */
401 | .suggestion-item.is-selected
402 | {
403 | background-color: var(--pre-code);
404 | }
405 |
406 | /* condense line spacing on file explorer title list. also avoids character-level word breaks */
407 | .nav-file-title-content,
408 | .search-result-file-title,
409 | .search-result-file-match
410 | {
411 | padding-top: 0 !important;
412 | padding-bottom: 0 !important;
413 | line-height: normal !important;
414 | word-break: keep-all;
415 | }
416 |
417 | /* styling for title that is selected in filer explorer */
418 | .nav-file.is-active > .nav-file-title
419 | {
420 | background-color: var(--pre-code);
421 | color: var(--text-a);
422 | border-color: var(--blockquote-border);
423 | border-width: 0px 0px 0px 3px;
424 | border-radius: 1px;
425 | }
426 |
427 | /* text color of non-selected files in sidebar */
428 | .nav-file-title,
429 | .search-result-file-match
430 | {
431 | color: var(--text-faint);
432 | }
433 |
434 | .search-result-file-title
435 | {
436 | color: var(--text-muted);
437 | }
438 |
439 | /* color and background of titles hovered over in side bars */
440 | body:not(.is-grabbing) .nav-file-title:hover,
441 | body:not(.is-grabbing) .nav-folder-title:hover,
442 | .search-result-file-match:hover,
443 | .search-result-file-title:hover,
444 | body:not(.is-grabbing) .nav-file-title:hover .nav-folder-collapse-indicator,
445 | body:not(.is-grabbing) .nav-folder-title:hover .nav-folder-collapse-indicator
446 | {
447 | background-color: var(--pre-code);
448 | color: var(--text-normal);
449 | }
450 |
451 | /* clean up side bar empty state (e.g. unlinked mentions) */
452 | .search-empty-state
453 | {
454 | width: auto;
455 | padding-left: 15px;
456 | padding-right: 15px;
457 | line-height: normal;
458 | }
459 |
460 | /* to have sidebar hide and then reveal on hover */
461 | .app-container.is-left-sidedock-collapsed .side-dock.mod-left:not(:hover),
462 | .app-container.is-right-sidedock-collapsed .side-dock.mod-right:not(:hover)
463 | {
464 | width: 0px !important;
465 | }
466 |
467 | /* font for everything outside of editor/preview panes */
468 | .app-container
469 | {
470 | font-family: var(--font-family-preview);
471 | }
472 |
473 | .status-bar-item
474 | {
475 | font-family: var(--font-family-preview);
476 | font-size: 12px;
477 | }
478 |
479 | /******************/
480 | /* settings popup */
481 | /******************/
482 |
483 | /* left hand side section non-selected section */
484 | .vertical-tab-header,
485 | .vertical-tab-nav-item
486 | {
487 | background-color: var(--background-primary);
488 | border-color: var(--text-faint);
489 | border-width: 2px;
490 | }
491 |
492 | /* left hand side section selected section */
493 | .vertical-tab-nav-item.is-active
494 | {
495 | background-color: var(--pre-code);
496 | border-color: var(--blockquote-border);
497 | border-width: 5px;
498 | }
499 |
500 | /* in settings menu to show hot key mapping */
501 | .setting-hotkey
502 | {
503 | background-color: var(--pre-code);
504 | }
505 |
506 | /******************/
507 | /* editor section */
508 | /******************/
509 |
510 | /* normal text outside of headings and code */
511 | /*@@@*/
512 | .cm-s-obsidian
513 | {
514 | font-family: var(--font-family-editor);
515 | font-size: 22px;
516 | color: var(--text-normal);
517 | padding-left: 0% !important;
518 | padding-right: 0% !important;
519 | }
520 |
521 | .mod-single-child .cm-s-obsidian
522 | {
523 | font-family: var(--font-family-editor);
524 | font-size: 15px;
525 | color: var(--text-normal);
526 | padding-left: 30% !important;
527 | padding-right: 30% !important;
528 | }
529 |
530 | /* headings */
531 | .cm-header-1
532 | {
533 | font-family: var(--font-family-editor);
534 | font-weight: 500;
535 | font-size: 28px;
536 | font-weight: bold;
537 | color: var(--text-title-h1);
538 | }
539 |
540 | .cm-header-2
541 | {
542 | font-family: var(--font-family-editor);
543 | font-weight: 500;
544 | font-size: 26px;
545 | font-weight: bold;
546 | color: var(--text-title-h2);
547 | }
548 |
549 | .cm-header-3
550 | {
551 | font-family: var(--font-family-editor);
552 | font-weight: 500;
553 | font-size: 22px;
554 | font-weight: bold;
555 | color: var(--text-title-h3);
556 | }
557 |
558 | .cm-header-4
559 | {
560 | font-family: var(--font-family-editor);
561 | font-weight: 500;
562 | font-size: 20px;
563 | font-weight: bold;
564 | color: var(--text-title-h4);
565 | }
566 |
567 | .cm-header-5
568 | {
569 | font-family: var(--font-family-editor);
570 | font-weight: 500;
571 | font-size: 18px;
572 | font-weight: bold;
573 | color: var(--text-title-h5);
574 | }
575 |
576 | .cm-header-6
577 | {
578 | font-family: var(--font-family-editor);
579 | font-weight: 500;
580 | font-size: 16px;
581 | font-weight: bold;
582 | color: var(--text-title-h5);
583 | }
584 |
585 | .cm-string,
586 | .cm-formatting-task,
587 | .CodeMirror-guttermarker-subtle
588 | {
589 | color: var(--text-link) !important;
590 | }
591 |
592 |
593 | /* remote secondary scroll bar in editor that comes from adding variable padding */
594 | .CodeMirror-scroll::-webkit-scrollbar {
595 | display: none;
596 | }
597 |
598 | /******************/
599 | /* preview section */
600 | /******************/
601 |
602 | /* normal text outside of headings and code */
603 | .markdown-preview-view
604 | {
605 | font-family: var(--font-family-preview);
606 | font-size: 22px;
607 | color: var(--text-normal);
608 | padding-left: 0% !important;
609 | padding-right: 0% !important;
610 | }
611 |
612 | .mod-single-child .markdown-preview-view
613 | {
614 | font-family: var(--font-family-preview);
615 | font-size: 15px;
616 | color: var(--text-normal);
617 | padding-left: 30% !important;
618 | padding-right: 30% !important;
619 | }
620 |
621 | /* headings */
622 | .markdown-preview-view h1
623 | {
624 | font-family: var(--font-family-preview);
625 | font-weight: 600 !important;
626 | font-size: 28px;
627 | font-weight: bold;
628 | color: var(--text-title-h1);
629 | }
630 |
631 | .markdown-preview-view h2
632 | {
633 | font-family: var(--font-family-preview);
634 | font-weight: 600 !important;
635 | font-size: 26px;
636 | font-weight: bold;
637 | color: var(--text-title-h2);
638 | }
639 |
640 | .markdown-preview-view h3
641 | {
642 | font-family: var(--font-family-preview);
643 | font-weight: 600 !important;
644 | font-size: 22px;
645 | font-weight: bold;
646 | color: var(--text-title-h3);
647 | }
648 |
649 | .markdown-preview-view h4
650 | {
651 | font-family: var(--font-family-preview);
652 | font-weight: 600 !important;
653 | font-size: 20px;
654 | font-weight: bold;
655 | color: var(--text-title-h4);
656 | }
657 |
658 | .markdown-preview-view h5
659 | {
660 | font-family: var(--font-family-preview);
661 | font-weight: 600 !important;
662 | font-size: 18px;
663 | font-weight: bold;
664 | color: var(--text-title-h5);
665 | }
666 |
667 | .markdown-preview-view h6
668 | {
669 | font-family: var(--font-family-preview);
670 | font-weight: 600 !important;
671 | font-size: 16px;
672 | font-weight: bold;
673 | color: var(--text-title-h5);
674 | }
675 |
676 | /* add some header prefix in preview */
677 | h1::before
678 | {
679 | content: 'H1 ';
680 | font-size: 12px;
681 | color: var(--text-faint)
682 | }
683 |
684 | h2::before
685 | {
686 | content: 'H2 ';
687 | font-size: 12px;
688 | color: var(--text-faint)
689 | }
690 |
691 | h3::before
692 | {
693 | content: 'H3 ';
694 | font-size: 12px;
695 | color: var(--text-faint)
696 | }
697 |
698 | h4::before
699 | {
700 | content: 'H4 ';
701 | font-size: 12px;
702 | color: var(--text-faint)
703 | }
704 |
705 | h5::before
706 | {
707 | content: 'H5 ';
708 | font-size: 12px;
709 | color: var(--text-faint)
710 | }
711 |
712 | h6::before
713 | {
714 | content: 'H6 ';
715 | font-size: 12px;
716 | color: var(--text-faint)
717 | }
718 |
719 | /* internal embedded link rendering in preview */
720 | .markdown-embed-title
721 | {
722 | font-weight: 600;
723 | }
724 |
725 | .markdown-embed
726 | {
727 | padding-left: 10px !important;
728 | padding-right: 10px !important;
729 | margin-left: 10px !important;
730 | margin-right: 10px !important;
731 | }
732 |
733 | .side-dock-ribbon.mod-left.is-collapsed:not(:hover), .side-dock-ribbon.mod-right.is-collapsed:not(:hover) {
734 | width: 15px !important;
735 | opacity: 0;
736 | }
737 | .side-dock-ribbon {
738 | transition-property: width, opacity;
739 | }
740 | .cm-hmd-list-indent .cm-tab, ul ul { position: relative; }
741 | .cm-hmd-list-indent .cm-tab::before, ul ul::before {
742 | content:'';
743 | border-left: 1px solid rgba(0, 122, 255, 0.25);
744 | position: absolute;
745 | }
746 | .cm-hmd-list-indent .cm-tab::before { left: 0; top: -5px; bottom: -4px;
747 | }
748 | ul ul::before { left: -11px; top: 0; bottom: 0;
749 | }
750 |
--------------------------------------------------------------------------------
/.obsidian/workspace:
--------------------------------------------------------------------------------
1 | {
2 | "main": {
3 | "id": "9e3ad0b60c45de61",
4 | "type": "split",
5 | "children": [
6 | {
7 | "id": "0fa210146851d0e9",
8 | "type": "leaf",
9 | "state": {
10 | "type": "markdown",
11 | "state": {
12 | "file": "README.md",
13 | "mode": "source",
14 | "source": false
15 | }
16 | }
17 | }
18 | ],
19 | "direction": "vertical"
20 | },
21 | "left": {
22 | "id": "a3b2d320c9b1fc62",
23 | "type": "split",
24 | "children": [
25 | {
26 | "id": "c12b147c157c6d0d",
27 | "type": "tabs",
28 | "children": [
29 | {
30 | "id": "3ef9734468a4547e",
31 | "type": "leaf",
32 | "state": {
33 | "type": "file-explorer",
34 | "state": {}
35 | }
36 | },
37 | {
38 | "id": "9707d2bc3b956526",
39 | "type": "leaf",
40 | "state": {
41 | "type": "search",
42 | "state": {
43 | "query": "",
44 | "matchingCase": false,
45 | "explainSearch": false,
46 | "collapseAll": false,
47 | "extraContext": false,
48 | "sortOrder": "alphabetical"
49 | }
50 | }
51 | },
52 | {
53 | "id": "e64a18baad312ba6",
54 | "type": "leaf",
55 | "state": {
56 | "type": "outline",
57 | "state": {
58 | "file": "README.md"
59 | }
60 | }
61 | }
62 | ]
63 | }
64 | ],
65 | "direction": "horizontal",
66 | "width": 293
67 | },
68 | "right": {
69 | "id": "158295ed98e97e96",
70 | "type": "split",
71 | "children": [
72 | {
73 | "id": "07d5123019263d0c",
74 | "type": "tabs",
75 | "children": [
76 | {
77 | "id": "2e39fca8e5546466",
78 | "type": "leaf",
79 | "state": {
80 | "type": "backlink",
81 | "state": {
82 | "file": "README.md",
83 | "collapseAll": false,
84 | "extraContext": false,
85 | "sortOrder": "alphabetical",
86 | "showSearch": false,
87 | "searchQuery": "",
88 | "backlinkCollapsed": false,
89 | "unlinkedCollapsed": false
90 | }
91 | }
92 | }
93 | ]
94 | }
95 | ],
96 | "direction": "horizontal",
97 | "width": 300
98 | },
99 | "active": "0fa210146851d0e9",
100 | "lastOpenFiles": [
101 | "README.md",
102 | "Pasted.md",
103 | "Pasted_image_20220125184741.png.md",
104 | "media/array.png.md",
105 | "media/sol.png",
106 | "media/runfi.png",
107 | "media/linked.png",
108 | "media/runtime.png",
109 | "media/best.png",
110 | "media/types.png"
111 | ]
112 | }
--------------------------------------------------------------------------------
/Archive/README - Copy (2).md:
--------------------------------------------------------------------------------
1 | Data Structures and Algorithms
2 | ==============================
3 |
4 | The summary of **Data Structures and Algorithms** plus every **Interview step.**
5 |
6 | I’ve included the code for each concept in Python in the code folder. I would
7 | suggest to implement this short code for your projects or coding interviews..
8 |
9 | I highly recommend the following materials by the order of importance:
10 |
11 | 1. [Udacity nano degree: Data Structures and
12 | Algorithms](https://www.udacity.com/course/data-structures-and-algorithms-nanodegree--nd256)
13 |
14 | 2. Youtube playlist
15 |
16 | 3. Data Structure in C book
17 |
18 | 4. CLRS book [If you are an academic].
19 |
20 | TLDR Objectives: Understanding of various types of techniques for algorithms
21 | design and (run time) analysis in detail. Also, a gentle introduction to several
22 | advanced data structures.
23 |
24 | TLDR Overview: Review of mathematical background, sorting and searching,
25 | algorithm design techniques such as divide and conquer, greedy approach, dynamic
26 | programming, worst case and average case analysis techniques, data structures
27 | such as binary search trees and various heaps, graph algorithms, string
28 | algorithms and geometric data structures, advanced topics (P, NP, NP-Complete,
29 | etc) if time permits.
30 |
31 | Solving any algorithm problem:
32 | ==============================
33 |
34 | 
35 |
36 | Think in simple term:
37 |
38 | 1. Don’t panic
39 |
40 | 2. What are the inputs
41 |
42 | 3. What are the outputs
43 |
44 | 4. Solve the problem
45 |
46 | **Next:**
47 |
48 | Do some examples on paper/mind, find **relationship** between input and output,
49 | finally, test some cases.
50 |
51 | Try solve the problem **On paper first**.
52 |
53 | Write algorithm. Pseudocode.
54 |
55 | Example 1 [Code included]: Write an algorithm /code that counts the difference
56 | of two dates.
57 |
58 | Ask yourself:
59 |
60 | Dates, DF, are all the inputs are valid? 1st data 2nd Second date must not be
61 | older than 1: invalid input
62 |
63 | How input are encoded? (yyyy,mm,dd)
64 |
65 | Output return a number because we can do things with return value rather
66 | printing it
67 |
68 | 
69 |
70 | First code: writing a block that makes the solution to work. Solve with a single
71 | simple case.
72 |
73 | Break into simple parts so that we can see our progress.
74 |
75 | Write simple small codes that work
76 |
77 | No need to figure out all the details. Consider that you will procrastinate
78 | later
79 |
80 | Comparison
81 | ==========
82 |
83 | Finding the smallest of n numbers:(n-1)
84 | Finding the biggest of n numbers:(n-1)
85 | Finding the smallest and the biggest of n numbers:(2n-3)
86 |
87 | Big O Notion:
88 | =============
89 |
90 | As the input to an algorithm increases, the time required to run the algorithm
91 | may also increase.
92 |
93 | For example in **Nested Loops**:
94 |
95 | For I in range:
96 |
97 | For j in range:
98 |
99 | > Print(“hello World”)
100 |
101 | Will increases the lines dramatically
102 |
103 | The *rate of increase* of an algorithm is also referred to as the **order** of
104 | the algorithm
105 |
106 | For example, instead of saying "this relationship has a linear rate of
107 | increase", we could instead say, "The *order* of this relationship is linear".
108 |
109 | *O Notation*, and you'll see that the "O" in the name refers to the **o**rder of
110 | the rate of increase.
111 |
112 | Length of input to my function
113 |
114 | O(2n+2) \> n=10 -\> 22
115 |
116 | In n\^2 + 5*n*2+5, the 55 has very little impact on the total
117 | efficiency—especially as the input size gets larger and larger. Asking the
118 | computer to do 10,005 operations vs. 10,000 operations makes little difference.
119 | Thus, it is the n\^2*n*2 that we really care about the most, and the + 5+5 makes
120 | little difference
121 |
122 | Efficiency is actually about O(n) Interviewer wants us to think about
123 | efficiency.
124 |
125 | Run time analysis
126 |
127 | O(3N) space efficiency (copying code)
128 |
129 | Int , float 4 bytes
130 |
131 | char 1 byte
132 |
133 | Binary search (Middle …. Middle, O (log(n)).:
134 | =============================================
135 |
136 | 
137 |
138 | **Algorithm:** Tricks to solve a problem
139 |
140 | **Q:** How to find number 25 in this a sorted array?
141 |
142 | **A:**
143 |
144 | **1. Linear search: O(n)**
145 |
146 | **2. Binary Search:** O(log(n)+1) ( Why it is called binary search? find a
147 | postion of binary)
148 |
149 | Middle, Middle, Middle.
150 |
151 | Sorting:
152 | ========
153 |
154 | **Bubble sort:**
155 |
156 | Simplest and most inefficient one O(n\^2)
157 |
158 | Merge Sort (divide, merge):
159 | ===========================
160 |
161 | Using divide and conquer, first, we divide 2 by 2
162 |
163 | 
164 |
165 | Then we compare the elements
166 |
167 | 
168 |
169 | Efficiency:
170 |
171 | O (n Log (n))
172 |
173 | Why we are seeing log (n) in our efficiency? Hint: same as binary search problem
174 |
175 | Quick Sort (divide, merge):
176 | ===========================
177 |
178 | Pick one and move it around
179 |
180 | 
181 |
182 | Why it can be chosen as the most efficient algorithm?
183 |
184 | Because on average it will outperform merge sort.
185 |
186 | On each step we are performing two moving around.
187 |
188 | 
189 |
190 | (Pivot = Last element) First move we move
191 |
192 | 1. Select right P
193 |
194 | 2. PL LS SP (Shift Pivot to left , Swap start and left)
195 |
196 | 3. Compare Start with pivot. If (Start \> Pivot repeat step 2)
197 |
198 | 4. Else move to second start
199 |
200 | 
201 |
202 | 
203 |
204 | I advise to practice this for cementing the algorithm.
205 |
206 | 
207 |
208 | **Great no need to move the original pivot anymore (2 is at the right place)**
209 |
210 | 
211 |
212 | Check 2 with lefts
213 |
214 | New pivot on right. Compare
215 |
216 | Moving phase
217 |
218 | Everything less than 8 and 10 sweap results in:
219 | Everythin less than 8 are already below 8 so cemented
220 |
221 | 
222 |
223 | **Efficiency:**
224 |
225 | **O(n2) if it’s already sorted. Why? Wasting time**
226 |
227 | Heaps:
228 | ======
229 |
230 | Dynamic programming:
231 | ====================
232 |
233 | (Programming == tables)
234 |
235 | Factorial problem in python:
236 |
237 | 
238 |
239 | DP = **Recursion** + **Memo**-ization
240 |
241 | Knapsack problem: Max value for weight limit
242 |
243 | 
244 |
245 | Knapsack. Imagine the skyrim world where you can carry a certain weight (50kg)
246 | in your bag, how can you gather the most valuable items (3w,500v) with you?
247 |
248 | How you optimize which items with their weights to carry with you?
249 |
250 | 1. Brute force: Check all the solutions and pick the best one: O (2\^n)
251 | possible combinations. “exponential time”
252 |
253 | Can we have a polynomial time algorithm? O(n\^2)
254 |
255 | 1. Smarter approach: Initiate with smallest item (2, 6) then (5, 9). Note that
256 | (4, 6) will not be placed since for index 4 value 6 is larger than 5.
257 |
258 | > Next look at index 6. By combining smallest value (2, 6) + (4, 5) we get
259 | > higher value (11).
260 |
261 | 
262 |
263 | > Figure: For each weight the maximum value we can hold.
264 | > Runtime is O(nW).
265 |
266 | 
267 |
268 | 1. Dynamic programming: {can you break into sub problems}
269 |
270 | Sub-problem: Max value for some smaller weight
271 |
272 | We start by using Base case ( so trivial to compute)
273 |
274 | **Base case:** Smallest computation (compute values for one object)
275 |
276 | **+**
277 |
278 | **Lookup table** to store the trivial cases.
279 |
280 | 
281 |
282 | 
283 |
284 | Longest common subsequent
285 |
286 | 
287 |
288 | 
289 |
290 | Complexity Theory
291 | =================
292 |
293 | Class P: n, n\^2,… (Any problem that can be solved in poly time)
294 |
295 | Class NP (Non deterministic): A set of decision problems where yes can be
296 | verified in polytime.
297 |
298 | Descion problems (answers are yes or no) can I go from a to be less than
299 | 100miles? Lets take traveling sales man. Optimization can I do this less than
300 | 100 miles?
301 |
302 | Is the answer more thaan 100? Yes is it lower than 200? 150? This way you will
303 | solve the problems
304 |
305 | Proof/verified/certificate Orlando – Atlanta – L.A
306 |
307 | Is this number a prime 234715307129734085? Hard to check
308 |
309 | Suppose this number not a prime? 1324 if the answer is no it can be verified
310 | quickly
311 |
312 | Class Co-NP: \_No\_ polytime
313 |
314 | Technical Interview
315 | ===================
316 |
317 | ======= Greedy Algorithm (Best option at each step):
318 | ====================================================
319 |
320 | 
321 |
322 | ATM machine : 1,2,10,20,50,100\<
323 |
324 | Return: n\$ the number of bills should be minimized
325 |
326 | 21\$ = 20 +1
327 |
328 | N= 365 – (3x100)- (1x50)-(1x10) – (1x 5)
329 |
330 | What about Target = 8?
331 |
332 | Example:
333 |
334 | Min operations example {see code}: By using while, in dividing numbers in half
335 | // == / and using
336 |
337 | Graph algorithm (data structure that shows relation):
338 | =====================================================
339 |
340 | Graph(Tree is a subgroup of graph,Network) Nodes(Vertex) Edges
341 |
342 | 
343 |
344 | Directed (non-directed), Acyclic, Connectivity
345 |
346 | Connectivity: You friends (social circle)
347 |
348 | As seen below, the right graph is stronger. In contrast, the left group can be
349 | dissolved if one of the connections drops.
350 |
351 | 
352 |
353 | 
354 |
355 | Go through array reccursavley.
356 |
357 | 
358 |
359 | Let’s define 3 variables
360 |
361 | 
362 |
363 | Final answer we be the best solution out of these both (A[i] B[i] )
364 |
365 | Technical Interview (CIOT BRCD) (cute bird)
366 | ===========================================
367 |
368 | What are the most important 7 steps?
369 |
370 | {Memory Palace} Imagine a cute bird sees a giant worm that is shaped like a Q
371 | {Question}. First the bird pour water on the worm (clarify). Then it find the
372 | tail and head (I, O). Then it will taste the worm (Test). It will use its brain
373 | to decide how to eat it (Brainstorm). Then a big white eagle comes and its needs
374 | to calculate the runtime of eating the worm {Runtime analysis}. Then it will
375 | start eating it with If, For, {Code} and Debugs it (No more bug).
376 |
377 | 
378 |
379 | The context should be asking questions and brainstorm at first. As you go on you
380 | rather than asking question everystep you must make statements and justify them.
381 |
382 | {so we can have null input like [] Is that right?} { I have a feeling that it
383 | might be useful in future steps}
384 |
385 | Example: So it contains integers right? So Null input is another input that we
386 | can have.
387 |
388 | Q:
389 | A: Thanks it’s a pleasure to do interview with you. {Positive mindset} {Don’t
390 | give up}
391 |
392 | 1. **Clarifying the question {To prove you wont dive into the problem without
393 | learning more about it}**
394 |
395 | Q: Given a 2D matrix of m, Just 0 and 1. Count the number of islands in the
396 | matrix [island is a group of 1 or just 1 by itself.]
397 |
398 | A: ok so, we are given a 2D matrix which will look something like this.:
399 |
400 | [[1,0,1],[1,1,1]]
401 |
402 | So, our goal is find the number of islands. Is the outcome the number? Or X? So
403 | if the are connected (I[1,0,0],[0,1,0],[0,0,1]) diagonally? Does that consider
404 | an island?
405 |
406 | So what we supposed to do is to find the number of
407 |
408 | {Just want to check Im solving the right problem…}
409 |
410 | 1. Generating inputs and outputs:
411 |
412 | > So my input is matrix of 0 s, 1 s (Integers, strings? No)
413 |
414 | > Output: Integer (\# of islands) (1s or group of ones)
415 |
416 | 1. Generating test cases:
417 |
418 | > {So just to test some cases {Special}}
419 |
420 | > {Can we get Is it ok we have }? Yes
421 |
422 | Q: number of island in a matrix
423 |
424 | **1.Clarify the question **
425 |
426 | A[[1,0,0]],[1,1,0]]{Just to make sure I’m solving the right problem….}
427 |
428 | **2.Generating input/output**
429 |
430 | \<\<\<\<\<\<\< HEAD 1. Generating input/output
431 |
432 | Input matrix of integers
433 |
434 | Output integers ( number of islands 0- max{n})
435 |
436 | 1. {Trick \#1 you can always answer the null case to interviewer.}{ I have a
437 | feeling that it might be useful in future steps} **Test cases** [**Edge
438 | cases**] [ Possible weird inputs that we have to handle A or none object
439 |
440 | {Null - empty- Write a code that doesnt crash}
441 |
442 | 1. **Brainstorming** So if we have null, for sure we have 0 so there would be
443 | no islands in this case. ======= Input matrix of integers.Output integers
444 | (number of islands 0- max{n})
445 |
446 | **3.Test cases**: {Trick \#1 you can always answer the null case to
447 | interviewer.}{ I have a feeling that it might be useful in future steps} **Test
448 | cases** [**Edge cases**] [ Possible weird inputs that we have to handle A or
449 | none object.
450 |
451 | {Null - empty- Write a code that doesnt crash}
452 |
453 | **4.Brainstorming:** {Variables that needs to initialized} {so I need to track
454 | X} {And keep tracking} {Runtime error} {Data structure brainstorm algorithms and
455 | data structures} {Represent graph DFS problem} So if we have null, for sure we
456 | have 0 so there would be no islands in this case. \>\>\>\>\>\>\>
457 | 600e13278473db6cc40a022e79c37c0e0baa2b56
458 |
459 | But also we can have this as input (the input she wants) {So what I am
460 | thinking here} is start at the first element . So i need a counter **variable**
461 | and I **initialze** it there. And **increment** it by 1.
462 |
463 | We get to Zero. Thats not part of any island so I need to keep track of X.
464 | Hmmmm. Maybe I can look at the elements on top and bottom and check if they are
465 | on the same island and keep track of it. Since there is no above that. We get a
466 | run time error. Maybe it could a case of data structure we can solve this. {This
467 | might be a breath first search problem. I can look at the elements around it.
468 | **Set to mark** as **visited** and **keep going**
469 |
470 | **If you are stuck?** This represent a type of data structure and algorithm .
471 | Merge sort maybe… Keep talking
472 |
473 | **5. Runtime anaylsis **
474 |
475 | When I’m looking all the elements in matrix I’m looking at them atlease once so
476 | I’m thinking the runtime would be nXm where N is the number of rows and M is the
477 | number of columns. Well it seems like the optimal solution. So i think i start
478 | and jump on coding now.
479 |
480 | **6.Coding**
481 |
482 | So I’m calling my mainfunction islandCounter():
483 |
484 | Variable a,b,c If() While() For()
485 |
486 | **7.Debugging**
487 |
488 | Test cases: input None -\> return 0 so its working
489 |
490 | So [[1,0,1],[1,1,0]]. Go ahead, that looks good. Now I’m adding both of these.
491 | And I probably {} O looks like I forget to {add a return} Looks like it works.
492 |
493 | Python programming:
494 | ===================
495 |
496 | \<\<\<\<\<\<\< HEAD while(len(q)!= 0):
497 |
498 | **6. Debug:**
499 |
500 | And run it by
501 |
502 | {oh looks like I forget to}
503 |
504 | Looks like it works.
505 |
506 | 
507 |
508 | \>\>\>\>\>\>\> 600e13278473db6cc40a022e79c37c0e0baa2b56
509 |
--------------------------------------------------------------------------------
/Archive/README - Copy.md:
--------------------------------------------------------------------------------
1 | Data Structures and Algorithms
2 | ==============================
3 |
4 | This is the summary of multiple materials on **Data Structures and Algorithms**.
5 |
6 | I’ve included the code for each concept in Python. I would suggest to implement
7 | this short code for your projects or coding interviews..
8 |
9 | I highly recommend the following materials by the order of importance:
10 |
11 | 1. [Udacity nano degree: Data Structures and
12 | Algorithms](https://www.udacity.com/course/data-structures-and-algorithms-nanodegree--nd256)
13 |
14 | 2. Youtube playlist
15 |
16 | 3. Data Structure in C book
17 |
18 | **Interview practice:**
19 |
20 | online peer-peer practice: http://Pramp.com
21 |
22 | TLDR Objectives: Understanding of various types of techniques for algorithms
23 | design and (run time) analysis in detail. Also, a gentle introduction to several
24 | advanced data structures.
25 |
26 | TLDR Overview: Review of mathematical background, sorting and searching,
27 | algorithm design techniques such as divide and conquer, greedy approach, dynamic
28 | programming, worst case and average case analysis techniques, data structures
29 | such as binary search trees and various heaps, graph algorithms, string
30 | algorithms and geometric data structures, advanced topics (P, NP, NP-Complete,
31 | etc) if time permits.
32 |
33 | Solving any algorithm problem:
34 | ==============================
35 |
36 | 
37 |
38 | Think in simple term:
39 |
40 | 1. Don’t panic
41 |
42 | 2. What are the inputs
43 |
44 | 3. What are the outputs
45 |
46 | 4. Solve the problem
47 |
48 | **Next:**
49 |
50 | Do some examples on paper/mind, find **relationship** between input and output,
51 | finally, test some cases.
52 |
53 | Try solve the problem **On paper first**.
54 |
55 | Write algorithm. Pseudocode.
56 |
57 | Example 1 [Code included]: Write an algorithm /code that counts the difference
58 | of two dates.
59 |
60 | Ask yourself:
61 |
62 | Dates, DF, are all the inputs are valid? 1st data 2nd Second date must not be
63 | older than 1: invalid input
64 |
65 | How input are encoded? (yyyy,mm,dd)
66 |
67 | Output return a number because we can do things with return value rather
68 | printing it
69 |
70 | 
71 |
72 | First code: writing a block that makes the solution to work. Solve with a single
73 | simple case.
74 |
75 | Break into simple parts so that we can see our progress.
76 |
77 | Write simple small codes that work
78 |
79 | No need to figure out all the details. Consider that you will procrastinate
80 | later
81 |
82 | Comparison
83 | ==========
84 |
85 | Finding the smallest of n numbers:(n-1)
86 | Finding the biggest of n numbers:(n-1)
87 | Finding the smallest and the biggest of n numbers:(2n-3)
88 |
89 | Big O Notion:
90 | =============
91 |
92 | As the input to an algorithm increases, the time required to run the algorithm
93 | may also increase.
94 |
95 | For example in **Nested Loops**:
96 |
97 | For I in range:
98 |
99 | For j in range:
100 |
101 | > Print(“hello World”)
102 |
103 | Will increases the lines dramatically
104 |
105 | The *rate of increase* of an algorithm is also referred to as the **order** of
106 | the algorithm
107 |
108 | For example, instead of saying "this relationship has a linear rate of
109 | increase", we could instead say, "The *order* of this relationship is linear".
110 |
111 | *O Notation*, and you'll see that the "O" in the name refers to the **o**rder of
112 | the rate of increase.
113 |
114 | Length of input to my function
115 |
116 | O(2n+2) \> n=10 -\> 22
117 |
118 | In n\^2 + 5*n*2+5, the 55 has very little impact on the total
119 | efficiency—especially as the input size gets larger and larger. Asking the
120 | computer to do 10,005 operations vs. 10,000 operations makes little difference.
121 | Thus, it is the n\^2*n*2 that we really care about the most, and the + 5+5 makes
122 | little difference
123 |
124 | Efficiency is actually about O(n) Interviewer wants us to think about
125 | efficiency.
126 |
127 | Run time analysis
128 |
129 | O(3N) space efficiency (copying code)
130 |
131 | Int , float 4 bytes
132 |
133 | char 1 byte
134 |
135 | TLDR: Binary search (Middle, Middle, O (log(n)).:
136 | =================================================
137 |
138 | 
139 |
140 | **Algorithm:** Tricks to solve a problem
141 |
142 | **Q:** How to find number 25 in this stack?
143 |
144 | **A:**
145 |
146 | **1. Linear search: O(n)**
147 |
148 | **2. Binary Search:** O(log(n)+1) ( Why it is called binary search? find a
149 | postion of binary)
150 |
151 | Middle, Middle, Middle.
152 |
153 | Sorting:
154 | ========
155 |
156 | **Bubble sort:**
157 |
158 | Simplest and most inefficient one O(n\^2)
159 |
160 | Merge Sort(divide, merge):
161 | ==========================
162 |
163 | Using divide and conquer, first, we divide 2 by 2
164 |
165 | 
166 |
167 | Then we compare the elements
168 |
169 | 
170 |
171 | Efficiency:
172 |
173 | O (n Log (n))
174 |
175 | Why we are seeing log (n) in our efficiency? Hint: same as binary search problem
176 |
177 | QuickSort(divide, merge):
178 | =========================
179 |
180 | Pick one and move it around
181 |
182 | 
183 |
184 | Why it can be chosen as the most efficient algorithm?
185 |
186 | Because on average it will outperform merge sort.
187 |
188 | On each step we are performing two moving around.
189 |
190 | 
191 |
192 | (Pivot = Last element) First move we move
193 |
194 | 1. Select right P
195 |
196 | 2. PL LS SP (Shift Pivot to left , Swap start and left)
197 |
198 | 3. Compare Start with pivot. If (Start \> Pivot repeat step 2)
199 |
200 | 4. Else move to second start
201 |
202 | 
203 |
204 | 
205 |
206 | I advise to practice this for cementing the algorithm.
207 |
208 | 
209 |
210 | **Great no need to move the original pivot anymore (2 is at the right place)**
211 |
212 | 
213 |
214 | Check 2 with lefts
215 |
216 | New pivot on right. Compare
217 |
218 | Moving phase
219 |
220 | Everything less than 8 and 10 sweap results in:
221 | Everythin less than 8 are already below 8 so cemented
222 |
223 | 
224 |
225 | **Efficiency:**
226 |
227 | **O(n2) if it’s already sorted. Why? Wasting time**
228 |
229 | Heaps:
230 | ======
231 |
232 | <<<<<<< HEAD
233 | Dynamic programming:
234 | ====================
235 |
236 | 
237 |
238 | Knapsack. Imagine the skyrim world where you can carry a certain weight in your
239 | bag.
240 |
241 | How you optimize which items with their weights to carry with you?
242 |
243 | 1. Brute force: check all the solutions and pick the best one: O(2\^n) possible
244 | combinations
245 |
246 | Technical Interview
247 | ===================
248 | =======
249 | Greedy Algorithm (Best option at each step):
250 | ================================================
251 |
252 | 
253 |
254 | ATM machine : 1,2,10,20,50,100\<
255 |
256 | Return: n\$ the number of bills should be minimized
257 |
258 | 21\$ = 20 +1
259 |
260 | N= 365 – (3x100)- (1x50)-(1x10) – (1x 5)
261 |
262 | What about Target = 8?
263 |
264 | Example:
265 |
266 | Min operations example {see code}: By using while, in dividing numbers in half
267 | // == / and using
268 |
269 | Graph algorithm (data structure that shows relation):
270 | =====================================================
271 |
272 | Graph(Tree is a subgroup of graph,Network) Nodes(Vertex) Edges
273 |
274 | 
275 |
276 | Directed (non-directed), Acyclic, Connectivity
277 |
278 | Connectivity: You friends (social circle)
279 |
280 | As seen below, the right graph is stronger. In contrast, the left group can be
281 | dissolved if one of the connections drops.
282 |
283 | 
284 |
285 | Technical Interview (CIOT BRCD) (cute bird)
286 | ===========================================
287 | >>>>>>> 600e13278473db6cc40a022e79c37c0e0baa2b56
288 |
289 | What are the most important 7 steps?
290 |
291 | {Memory Palace} Imagine a cute bird sees a giant worm that is shaped like a Q
292 | {Question}. First the bird pour water on the worm (clarify). Then it find the
293 | tail and head (I, O). Then it will taste the worm (Test). It will use its brain
294 | to decide how to eat it (Brainstorm). Then a big white eagle comes and its needs
295 | to calculate the runtime of eating the worm {Runtime analysis}. Then it will
296 | start eating it with If, For, {Code} and Debugs it (No more bug).
297 |
298 | 
299 |
300 | The context should be asking questions and brainstorm at first. As you go on you
301 | rather than asking question everystep you must make statements and justify them.
302 |
303 | {so we can have null input like [[]] Is that right?} { I have a feeling that it
304 | might be useful in future steps}
305 |
306 | Example: So it contains integers right? So Null input is another input that we
307 | can have.
308 |
309 | Q:
310 | A: Thanks it’s a pleasure to do interview with you. {Positive mindset} {Don’t
311 | give up}
312 |
313 | 1. **Clarifying the question {To prove you wont dive into the problem without
314 | learning more about it}**
315 |
316 | Q: Given a 2D matrix of m, Just 0 and 1. Count the number of islands in the
317 | matrix [island is a group of 1 or just 1 by itself.]
318 |
319 | A: ok so, we are given a 2D matrix which will look something like this.:
320 |
321 | [[1,0,1],[1,1,1]]
322 |
323 | So, our goal is find the number of islands. Is the outcome the number? Or X? So
324 | if the are connected (I[1,0,0],[0,1,0],[0,0,1]) diagonally? Does that consider
325 | an island?
326 |
327 | So what we supposed to do is to find the number of
328 |
329 | {Just want to check Im solving the right problem…}
330 |
331 | 1. Generating inputs and outputs:
332 |
333 | > So my input is matrix of 0 s, 1 s (Integers, strings? No)
334 |
335 | > Output: Integer (\# of islands) (1s or group of ones)
336 |
337 | 1. Generating test cases:
338 |
339 | > {So just to test some cases {Special}}
340 |
341 | > {Can we get Is it ok we have }? Yes
342 |
343 | Q: number of island in a matrix
344 |
345 | **1.Clarify the question **
346 |
347 | A[[1,0,0]],[1,1,0]]{Just to make sure I’m solving the right problem….}
348 |
349 | **2.Generating input/output**
350 |
351 | <<<<<<< HEAD
352 | 1. Generating input/output
353 |
354 | Input matrix of integers
355 |
356 | Output integers ( number of islands 0- max{n})
357 |
358 | 1. {Trick \#1 you can always answer the null case to interviewer.}{ I have a
359 | feeling that it might be useful in future steps} **Test cases** [**Edge
360 | cases**] [ Possible weird inputs that we have to handle A[] or none object
361 |
362 | {Null - empty- Write a code that doesnt crash}
363 |
364 | 1. **Brainstorming** So if we have null, for sure we have 0 so there would be
365 | no islands in this case.
366 | =======
367 | Input matrix of integers.Output integers (number of islands 0- max{n})
368 |
369 | **3.Test cases**: {Trick \#1 you can always answer the null case to
370 | interviewer.}{ I have a feeling that it might be useful in future steps} **Test
371 | cases** [**Edge cases**] [ Possible weird inputs that we have to handle A[] or
372 | none object.
373 |
374 | {Null - empty- Write a code that doesnt crash}
375 |
376 | **4.Brainstorming:** {Variables that needs to initialized} {so I need to track
377 | X} {And keep tracking} {Runtime error} {Data structure brainstorm algorithms and
378 | data structures} {Represent graph DFS problem} So if we have null, for sure we
379 | have 0 so there would be no islands in this case.
380 | >>>>>>> 600e13278473db6cc40a022e79c37c0e0baa2b56
381 |
382 | But also we can have this as input (the input she wants) {So what I am
383 | thinking here} is start at the first element . So i need a counter **variable**
384 | and I **initialze** it there. And **increment** it by 1.
385 |
386 | We get to Zero. Thats not part of any island so I need to keep track of X.
387 | Hmmmm. Maybe I can look at the elements on top and bottom and check if they are
388 | on the same island and keep track of it. Since there is no above that. We get a
389 | run time error. Maybe it could a case of data structure we can solve this. {This
390 | might be a breath first search problem. I can look at the elements around it.
391 | **Set to mark** as **visited** and **keep going**
392 |
393 | **If you are stuck?** This represent a type of data structure and algorithm .
394 | Merge sort maybe… Keep talking
395 |
396 | **5. Runtime anaylsis **
397 |
398 | When I’m looking all the elements in matrix I’m looking at them atlease once so
399 | I’m thinking the runtime would be nXm where N is the number of rows and M is the
400 | number of columns. Well it seems like the optimal solution. So i think i start
401 | and jump on coding now.
402 |
403 | **6.Coding**
404 |
405 | So I’m calling my mainfunction islandCounter():
406 |
407 | Variable a,b,c If() While() For()
408 |
409 | **7.Debugging**
410 |
411 | Test cases: input None[] -\> return 0 so its working
412 |
413 | So [[1,0,1],[1,1,0]]. Go ahead, that looks good. Now I’m adding both of these.
414 | And I probably {} O looks like I forget to {add a return} Looks like it works.
415 |
416 | Python programming:
417 | ===================
418 |
419 | <<<<<<< HEAD
420 | while(len(q)!= 0):
421 |
422 | **6. Debug:**
423 |
424 | And run it by
425 |
426 | {oh looks like I forget to}
427 |
428 | Looks like it works.
429 |
430 |
431 | =======
432 | 
433 | >>>>>>> 600e13278473db6cc40a022e79c37c0e0baa2b56
434 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/1-python-refresher.py:
--------------------------------------------------------------------------------
1 | # tldr its about using keys and assigning vectors to them
2 | my_dict = {'a':[0, 1, 2, 3], 'b':[0, 1, 2, 3], 'c':[0, 1, 2, 3], 'd':[0, 1, 2, 3]}
3 | i=0
4 | output = []
5 | for key in my_dict:
6 | output.append(my_dict[key][i])
7 | i+=1
8 | print(output)
9 | # answer: [0, 1, 2, 3]
10 |
11 | print(my_dict['a'])
12 | for key in my_dict:
13 | print(key)
14 |
15 | """[0, 1, 2, 3]
16 | [0, 1, 2, 3]
17 | a
18 | b
19 | c
20 | d"""
21 |
22 | my_dict = {'a':[0,2,3,4],'b':[2,3,4], 'c':[0,1,4,3]}
23 | def printDict(M):
24 | i=0
25 | output = []
26 | for key in M:
27 | for i in range(len(M.output))
28 | output.append(M[key][i])
29 | i += 1
30 | print(output)
31 |
32 | printDict(my_dict)
--------------------------------------------------------------------------------
/Code/1-1-Introduction/2-control-structures.py:
--------------------------------------------------------------------------------
1 | # TLDR: 2 if state and 1 for for finding smallest positive number
2 | def smallest_positive(in_list):
3 | # TODO: Define a control structure that finds the smallest positive
4 | # number in in_list and returns the correct smallest number.
5 | arg1=in_list[0]
6 | for i in range(len(in_list)):
7 | if in_list[i] > 0:
8 | if in_list[i] <= arg1:
9 | arg1 = in_list[i]
10 | return arg1
11 |
12 | print(smallest_positive([4, -6, 7, 2, -4, 10]))
13 | # Correct output: 2
14 |
15 | print(smallest_positive([.2, 5, 3, -.1, 7, 7, 6]))
16 | # Correct output: 0.2
17 |
18 | def smallest_positive(in_list):
19 | # TODO: Define a control structure that finds the smallest positive
20 | # number in in_list and returns the correct smallest number.
21 |
22 | smallest_pos = None
23 | for num in in_list:
24 | if num > 0:
25 | # Note: we use a logical "or" in this solution to form
26 | # the conditional statement, although this was
27 | # not introduced above.
28 | if smallest_pos == None or num < smallest_pos:
29 | smallest_pos = num
30 | return smallest_pos
31 |
32 | # Test cases
33 |
34 | print(smallest_positive([4, -6, 7, 2, -4, 10]))
35 | # Correct output: 2
36 |
37 | print(smallest_positive([.2, 5, 3, -.1, 7, 7, 6]))
38 | # Correct output: 0.2
39 | # Test cases
40 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/3-control-structures-ex2.py:
--------------------------------------------------------------------------------
1 | # This exercise uses a data structure that stores Udacity course information.
2 | # The data structure format is:
3 |
4 | # { : { : { : , ... },
5 | # ... },
6 | # ... }
7 |
8 |
9 | courses = {
10 | 'spring2020': { 'cs101': {'name': 'Building a Search Engine',
11 | 'teacher': 'Dave',
12 | 'assistant': 'Peter C.'},
13 | 'cs373': {'name': 'Programming a Robotic Car',
14 | 'teacher': 'Sebastian',
15 | 'assistant': 'Andy'}},
16 | 'fall2020': { 'cs101': {'name': 'Building a Search Engine',
17 | 'teacher': 'Dave',
18 | 'assistant': 'Sarah'},
19 | 'cs212': {'name': 'The Design of Computer Programs',
20 | 'teacher': 'Peter N.',
21 | 'assistant': 'Andy',
22 | 'prereq': 'cs101'},
23 | 'cs253': {'name': 'Web Application Engineering - Building a Blog',
24 | 'teacher': 'Steve',
25 | 'prereq': 'cs101'},
26 | 'cs262': {'name': 'Programming Languages - Building a Web Browser',
27 | 'teacher': 'Wes',
28 | 'assistant': 'Peter C.',
29 | 'prereq': 'cs101'},
30 | 'cs373': {'name': 'Programming a Robotic Car',
31 | 'teacher': 'Sebastian'},
32 | 'cs387': {'name': 'Applied Cryptography',
33 | 'teacher': 'Dave'}},
34 | 'spring2044': { 'cs001': {'name': 'Building a Quantum Holodeck',
35 | 'teacher': 'Dorina'},
36 | 'cs003': {'name': 'Programming a Robotic Robotics Teacher',
37 | 'teacher': 'Jasper'},
38 | }
39 | }
40 |
41 |
42 | def when_offered(courses, course):
43 | # TODO: Fill out the function here.
44 | answer=[]
45 | for key in courses:
46 | if course in courses[key]:
47 | answer.append(key)
48 | # if key1 in c
49 | # TODO: Return list of semesters here.
50 | return answer
51 | # for key in courses:
52 | # courses[key][]
53 | # print(key)
54 |
55 |
56 | print(when_offered(courses, 'cs101'))
57 |
58 | # Correct result:
59 | # ['fall2020', 'spring2020']
60 |
61 | print(when_offered(courses, 'bio893'))
62 | # Correct result:
63 | # []
64 |
65 | # Answer:
66 | def when_offered(courses, course):
67 | # TODO: Fill out the function here.
68 | semesters = []
69 | for semester in courses:
70 | if course in courses[semester]:
71 | semesters.append(semester)
72 | # TODO: Return list of semesters here.
73 | return semesters
74 |
75 |
76 |
77 | print(when_offered(courses, 'cs101'))
78 | # Correct result:
79 | # ['fall2020', 'spring2020']
80 |
81 | print(when_offered(courses, 'bio893'))
82 | # Correct result:
83 | # []
84 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/4-generators.py:
--------------------------------------------------------------------------------
1 | def all_odd_for():
2 | n = 0
3 | # while True:
4 | for i in range(10):
5 | i += 1
6 | n += 1
7 | if (n % 2 != 0):
8 | print(n)
9 |
10 |
11 | def all_odd():
12 | n = 0
13 | while True:
14 | n += 1
15 | if (n % 2 != 0):
16 | yield n
17 | my_gen = all_odd()
18 |
19 | my_gen.__next__()
20 | print(next(my_gen))
21 | print(next(my_gen))
22 | print(next(my_gen))
23 | for i in range(20):
24 | print(next(my_gen))
--------------------------------------------------------------------------------
/Code/1-1-Introduction/5-factorial.py:
--------------------------------------------------------------------------------
1 | def prod(x,y):
2 | return x*y
3 | def factorial(num):
4 | n=1
5 | answer = 1
6 | while True:
7 | if (n < num):
8 | n += 1
9 | answer = prod(answer,n)
10 | else:
11 | yield answer
12 |
13 |
14 |
15 |
16 |
17 | n=5
18 | print(next(factorial(n)))
19 | print(next(factorial(n)))
20 | print(next(factorial(n)))
21 |
22 | # answer
23 | def prod(a,b):
24 | # TODO change output to the product of a and b
25 | output = a*b
26 | return output
27 |
28 | def fact_gen():
29 | i = 1
30 | n = i
31 | while True:
32 | output = prod(n, i)
33 | i+=1
34 | n = output
35 | yield output
36 | # TODO: update i and n
37 | # Hint: i is a successive integer and n is the previous product
38 |
39 |
40 | # Test block
41 | my_gen = fact_gen()
42 | num = 5
43 | for i in range(num):
44 | print(next(my_gen))
45 |
46 | # Correct result when num = 5:
47 | # 1
48 | # 2
49 | # 6
50 | # 24
51 | # 120
52 |
53 |
54 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/6-Sudoku.py:
--------------------------------------------------------------------------------
1 | correct = [[1,2,3],
2 | [2,3,1],
3 | [3,1,2]]
4 |
5 | incorrect = [[1,2,3,4],
6 | [2,3,1,3],
7 | [3,1,2,3],
8 | [4,4,4,4]]
9 |
10 | incorrect2 = [[1,2,3,4],
11 | [2,3,1,4],
12 | [4,1,2,3],
13 | [3,4,1,2]]
14 |
15 | incorrect3 = [[1,2,3,4,5],
16 | [2,3,1,5,6],
17 | [4,5,2,1,3],
18 | [3,4,5,2,1],
19 | [5,6,4,3,2]]
20 |
21 | incorrect4 = [['a','b','c'],
22 | ['b','c','a'],
23 | ['c','a','b']]
24 |
25 | incorrect5 = [ [1, 1.5],
26 | [1.5, 1]]
27 |
28 | def check_sudoku(square):
29 | for row in square:
30 | # Create a list with the integers 1, 2, ..., n.
31 | # We will check that each number in the row is in the list
32 | # and remove the numbers from the list once they are verified
33 | # to ensure that each number only occurs once in the row.
34 | check_list = list(range(1, len(square[0]) + 1))
35 | for i in row:
36 | if i not in check_list:
37 | return False
38 | check_list.remove(i)
39 | for n in range(len(square[0])):
40 | # We do the same here for each column in the square.
41 | check_list = list(range(1, len(square[0]) + 1))
42 | for row in square:
43 | if row[n] not in check_list:
44 | return False
45 | check_list.remove(row[n])
46 | return True
47 |
48 |
49 | print(check_sudoku(correct))
50 | #>>> False
51 |
52 | print(check_sudoku(correct))
53 | #>>> True
54 |
55 | print(check_sudoku(incorrect2))
56 | #>>> False
57 |
58 | print(check_sudoku(incorrect3))
59 | #>>> False
60 |
61 | print(check_sudoku(incorrect4))
62 | #>>> False
63 |
64 | print(check_sudoku(incorrect5))
65 | #>>> False
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/7-class.py:
--------------------------------------------------------------------------------
1 | class Person:
2 | def __init__(self, name, age, month):
3 | self.name = name
4 | self.age = age
5 | self.birthday_month = month
6 |
7 | def birthday(self):
8 | self.age += 1
9 |
10 | def create_person_objects(names, ages, months):
11 | my_data = zip(names, ages, months)
12 | person_objects = []
13 | for item in my_data:
14 | person_objects.append(Person(*item))
15 | return person_objects
16 |
17 | def get_april_birthdays(people):
18 | # TODO:
19 | # Increment "age" for all people with birthdays in April.
20 | # Return a dictionary "april_birthdays" with the names of
21 | # all people with April birthdays as keys, and their updated ages
22 | # as values. See the test below for an example expected output.
23 | april_birthdays = {}
24 | for person in people:
25 | if person.birthday_month == 'April':
26 | person.age += 1
27 | april_birthdays[person.name] = person.age
28 |
29 | return april_birthdays
30 |
31 | def get_most_common_month(people):
32 | # TODO: Use the "months" dictionary to record counts of
33 | # birthday months for persons in the "people" data.
34 | # Return the month with the largest number of birthdays.
35 | months = {'January':0, 'February':0, 'March':0, 'April':0, 'May':0,
36 | 'June':0, 'July':0, 'August':0, 'September':0, 'October':0,
37 | 'November':0, 'December':0}
38 |
39 | for person in people:
40 | months[person.birthday_month] += 1
41 |
42 | max_month = None
43 | max_value = 0
44 | for key in months.keys():
45 | if months[key] > max_value:
46 | max_value = months[key]
47 | max_month = key
48 |
49 | return max_month
50 |
51 |
52 |
53 | def test():
54 | # Here is the data for the test. Assume there is a single most common month.
55 | names = ['Howard', 'Richard', 'Jules', 'Trula', 'Michael', 'Elizabeth', 'Richard', 'Shirley', 'Mark', 'Brianna', 'Kenneth', 'Gwen', 'William', 'Rosa', 'Denver', 'Shelly', 'Sammy', 'Maryann', 'Kathleen', 'Andrew', 'Joseph', 'Kathleen', 'Lisa', 'Viola', 'George', 'Bonnie', 'Robert', 'William', 'Sabrina', 'John', 'Robert', 'Gil', 'Calvin', 'Robert', 'Dusty', 'Dario', 'Joeann', 'Terry', 'Alan', 'Rosa', 'Jeane', 'James', 'Rachel', 'Tu', 'Chelsea', 'Andrea', 'Ernest', 'Erica', 'Priscilla', 'Carol', 'Michael', 'Dale', 'Arthur', 'Helen', 'James', 'Donna', 'Patricia', 'Betty', 'Patricia', 'Mollie', 'Nicole', 'Ernest', 'Wendy', 'Graciela', 'Teresa', 'Nicole', 'Trang', 'Caleb', 'Robert', 'Paul', 'Nieves', 'Arleen', 'Milton', 'James', 'Lawrence', 'Edward', 'Susan', 'Patricia', 'Tana', 'Jessica', 'Suzanne', 'Darren', 'Arthur', 'Holly', 'Mary', 'Randal', 'John', 'Laura', 'Betty', 'Chelsea', 'Margaret', 'Angel', 'Jeffrey', 'Mary', 'Donald', 'David', 'Roger', 'Evan', 'Danny', 'William']
56 | ages = [17, 58, 79, 8, 10, 57, 4, 98, 19, 47, 81, 68, 48, 13, 39, 21, 98, 51, 49, 12, 24, 78, 36, 59, 3, 87, 94, 85, 43, 69, 15, 52, 57, 36, 52, 5, 52, 5, 33, 10, 71, 28, 70, 9, 25, 28, 76, 71, 22, 35, 35, 100, 9, 95, 69, 52, 66, 91, 39, 84, 65, 29, 20, 98, 30, 83, 30, 15, 88, 89, 24, 98, 62, 94, 86, 63, 34, 23, 23, 19, 10, 80, 88, 67, 17, 91, 85, 97, 29, 7, 34, 38, 92, 29, 14, 52, 94, 62, 70, 22]
57 | months = ['January', 'March', 'January', 'October', 'April', 'February', 'August', 'January', 'June', 'August', 'February', 'May', 'March', 'June', 'February', 'August', 'June', 'March', 'August', 'April', 'April', 'June', 'April', 'June', 'February', 'September', 'March', 'July', 'September', 'December', 'June', 'June', 'August', 'November', 'April', 'November', 'August', 'June', 'January', 'August', 'May', 'March', 'March', 'March', 'May', 'September', 'August', 'April', 'February', 'April', 'May', 'March', 'March', 'January', 'August', 'October', 'February', 'November', 'August', 'June', 'September', 'September', 'January', 'September', 'July', 'July', 'December', 'June', 'April', 'February', 'August', 'September', 'August', 'February', 'April', 'July', 'May', 'November', 'December', 'February', 'August', 'August', 'September', 'December', 'February', 'March', 'June', 'December', 'February', 'May', 'April', 'July', 'March', 'June', 'December', 'March', 'July', 'May', 'September', 'November']
58 | people = create_person_objects(names, ages, months)
59 |
60 | # Calls to the two functions you have completed.
61 | print(get_april_birthdays(people))
62 | print(get_most_common_month(people))
63 |
64 |
65 |
66 | test()
67 | # Expected result:
68 | # {'Michael': 11, 'Erica': 72, 'Carol': 36, 'Lisa': 37, 'Lawrence': 87, 'Joseph': 25, 'Margaret': 35, 'Andrew': 13, 'Dusty': 53, 'Robert': 89}
69 | # August
70 |
--------------------------------------------------------------------------------
/Code/1-1-Introduction/8-my thoughts.py:
--------------------------------------------------------------------------------
1 | # why are we using self and all that in machine learning?
2 | # There is no use of that. All of the machine learning problems can be solved as a data engineering problems
3 |
4 | # Problem 1: Tokenize a dataset
5 | import os
6 | addresses = [51234,3413245,412341235,132231344]
7 | def tokenize(arg1):
8 | tokenized_address = [[],
9 | []]
10 | i = 0
11 | for item in arg1:
12 | tokenized_address[0].append(item)
13 | item = i
14 | tokenized_address[1].append(item)
15 | i+=1
16 | tokenized_address
17 | with open("token.txt",'w') as f:
18 | for item in str(tokenized_address):
19 | f.write(item)
20 | print(tokenized_address)
21 | return tokenized_address
22 | tokenize(addresses)
23 | def de_tokenize(arg1):
24 | new_list = []
25 | with open("token.txt",'r') as f:
26 | for item in f:
27 | new_list.append(f)
28 | print(new_list)
29 | return new_list
30 |
31 | de_tokenize(addresses)
--------------------------------------------------------------------------------
/Code/1-1-Introduction/token.txt:
--------------------------------------------------------------------------------
1 | [[51234, 3413245, 412341235, 132231344], [0, 1, 2, 3]]
--------------------------------------------------------------------------------
/Code/1-2-Solve problems/Age.py:
--------------------------------------------------------------------------------
1 | # def nextDay(year,month,day):
2 | # """Only for 30 days
3 |
4 | # Args:
5 | # year (int): clear
6 | # month (int): clear
7 | # day (int ): clear
8 |
9 | # Returns:
10 | # three int's: the next day function
11 | # """
12 | # if(day<30):
13 | # day += 1
14 | # print(year,month,day)
15 | # return year,month,day
16 | # if(day==30 and month==12):
17 | # year +=1
18 | # month = 1
19 | # day = 1
20 | # print(year,month,day)
21 | # return year,month,day
22 | # if(day==30 and month!=12):
23 | # month += 1
24 | # day = 1
25 | # print(year,month,day)
26 | # return year,month,day
27 | # # All months have 30days
28 |
29 | # nextDay(1999, 12, 30)
30 | # nextDay(2013, 1, 30)
31 | # nextDay(2012, 12, 30)
32 |
33 | # Define a daysBetweenDates procedure that would produce the
34 | # correct output if there was a correct nextDay procedure.
35 | #
36 | # Note that this will NOT produce correct outputs yet, since
37 | # our nextDay procedure assumes all months have 30 days
38 | # (hence a year is 360 days, instead of 365).
39 | #
40 |
41 | def nextDay(year, month, day):
42 | """Simple version: assume every month has 30 days"""
43 | if day < 30:
44 | return year, month, day + 1
45 | else:
46 | if month == 12:
47 | return year + 1, 1, 1
48 | else:
49 | return year, month + 1, 1
50 |
51 | def daysBetweenDates(year1, month1, day1, year2, month2, day2):
52 | my_bool= True
53 | counter=0
54 | arg_y,arg_m,arg_d=year1,month1,day1
55 | while my_bool:
56 | arg_y,arg_m,arg_d = nextDay(arg_y,arg_m,arg_d)
57 | counter += 1
58 | if(arg_y==year2 and arg_m==month2 and arg_d==day2):
59 | my_bool=False
60 | print(counter)
61 | return counter
62 |
63 | daysBetweenDates(1,1,1,1,1,10)
64 |
65 | def test():
66 | test_cases = [((2012,9,30,2012,10,30),30),
67 | ((2012,1,1,2013,1,1),360),
68 | ((2012,9,1,2012,9,4),3)]
69 |
70 | for (args, answer) in test_cases:
71 | result = daysBetweenDates(*args)
72 | if result != answer:
73 | print ("Test with data:", args, "failed")
74 | else:
75 | print ("Test case passed!")
76 |
77 | test()
78 |
79 |
80 | # His code
81 | # Credit goes to Websten from forums
82 | #
83 | # Program defensively:
84 | #
85 | # What do you do if your input is invalid? For example what should
86 | # happen when date 1 is not before date 2?
87 | #
88 | # Add an assertion to the code for daysBetweenDates to give
89 | # an assertion failure when the inputs are invalid. This should
90 | # occur when the first date is not before the second date.
91 | #
92 |
93 | def nextDay(year, month, day):
94 | """Simple version: assume every month has 30 days"""
95 | if day < 30:
96 | return year, month, day + 1
97 | else:
98 | if month == 12:
99 | return year + 1, 1, 1
100 | else:
101 | return year, month + 1, 1
102 |
103 | def dateIsBefore(year1, month1, day1, year2, month2, day2):
104 | """Returns True if year1-month1-day1 is before
105 | year2-month2-day2. Otherwise, returns False."""
106 | if year1 < year2:
107 | return True
108 | if year1 == year2:
109 | if month1 < month2:
110 | return True
111 | if month1 == month2:
112 | return day1 < day2
113 | return False
114 |
115 | def daysBetweenDates(year1, month1, day1, year2, month2, day2):
116 | """Returns the number of days between year1/month1/day1
117 | and year2/month2/day2. Assumes inputs are valid dates
118 | in Gregorian calendar."""
119 | # program defensively! Add an assertion if the input is not valid!
120 |
121 | days = 0
122 | while dateIsBefore(year1, month1, day1, year2, month2, day2):
123 | year1, month1, day1 = nextDay(year1, month1, day1)
124 | days += 1
125 | return days
126 |
127 | def test():
128 | test_cases = [((2012,9,30,2012,10,30),30),
129 | ((2012,1,1,2013,1,1),360),
130 | ((2012,9,1,2012,9,4),3),
131 | ((2013,1,1,1999,12,31), "AssertionError")]
132 |
133 | for (args, answer) in test_cases:
134 | try:
135 | result = daysBetweenDates(*args)
136 | if result == answer and answer != "AssertionError":
137 | print ("Test case passed!")
138 | else:
139 | print ("Test with data:", args, "failed")
140 |
141 | except AssertionError:
142 | if answer == "AssertionError":
143 | print ("Nice job! Test case {0} correctly raises AssertionError!\n".format(args))
144 | else:
145 | print ("Check your work! Test case {0} should not raise AssertionError!\n".format(args) )
146 | test()
147 |
--------------------------------------------------------------------------------
/Code/1-3-Efficiency/Effciency_Notes.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/32ada10a94cc6172ec72becdac3a6df14a534e23/Code/1-3-Efficiency/Effciency_Notes.docx
--------------------------------------------------------------------------------
/Code/1-4_Project/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/32ada10a94cc6172ec72becdac3a6df14a534e23/Code/1-4_Project/.DS_Store
--------------------------------------------------------------------------------
/Code/1-4_Project/Task0.py:
--------------------------------------------------------------------------------
1 | """
2 | Read file into texts and calls.
3 | It's ok if you don't understand how to read files.
4 | """
5 | import csv
6 | with open('texts.csv', 'r') as f:
7 | reader = csv.reader(f)
8 | texts = list(reader)
9 |
10 | with open('calls.csv', 'r') as f:
11 | reader = csv.reader(f)
12 | calls = list(reader)
13 |
14 |
15 | """
16 | TASK 0:
17 | What is the first record of texts and what is the last record of calls?
18 | Print messages:
19 | "First record of texts, texts at time