├── media ├── array.png.md ├── best.png ├── sol.png ├── Double.png ├── arrays.png ├── linked.png ├── runfi.png ├── types.png ├── outline.png ├── runtime.png ├── 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 ├── aafcce2fa1d4355bed1f9c7f5850c437.png ├── aedaa435d36c4f0f3cbf29d50034fdd2.png ├── b41c1c2d2548c9e6940e3506ec84f34f.png ├── c018057d901372ab5b57e93742036550.png ├── c75f1ae6443175cde6bff55aaa014eda.png ├── d5e6c36b1d10faaaf0d1ae40e3182cca.png ├── d60404983770ccf9700e87bf00057d26.png ├── dab72f2bab27818a10403e79984d290a.png ├── efb964d97b2648ca21e04162697e01e1.png ├── fb4c847451ca46a38339e5be359320a9.png └── fea061ac8378d67ca943d89b8a692000.png ├── .obsidian ├── hotkeys.json ├── appearance.json ├── core-plugins.json ├── app.json ├── workspace └── snippets │ └── obsidian.css ├── Code ├── 1-1-Introduction │ ├── token.txt │ ├── 4-generators.py │ ├── 1-python-refresher.py │ ├── 8-my thoughts.py │ ├── 5-factorial.py │ ├── 2-control-structures.py │ ├── 6-Sudoku.py │ ├── 3-control-structures-ex2.py │ └── 7-class.py ├── 1-4_Project │ ├── .DS_Store │ ├── test1.py │ ├── Task0.py │ ├── Task2.py │ ├── Task4.py │ ├── Task3.py │ └── Task1.py ├── 1-3-Efficiency │ └── Effciency_Notes.docx ├── 7-Technical Interview │ ├── Python1.py │ ├── Question2.py │ └── Question1.py ├── 3-Algorithms │ ├── sorting_algorithm.py │ ├── 1-comparison.py │ ├── greedyNumOperations.py │ ├── greedyATM.py │ └── greedyTrain.py ├── 6-Dynamic-Programming │ ├── fibionachi.py │ ├── stock_prices.py │ └── 001_Knapsack problem.py └── 1-2-Solve problems │ └── Age.py ├── README.md ├── Archive ├── README - Copy.md └── README - Copy (2).md ├── ~WRL2750.tmp ├── code └── Python_OBB_One_Notebook_for_all.ipynb └── LICENSE /media/array.png.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.obsidian/hotkeys.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Code/1-1-Introduction/token.txt: -------------------------------------------------------------------------------- 1 | [[51234, 3413245, 412341235, 132231344], [0, 1, 2, 3]] -------------------------------------------------------------------------------- /media/best.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/best.png -------------------------------------------------------------------------------- /media/sol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/sol.png -------------------------------------------------------------------------------- /media/Double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/Double.png -------------------------------------------------------------------------------- /media/arrays.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/arrays.png -------------------------------------------------------------------------------- /media/linked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/linked.png -------------------------------------------------------------------------------- /media/runfi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/runfi.png -------------------------------------------------------------------------------- /media/types.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/types.png -------------------------------------------------------------------------------- /media/outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/outline.png -------------------------------------------------------------------------------- /media/runtime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/runtime.png -------------------------------------------------------------------------------- /Code/1-4_Project/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/Code/1-4_Project/.DS_Store -------------------------------------------------------------------------------- /.obsidian/appearance.json: -------------------------------------------------------------------------------- 1 | { 2 | "theme": "moonstone", 3 | "baseFontSize": 10, 4 | "enabledCssSnippets": [ 5 | "obsidian" 6 | ] 7 | } -------------------------------------------------------------------------------- /Code/1-3-Efficiency/Effciency_Notes.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/Code/1-3-Efficiency/Effciency_Notes.docx -------------------------------------------------------------------------------- /media/1f11fb9b2ed3eb432764db5635531f54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/1f11fb9b2ed3eb432764db5635531f54.png -------------------------------------------------------------------------------- /media/28a37a2c4d8794faa0b22686c21cbece.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/28a37a2c4d8794faa0b22686c21cbece.png -------------------------------------------------------------------------------- /media/2aab5b68c0b0e7ea62486cfe66e08caa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/2aab5b68c0b0e7ea62486cfe66e08caa.png -------------------------------------------------------------------------------- /media/393309480a114e09e85165f26cfdf15d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/393309480a114e09e85165f26cfdf15d.png -------------------------------------------------------------------------------- /media/426dc47adbe8aa35d9ca78e2e77905be.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/426dc47adbe8aa35d9ca78e2e77905be.png -------------------------------------------------------------------------------- /media/44d46f063fca4872104e6edb1a26e63d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/44d46f063fca4872104e6edb1a26e63d.png -------------------------------------------------------------------------------- /media/4a3923fde43ff67cc4066b14626677b0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/4a3923fde43ff67cc4066b14626677b0.png -------------------------------------------------------------------------------- /media/4c958b1e2b2f2c7a5c54dc66945872db.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/4c958b1e2b2f2c7a5c54dc66945872db.png -------------------------------------------------------------------------------- /media/4def5b724f6f15c6b099ce425f8c4e09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/4def5b724f6f15c6b099ce425f8c4e09.png -------------------------------------------------------------------------------- /media/4fe578f16ea7ad1e9fd04d71fdea444a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/4fe578f16ea7ad1e9fd04d71fdea444a.png -------------------------------------------------------------------------------- /media/5a7c7e913b6193df10c1bd43504915d2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/5a7c7e913b6193df10c1bd43504915d2.png -------------------------------------------------------------------------------- /media/807b5c8aee182baaa1713c01e98994f9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/807b5c8aee182baaa1713c01e98994f9.png -------------------------------------------------------------------------------- /media/8772bf182b4a29b45fa854704118a58d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/8772bf182b4a29b45fa854704118a58d.png -------------------------------------------------------------------------------- /media/9475b959311dc362995bdb778c55234b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/9475b959311dc362995bdb778c55234b.png -------------------------------------------------------------------------------- /media/979a59ecbdab5b700013dbe7875b4603.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/979a59ecbdab5b700013dbe7875b4603.png -------------------------------------------------------------------------------- /media/9beca1381c793944285f552ff3a4842c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/9beca1381c793944285f552ff3a4842c.png -------------------------------------------------------------------------------- /media/aafcce2fa1d4355bed1f9c7f5850c437.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/aafcce2fa1d4355bed1f9c7f5850c437.png -------------------------------------------------------------------------------- /media/aedaa435d36c4f0f3cbf29d50034fdd2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/aedaa435d36c4f0f3cbf29d50034fdd2.png -------------------------------------------------------------------------------- /media/b41c1c2d2548c9e6940e3506ec84f34f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/b41c1c2d2548c9e6940e3506ec84f34f.png -------------------------------------------------------------------------------- /media/c018057d901372ab5b57e93742036550.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/c018057d901372ab5b57e93742036550.png -------------------------------------------------------------------------------- /media/c75f1ae6443175cde6bff55aaa014eda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/c75f1ae6443175cde6bff55aaa014eda.png -------------------------------------------------------------------------------- /media/d5e6c36b1d10faaaf0d1ae40e3182cca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/d5e6c36b1d10faaaf0d1ae40e3182cca.png -------------------------------------------------------------------------------- /media/d60404983770ccf9700e87bf00057d26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/d60404983770ccf9700e87bf00057d26.png -------------------------------------------------------------------------------- /media/dab72f2bab27818a10403e79984d290a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/dab72f2bab27818a10403e79984d290a.png -------------------------------------------------------------------------------- /media/efb964d97b2648ca21e04162697e01e1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/efb964d97b2648ca21e04162697e01e1.png -------------------------------------------------------------------------------- /media/fb4c847451ca46a38339e5be359320a9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/fb4c847451ca46a38339e5be359320a9.png -------------------------------------------------------------------------------- /media/fea061ac8378d67ca943d89b8a692000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ashfarhangi/Algorithms_Data_Structures_Notes/HEAD/media/fea061ac8378d67ca943d89b8a692000.png -------------------------------------------------------------------------------- /Code/1-4_Project/test1.py: -------------------------------------------------------------------------------- 1 | arg1 = [1234,12342,13243,1234,51,1234] 2 | print(arg1) 3 | idx = 0 4 | for i in range(10): 5 | if(arg1.count(1234)!=0): 6 | idx = arg1.index(1234,idx) 7 | print(idx) 8 | del arg1[idx] 9 | idx +=1 10 | print(arg1) -------------------------------------------------------------------------------- /Code/7-Technical Interview/Python1.py: -------------------------------------------------------------------------------- 1 | # room_numbers = { 2 | # ['Freddie', 'Jen']: 403, 3 | # ['Ned', 'Keith']: 391, 4 | # ['Kristin', 'Jazzmyne']: 411, 5 | # ['Eugene', 'Zach']: 395 6 | # } 7 | tree ={1:{"left": 2, "right": None, "parent": 4 8 | 9 | }} 10 | print(tree[1]["right"]) -------------------------------------------------------------------------------- /.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 | ] -------------------------------------------------------------------------------- /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/7-Technical Interview/Question2.py: -------------------------------------------------------------------------------- 1 | array1 = [1,2,3,-5,1,0,2] 2 | array2 = [] 3 | """ 4 | input: [1,3,5]; [] ;None 5 | output: [1,5], None 6 | 7 | 8 | """ 9 | def smallestAndLargest(arr): 10 | if(arr == None or arr == []): 11 | return None 12 | 13 | largest = arr[0] 14 | smallest = arr[0] 15 | key = None 16 | 17 | for i in range(len(arr)): 18 | if(arr[i] <= smallest): 19 | smallest = arr[i] 20 | if(arr[i] >= largest): 21 | largest = arr[i] 22 | print([smallest,largest]) 23 | 24 | smallestAndLargest(array1) -------------------------------------------------------------------------------- /Code/3-Algorithms/sorting_algorithm.py: -------------------------------------------------------------------------------- 1 | """Summary 2 | use a key to hold the number and keep it in its place if its higher than left ones /or replace it with left ones if its lower 3 | [5,2] > [2,5] 4 | Attributes: 5 | A (list): Just a list 6 | """ 7 | A = [5,2,4,6,1,3] 8 | 9 | def insertion_sort(): 10 | """insertaion sort effective 1s 11 | """ 12 | for j in range(1,len(A)): 13 | key = A[j] 14 | i = j - 1 15 | while(i>=0 and A[i]>key): 16 | A[i+1] = A[i] 17 | i = i-1 18 | A[i+1] = key 19 | print(A) 20 | 21 | def python_sort(): 22 | """Tim sort: 23 | """ 24 | A.sort() 25 | print(A) 26 | 27 | 28 | insertion_sort() 29 | # 0.2s 30 | python_sort() 31 | # 0.1s 32 | -------------------------------------------------------------------------------- /Code/3-Algorithms/1-comparison.py: -------------------------------------------------------------------------------- 1 | a = [1,2,3,4,0] 2 | 3 | def smallest(a): 4 | key = a[0] 5 | o = 0 6 | for i in range(len(a)-1): 7 | o = o+ 1 8 | if (a[i]<=key): 9 | key = a[i] 10 | print(key,o) 11 | 12 | smallest(a) 13 | 14 | def biggest(a): 15 | key = a[0] 16 | o = 0 17 | for i in range(len(a)-1): 18 | o = o+ 1 19 | if (a[i]>=key): 20 | key = a[i] 21 | print(key,o) 22 | biggest(a) 23 | 24 | def biggestAndSmallest(a): 25 | key = a[0] 26 | o = 0 27 | for i in range(len(a)-1): 28 | o = o+ 1 29 | if (a[i]>=key): 30 | key = a[i] 31 | #drop it 32 | for i in range(len(a)-1): 33 | o = o+ 1 34 | if (a[i]<=key): 35 | key = a[i] 36 | print(key,o) 37 | 38 | biggestAndSmallest(a) 39 | 40 | -------------------------------------------------------------------------------- /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/6-Dynamic-Programming/fibionachi.py: -------------------------------------------------------------------------------- 1 | # fibionachi 2 | # input: 1 2 3 4 5 6 7 8 9 10 3 | # output: 1 1 2 3 5 8 13 21 34 55 4 | n = 3 5 | def fib(n): 6 | if n < 0: 7 | return False 8 | elif n== 0: 9 | return 0 10 | elif n == 1: 11 | return 1 12 | else: 13 | return fib(n-1)+fib(n-2) 14 | print(n) 15 | # o(n^2) 16 | print(fib(10)) 17 | #code taken from geeksforgeeks.org 18 | def dynamicFib(n): 19 | arr = [0,1] 20 | while (len(arr) < n+1): 21 | arr.append(0) 22 | 23 | if n < 0: 24 | return n 25 | if n<=1: 26 | return n 27 | else: 28 | if arr[n-1] ==0: 29 | arr[n-1] = dynamicFib(n-1) 30 | if arr[n-2] == 0: 31 | arr[n-2] == dynamicFib(n-2) 32 | arr[n] = arr[n-2] + arr[n-1] 33 | return arr[n] 34 | print(dynamicFib(2)) -------------------------------------------------------------------------------- /Code/3-Algorithms/greedyNumOperations.py: -------------------------------------------------------------------------------- 1 | target = 18 2 | numOperation = 6 3 | 4 | def minOperations(target:int) -> int: 5 | steps = 0 6 | while(target!=0): 7 | while(target/ 2) == (target//2): 8 | target = target // 2 9 | steps += 1 10 | 11 | 12 | target -=1 13 | steps +=1 14 | 15 | return steps 16 | 17 | def test_function(test_case): 18 | target = test_case[0] 19 | solution = test_case[1] 20 | output = minOperations(target) 21 | 22 | if output == solution: 23 | print("Pass") 24 | else: 25 | print("Fail") 26 | target = 18 27 | solution = 6 28 | test_case = [target, solution] 29 | test_function(test_case) 30 | target = 69 31 | solution = 9 32 | test_case = [target, solution] 33 | test_function(test_case) 34 | -------------------------------------------------------------------------------- /Code/3-Algorithms/greedyATM.py: -------------------------------------------------------------------------------- 1 | bills = [1,2,5,10,20,50,100] 2 | amount = 0 3 | 4 | """ 5 | CITBRCD 6 | input = [1,4,2] or [] or None 7 | 3.5 8 | output = integer 9 | 365=3x100 + 1x50 + 1x10 +1 x5 = 6 10 | initiate billCount variable, 11 | """ 12 | """Greedy algorithm choosing the best action at each step.""" 13 | 14 | def countBill(amount,bills): 15 | if (amount ==0 or amount == None): 16 | return False 17 | billCount = 0 18 | for i in range(1,len(bills)): 19 | arg1 = amount / bills[-i] 20 | if ( arg1>= 1): 21 | arg1 = int(arg1) 22 | billCount += arg1 23 | amount = amount - (arg1*bills[-i]) 24 | print( billCount) 25 | countBill(amount,bills) 26 | 27 | """ 28 | Its not optimal for {1,4,5,10} 29 | for target = 8 30 | 5 1 1 1 31 | rather than 4+4 32 | """ 33 | 34 | -------------------------------------------------------------------------------- /.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 | } -------------------------------------------------------------------------------- /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/7-Technical Interview/Question1.py: -------------------------------------------------------------------------------- 1 | from collections import deque 2 | m =[[1,0,1],[1,0,0]] 3 | def islandFinder(m): 4 | if(m == [] or m == None): 5 | return 0 6 | # Initiate variable count 7 | numIsland = 0 8 | #number of elements 9 | r = len(m) 10 | # number of rows just check the number of elements inside each element. 11 | c = len(m[0]) 12 | print("number of rows:",r) 13 | print("number of columns:",c) 14 | for i in range(r): 15 | for j in range(c): 16 | # if m[i,] 17 | if (m[i][j] == 1): 18 | numIsland+=1 19 | #Now we need breath first search? 20 | findPartsOfIsland(i,j) 21 | print(numIsland) 22 | # need to learn depth search first algorithm for trees. 23 | def findPartsOfIsland(i,j): 24 | q = deque() 25 | q.append([i,j]) 26 | while(len(q!=0)): 27 | x = q.pop() 28 | y = i[1] 29 | # Talk about the purpose of your code 30 | # use a que to get 31 | # First thing i want do to is initiatlize 32 | # since we are using. First 33 | islandFinder(m) -------------------------------------------------------------------------------- /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-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