├── ToDo-List ├── baseApp │ ├── __init__.py │ ├── migrations │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ └── 0001_initial.cpython-38.pyc │ │ └── 0001_initial.py │ ├── tests.py │ ├── admin.py │ ├── __pycache__ │ │ ├── apps.cpython-38.pyc │ │ ├── urls.cpython-38.pyc │ │ ├── admin.cpython-38.pyc │ │ ├── models.cpython-38.pyc │ │ ├── views.cpython-38.pyc │ │ └── __init__.cpython-38.pyc │ ├── apps.py │ ├── models.py │ ├── urls.py │ └── views.py ├── todo_list │ ├── __init__.py │ ├── __pycache__ │ │ ├── urls.cpython-38.pyc │ │ ├── wsgi.cpython-38.pyc │ │ ├── __init__.cpython-38.pyc │ │ └── settings.cpython-38.pyc │ ├── asgi.py │ ├── wsgi.py │ ├── urls.py │ └── settings.py ├── templates │ └── base │ │ ├── task_detail.html │ │ ├── task_create.html │ │ ├── task_delete.html │ │ ├── loginpage.html │ │ ├── register.html │ │ ├── task_list.html │ │ └── base.html ├── db.sqlite3 └── manage.py ├── registaration.py.rar ├── CDF Hstogram Analysis in Python ├── Image4.jpg └── Maths for Machine Learning Project ├── addition.py ├── Recursion ├── basic │ ├── Main.java │ ├── print_number.java │ ├── sum_digits.java │ ├── concept.java │ └── binary_search.java ├── tree_algos │ ├── max_depth.java │ └── isbalanced.java ├── leetcode │ ├── make_it_zero.java │ ├── count_opearation_zero.java │ └── Minimum_Moves_to_Reach_Target_Score.java ├── Array_recursion │ ├── sort.java │ ├── RBS.java │ └── linear_search.java ├── sorting │ ├── bubble_sort.java │ ├── selection_sort.java │ ├── MergeInPlaceSort.java │ └── MergeSort.java └── patterns │ └── one.java ├── contributers.md ├── function_overloading.cpp ├── README.md ├── palidrome.c ├── temp.py ├── merge.cpp ├── intojpg.py ├── dda_algorithm.c ├── ValidParentheses.cpp ├── youtube_video_downloader_requirement.txt ├── 0-1 Knapsack.cpp ├── SimpleCalculator.py ├── guessthenumber.java ├── imagetransfer.py ├── Largest Rectangle in histogram.cpp ├── Book_allocation.java ├── Z-algorithm.cpp ├── stringMethod.py ├── youtube_video_downloader.py ├── asteroid game.py └── Bellaman-ford-algo.cpp /ToDo-List/baseApp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ToDo-List/todo_list/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/task_detail.html: -------------------------------------------------------------------------------- 1 |

Task: {{tasks}}

-------------------------------------------------------------------------------- /ToDo-List/baseApp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /ToDo-List/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/db.sqlite3 -------------------------------------------------------------------------------- /registaration.py.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/registaration.py.rar -------------------------------------------------------------------------------- /ToDo-List/baseApp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from .models import Task 3 | 4 | 5 | admin.site.register(Task) 6 | -------------------------------------------------------------------------------- /CDF Hstogram Analysis in Python/Image4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/CDF Hstogram Analysis in Python/Image4.jpg -------------------------------------------------------------------------------- /addition.py: -------------------------------------------------------------------------------- 1 | 2 | a = int(input('Enter the value of a:')) 3 | b = int(input('Enter the value of b:'))3 4 | 5 | sum = a + b 6 | print('The required sum is ', sum) -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /Recursion/basic/Main.java: -------------------------------------------------------------------------------- 1 | package com.company; 2 | 3 | public class Main { 4 | 5 | public static void main(String[] args) { 6 | // write your code here 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/todo_list/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/todo_list/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/todo_list/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/todo_list/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /contributers.md: -------------------------------------------------------------------------------- 1 | 1. [Rochak Sedai](https://github.com/RochakSedai) 2 | 2. [Anup Kafle](https://github.com/anupkafle) 3 | 3. [Abhishek Mishra](https://github.com/abhishivam1) 4 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/todo_list/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/todo_list/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/todo_list/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/todo_list/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/baseApp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class BaseappConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'baseApp' 7 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /ToDo-List/baseApp/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abhishivam1/hack-this-october-fest2022/HEAD/ToDo-List/baseApp/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /Recursion/tree_algos/max_depth.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int maxDepth(TreeNode root) { 3 | if(root == null) return 0; 4 | 5 | int lh = maxDepth(root.left); 6 | int rh = maxDepth(root.right); 7 | 8 | return 1 + Math.max(lh, rh); 9 | } 10 | } -------------------------------------------------------------------------------- /Recursion/basic/print_number.java: -------------------------------------------------------------------------------- 1 | package com.company; 2 | public class print_number { 3 | public static void main(String[] args) { 4 | print(5); 5 | } 6 | 7 | static void print(int n) { 8 | if (n == 0){ 9 | return; 10 | } 11 | print(n-1); 12 | System.out.println(n); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Recursion/basic/sum_digits.java: -------------------------------------------------------------------------------- 1 | package com.company; 2 | public class sum_digits { 3 | public static void main(String[] args) { 4 | int answer = sum_digit(1342); 5 | System.out.println(answer); 6 | } 7 | 8 | static int sum_digit(int n) 9 | { 10 | if (n == 0) 11 | { 12 | return 0; 13 | } 14 | return n % 10 + sum_digit(n/10); //recursive caal 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /function_overloading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | inline void swap(int &, int &); 5 | int main() 6 | { 7 | int a=5,b=6; 8 | cout<< "Before swapping: a="<← Back 6 | 7 | 8 |
9 |
10 | {% csrf_token %} 11 | {{form.as_p}} 12 | 13 |
14 |
15 | 16 | 17 | {% endblock content %} 18 | 19 | -------------------------------------------------------------------------------- /palidrome.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char str[] = { "aabba" }; 7 | 8 | int l = 0; 9 | int h = strlen(str) - 1; 10 | 11 | while (h > l) { 12 | if (str[l++] != str[h--]) { 13 | printf("%s is not a palindrome\n", str); 14 | return 0; 15 | // will return from here 16 | } 17 | } 18 | 19 | printf("%s is a palindrome\n", str); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /temp.py: -------------------------------------------------------------------------------- 1 | celsius_1 = float(input("Temperature value in degree Celsius: " )) 2 | Fahrenheit_1 = (celsius_1 * 1.8) + 32 3 | print('The %.2f degree Celsius is equal to: %.2f Fahrenheit' 4 | %(celsius_1, Fahrenheit_1)) 5 | 6 | print("----OR----") 7 | celsius_2 = float (input("Temperature value in degree Celsius: " )) 8 | Fahrenheit_2 = (celsius_2 * 9/5) + 32 9 | print ('The %.2f degree Celsius is equal to: %.2f Fahrenheit' 10 | %(celsius_2, Fahrenheit_2)) -------------------------------------------------------------------------------- /ToDo-List/todo_list/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for todo_list project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_list.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /ToDo-List/todo_list/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for todo_list project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_list.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/task_delete.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | {% block content %} 3 | 4 |
5 | ← Go Back 6 |
7 | 8 |
9 |
10 | {% csrf_token %} 11 |

Are you sure you want to delete this task? {{task}}

12 | 13 |
14 |
15 | 16 | {% endblock content %} 17 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/loginpage.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | {% block content %} 3 | 4 |
5 |

Login

6 |
7 | 8 |
9 |
10 | {% csrf_token %} 11 | {{form.as_p}} 12 | 13 |
14 | 15 |

Don't have an account? Register

16 |
17 | 18 | {% endblock content %} 19 | -------------------------------------------------------------------------------- /Recursion/leetcode/make_it_zero.java: -------------------------------------------------------------------------------- 1 | package com.leetcode; 2 | 3 | public class make_it_zero { 4 | static int c = 0; 5 | public static void main(String[] args) { 6 | int n = 8; 7 | int answer = make_zero(n); 8 | System.out.println(answer); 9 | } 10 | static int make_zero(int n) { 11 | if ( n == 0){ 12 | return c; 13 | } 14 | if (n % 2 == 0){ 15 | ++c; 16 | return make_zero(n/2); 17 | } 18 | ++c; 19 | return make_zero(n-1); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Recursion/Array_recursion/sort.java: -------------------------------------------------------------------------------- 1 | package com.Array_recursion; 2 | 3 | public class sort { 4 | public static void main(String[] args) { 5 | int[] arr = {1,2,3,4,5}; 6 | boolean result = sort_array(arr); 7 | System.out.println(result); 8 | } 9 | static boolean sort_array(int[] arr) 10 | { 11 | return helper( arr, 0); 12 | } 13 | static boolean helper(int[] arr, int i){ 14 | if (arr[i] == arr[arr.length-1]) 15 | return true; 16 | return arr[i] < arr[i+1] && helper(arr, i+1); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Recursion/tree_algos/isbalanced.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean isBalanced(TreeNode root) { 3 | return dfsHeight (root) != -1; 4 | } 5 | int dfsHeight (TreeNode root) { 6 | if (root == null) return 0; 7 | 8 | int leftHeight = dfsHeight (root.left); 9 | if (leftHeight == -1) return -1; 10 | int rightHeight = dfsHeight (root.right); 11 | if (rightHeight == -1) return -1; 12 | 13 | if (Math.abs(leftHeight - rightHeight) > 1) return -1; 14 | return Math.max(leftHeight, rightHeight) + 1; 15 | } 16 | } -------------------------------------------------------------------------------- /ToDo-List/baseApp/models.py: -------------------------------------------------------------------------------- 1 | from email.policy import default 2 | from turtle import title 3 | from django.db import models 4 | from django.contrib.auth.models import User 5 | 6 | # Create your models here. 7 | 8 | class Task(models.Model): 9 | user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) 10 | title = models.CharField(max_length=50) 11 | description = models.TextField(null=True, blank=True) 12 | complete = models.BooleanField(default=False) 13 | created = models.DateTimeField(auto_now_add=True) 14 | 15 | def __str__(self): 16 | return self.title 17 | 18 | class Meta: 19 | ordering = ["complete"] -------------------------------------------------------------------------------- /merge.cpp: -------------------------------------------------------------------------------- 1 | class Solution 2 | { 3 | public: 4 | ListNode* merge(ListNode *list1, ListNode *list2) 5 | { 6 | if (list1 == NULL) return list2; 7 | if (list2 == NULL) return list1; 8 | if (list1->val < list2->val) 9 | { 10 | list1->next = merge(list1->next, list2); 11 | return list1; 12 | } 13 | else 14 | { 15 | list2->next = merge(list1, list2->next); 16 | return list2; 17 | } 18 | } 19 | ListNode* mergeTwoLists(ListNode *list1, ListNode *list2) 20 | { 21 | return merge(list1, list2); 22 | } 23 | }; -------------------------------------------------------------------------------- /Recursion/basic/binary_search.java: -------------------------------------------------------------------------------- 1 | package com.company; 2 | public class binary_search { 3 | public static void main(String[] args) { 4 | int[] arr = {1,2,3,4,78,90,100}; 5 | int target = 78; 6 | System.out.println(search(arr,target,0,arr.length-1)); 7 | } 8 | 9 | static int search(int[] arr, int target, int s, int e) 10 | { 11 | if (s > e){ 12 | return -1; 13 | } 14 | 15 | int m = s + (e-s) / 2; 16 | if (target == arr[m]) { 17 | return m; 18 | } 19 | if (target < arr[m]) 20 | { 21 | return search(arr,target,s,m-1); 22 | } 23 | return search(arr,target,m+1,e); 24 | } 25 | } -------------------------------------------------------------------------------- /intojpg.py: -------------------------------------------------------------------------------- 1 | import os 2 | from os import listdir 3 | from PIL import Image 4 | import requests 5 | import shutil 6 | 7 | # get the path/directory 8 | folder_dir = r"C:\Users\Dell\Downloads\sample" 9 | 10 | for images in os.listdir(folder_dir): 11 | 12 | filename = images 13 | 14 | # splitting the file name after the last '.' 15 | separator = '.' 16 | filename = filename.rsplit(separator, 1)[0] 17 | 18 | images = Image.open(fr'C:\Users\Dell\Downloads\sample\{images}') 19 | 20 | # conversion of other mode into RGB so that it can be converted into jpg 21 | images = images.convert('RGB') 22 | file_name = filename + '.jpg' 23 | conversion = images.save(file_name) 24 | -------------------------------------------------------------------------------- /Recursion/leetcode/count_opearation_zero.java: -------------------------------------------------------------------------------- 1 | package com.leetcode; 2 | import java.util.Scanner; 3 | public class count_opearation_zero { 4 | public static void main(String[] args) { 5 | Scanner in = new Scanner(System.in); 6 | int num1 = in.nextInt(); 7 | int num2 = in.nextInt(); 8 | 9 | int answer = count_zero(num1,num2); 10 | System.out.println(answer); 11 | } 12 | static int count_zero(int num1, int num2) 13 | { 14 | if (num1 == 0 || num2 == 0) 15 | return 0; 16 | else if ( num1 >= num2) 17 | num1 = num1 - num2; 18 | else 19 | num2 = num2 - num1; 20 | 21 | return 1 + count_zero(num1, num2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Recursion/sorting/bubble_sort.java: -------------------------------------------------------------------------------- 1 | package com.sorting; 2 | 3 | import java.util.Arrays; 4 | 5 | public class bubble_sort { 6 | public static void main(String[] args) { 7 | int[] arr = {4,3,2,1}; 8 | bsort(arr,arr.length-1,0); 9 | System.out.println(Arrays.toString(arr)); 10 | } 11 | 12 | static void bsort(int[] arr,int r,int c){ 13 | if (r == 0){ 14 | return; 15 | } 16 | if(r > c) 17 | { 18 | if (arr[c] > arr[c+1]){ 19 | int temp = arr[c+1]; 20 | arr[c+1] = arr[c]; 21 | arr[c] = temp; 22 | } 23 | bsort(arr,r,c+1); 24 | } 25 | bsort(arr,r-1,0); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/register.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | {% block content %} 3 | 4 |
5 |

Register

6 |
7 | 8 |
9 |
10 | {% csrf_token %} 11 | 12 | {{form.username}} 13 | 14 | {{form.password1}} 15 | 16 | {{form.password2}} 17 | 18 |
19 | 20 |

Already have an account? Login

21 |
22 | 23 | {% endblock content %} 24 | -------------------------------------------------------------------------------- /ToDo-List/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'todo_list.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /dda_algorithm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int abs (int n) 8 | { 9 | return ((n>0)? n: (n*(-1))); 10 | } 11 | 12 | void DDA(int x0, int y0, int x1, int y1) 13 | { 14 | int dx = x1-x0; 15 | int dy = y1-y0; 16 | 17 | int steps = abs(dx)>abs(dy)? abs(dx):abs(dy); 18 | 19 | float xinc = dx/steps; 20 | float yinc = dy/steps; 21 | 22 | for (int i=1; i<=steps;i++) 23 | { 24 | putpixel(x1,y1,RED); 25 | x1 += xinc; 26 | y1 += yinc; 27 | } 28 | } 29 | int main() 30 | { 31 | int gd = DETECT, gm; 32 | 33 | initgraph(&gd, &gm, ""); 34 | 35 | int x0=100 y0=100, x1=200, y1=200; 36 | DDA(x0,y0,x1,y1); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import CreateList, DetailList, TaskList, UpdateList, DeleteList, CustomLogin, RegisterPage 3 | from django.contrib.auth.views import LogoutView 4 | 5 | urlpatterns = [ 6 | path('login/', CustomLogin.as_view(), name="login"), 7 | path('logout/', LogoutView.as_view(next_page = 'login'), name="logout"), 8 | path('register/', RegisterPage.as_view(), name="register"), 9 | 10 | 11 | path('', TaskList.as_view(), name="tasks"), 12 | path('task/', DetailList.as_view(), name="detail"), 13 | path('create-list', CreateList.as_view(), name="create"), 14 | path('update/', UpdateList.as_view(), name="update"), 15 | path('delete/', DeleteList.as_view(), name="delete") 16 | 17 | 18 | 19 | ] -------------------------------------------------------------------------------- /ValidParentheses.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | 6 | bool isValid(string x) 7 | { 8 | stack st; 9 | for(int i=0;i 1 && target % 2 == 0 && maxDoubles > 0) 16 | return helper(target/2,maxDoubles-1,count +1); 17 | else if (target > 1 && maxDoubles > 0) 18 | return helper(target-1,maxDoubles,count+1); 19 | 20 | return count+target-1; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Recursion/sorting/selection_sort.java: -------------------------------------------------------------------------------- 1 | package com.sorting; 2 | 3 | import java.util.Arrays; 4 | 5 | public class selection_sort { 6 | public static void main(String[] args) { 7 | int[] arr = {4,3,2,1}; 8 | Ssort(arr,arr.length,0,0); 9 | System.out.println(Arrays.toString(arr)); 10 | } 11 | static void Ssort(int[] arr, int r, int c,int max){ 12 | if(r==0){ 13 | return; 14 | } 15 | if(r > c){ 16 | if(arr[c] > arr[max]) 17 | { 18 | Ssort(arr,r,c+1,c); 19 | } 20 | else{ 21 | Ssort(arr,r,c+1,max); 22 | } 23 | }else{ 24 | int temp = arr[max]; 25 | arr[max] = arr[r-1]; 26 | arr[r-1] = temp; 27 | 28 | Ssort(arr,r-1,0,0); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ToDo-List/todo_list/urls.py: -------------------------------------------------------------------------------- 1 | """todo_list URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('', include('baseApp.urls')) 22 | ] 23 | -------------------------------------------------------------------------------- /youtube_video_downloader_requirement.txt: -------------------------------------------------------------------------------- 1 | appdirs==1.4.4 2 | astroid==2.4.1 3 | autopep8==1.5.2 4 | backcall==0.1.0 5 | colorama==0.4.3 6 | cycler==0.10.0 7 | decorator==4.4.2 8 | distlib==0.3.0 9 | filelock==3.0.12 10 | ipykernel==5.3.0 11 | ipython==7.15.0 12 | ipython-genutils==0.2.0 13 | isort==4.3.21 14 | jedi==0.17.0 15 | jupyter-client==6.1.3 16 | jupyter-core==4.6.3 17 | kiwisolver==1.2.0 18 | lazy-object-proxy==1.4.3 19 | matplotlib==3.2.1 20 | mccabe==0.6.1 21 | mpld3==0.3 22 | numpy==1.18.4 23 | pandas==1.0.4 24 | parso==0.7.0 25 | pickleshare==0.7.5 26 | prompt-toolkit==3.0.5 27 | pycodestyle==2.6.0 28 | Pygments==2.6.1 29 | pylint==2.5.2 30 | pyparsing==2.4.7 31 | python-dateutil==2.8.1 32 | pytube==9.6.0 33 | pytz==2020.1 34 | pywin32==227 35 | pyzmq==19.0.1 36 | six==1.14.0 37 | toml==0.10.0 38 | tornado==6.0.4 39 | traitlets==4.3.3 40 | virtualenv==20.0.21 41 | wcwidth==0.2.2 42 | wrapt==1.12.1 43 | -------------------------------------------------------------------------------- /Recursion/patterns/one.java: -------------------------------------------------------------------------------- 1 | package com.patterns; 2 | 3 | public class one { 4 | public static void main(String[] args) { 5 | pattern2(5,0); 6 | } 7 | static void pattern1(int row,int col){ 8 | if (row == 0){ 9 | return; 10 | } 11 | if (col < row ) 12 | { 13 | System.out.print('*'); 14 | pattern1(row,col+1); 15 | } 16 | else 17 | { 18 | System.out.println(); 19 | pattern1(row-1,0); 20 | } 21 | } 22 | 23 | static void pattern2(int row,int col){ 24 | if (row == 0){ 25 | return; 26 | } 27 | if (col < row ) 28 | { 29 | pattern2(row,col+1); 30 | System.out.print('*'); 31 | } 32 | else 33 | { 34 | pattern2(row-1,0); 35 | System.out.println(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Recursion/Array_recursion/RBS.java: -------------------------------------------------------------------------------- 1 | package com.Array_recursion; 2 | 3 | public class RBS { 4 | public static void main(String[] args) { 5 | int[] arr = {5,6,1,2,3,4}; 6 | int target = 6; 7 | System.out.println(search(arr,target,0,arr.length-1)); 8 | } 9 | static int search(int[] arr,int target, int s,int e) 10 | { 11 | if( s > e ){ 12 | return -1; 13 | } 14 | int m = s + (e-s) / 2; 15 | 16 | if( arr[m] == target ){ 17 | return m; 18 | } 19 | 20 | if(arr[s] <= arr[m]) 21 | { 22 | if (target >= arr[s] && target <= arr[m]) 23 | return search(arr,target,s,m-1); 24 | else 25 | return search(arr,target,m+1,e); 26 | } 27 | 28 | if(target >= arr[m] && target <= arr[e]) 29 | { 30 | return search(arr,target,m+1,e); 31 | } 32 | return search(arr,target,s,m-1); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Recursion/Array_recursion/linear_search.java: -------------------------------------------------------------------------------- 1 | 2 | package com.Array_recursion; 3 | 4 | import java.util.ArrayList; 5 | 6 | public class linear_search { 7 | public static void main(String[] args) { 8 | int[] arr = {1,2,3,4,4,5,6}; 9 | int target = 4; 10 | // boolean result = search(arr,target,0); 11 | System.out.println(findallIndex(arr,target,0)); 12 | } 13 | 14 | static ArrayList findallIndex(int[] arr, int target, int i) { 15 | ArrayList list = new ArrayList<>(); 16 | if(i == arr.length) 17 | return list; 18 | if(arr[i] == target) 19 | list.add(i); 20 | 21 | ArrayList ansFromBelowCalls = findallIndex(arr, target, i+1); 22 | list.addAll(ansFromBelowCalls); 23 | return list; 24 | } 25 | 26 | static boolean search(int[] arr,int target,int i) 27 | { 28 | if (i == arr.length) { 29 | return false; 30 | } 31 | return (arr[i] == target) || search(arr,target,i+1); 32 | 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /0-1 Knapsack.cpp: -------------------------------------------------------------------------------- 1 | // A dynamic programming based 2 | // solution for 0-1 Knapsack problem 3 | #include 4 | using namespace std; 5 | 6 | // A utility function that returns 7 | // maximum of two integers 8 | int max(int a, int b) 9 | { 10 | return (a > b) ? a : b; 11 | } 12 | 13 | // Returns the maximum value that 14 | // can be put in a knapsack of capacity W 15 | int knapSack(int W, int wt[], int val[], int n) 16 | { 17 | int i, w; 18 | vector> K(n + 1, vector(W + 1)); 19 | 20 | // Build table K[][] in bottom up manner 21 | for(i = 0; i <= n; i++) 22 | { 23 | for(w = 0; w <= W; w++) 24 | { 25 | if (i == 0 || w == 0) 26 | K[i][w] = 0; 27 | else if (wt[i - 1] <= w) 28 | K[i][w] = max(val[i - 1] + 29 | K[i - 1][w - wt[i - 1]], 30 | K[i - 1][w]); 31 | else 32 | K[i][w] = K[i - 1][w]; 33 | } 34 | } 35 | return K[n][W]; 36 | } 37 | 38 | // Driver Code 39 | int main() 40 | { 41 | int val[] = { 60, 100, 120 }; 42 | int wt[] = { 10, 20, 30 }; 43 | int W = 50; 44 | int n = sizeof(val) / sizeof(val[0]); 45 | 46 | cout << knapSack(W, wt, val, n); 47 | 48 | return 0; 49 | } 50 | 51 | // This code is contributed by Debojyoti Mandal 52 | -------------------------------------------------------------------------------- /ToDo-List/baseApp/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 4.1.2 on 2022-10-10 16:06 2 | 3 | from django.conf import settings 4 | from django.db import migrations, models 5 | import django.db.models.deletion 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | migrations.swappable_dependency(settings.AUTH_USER_MODEL), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='Task', 19 | fields=[ 20 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('title', models.CharField(max_length=50)), 22 | ('description', models.TextField(blank=True, null=True)), 23 | ('complete', models.BooleanField(default=False)), 24 | ('created', models.DateTimeField(auto_now_add=True)), 25 | ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 26 | ], 27 | options={ 28 | 'ordering': ['complete'], 29 | }, 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /Recursion/sorting/MergeInPlaceSort.java: -------------------------------------------------------------------------------- 1 | package com.sorting; 2 | 3 | import java.util.Arrays; 4 | 5 | public class MergeInPlaceSort { 6 | public static void main(String[] args) { 7 | int[] arr = {5,4,3,2,1}; 8 | mergeInplace(arr,0,arr.length); 9 | System.out.println(Arrays.toString(arr)); 10 | } 11 | static void mergeInplace(int[] arr, int s, int e ){ 12 | 13 | if( e-s == 1){ 14 | return; 15 | } 16 | int m = ( e+s ) / 2; 17 | 18 | mergeInplace(arr,s,m); 19 | mergeInplace(arr,m,e); 20 | 21 | merge(arr,s,m,e); 22 | } 23 | 24 | static void merge(int[] arr,int s, int m, int e){ 25 | int[] mix = new int[e-s]; 26 | 27 | int i = s; 28 | int j = m; 29 | int k = 0; 30 | 31 | while ( i < m && j < e){ 32 | 33 | if( arr[i] < arr[j]){ 34 | mix[k] = arr[i]; 35 | i++; 36 | }else{ 37 | mix[k] = arr[j]; 38 | j++; 39 | } 40 | k++; 41 | } 42 | 43 | while (i < m){ 44 | mix[k] = arr[i]; 45 | i++; 46 | k++; 47 | } 48 | 49 | while (j < e){ 50 | mix[k] = arr[j]; 51 | j++; 52 | k++; 53 | } 54 | 55 | for (int l = 0; l < mix.length; l++) { 56 | arr[s + l] = mix[l]; 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /SimpleCalculator.py: -------------------------------------------------------------------------------- 1 | #solving the issue and added an exponent function which you can use 2 | 3 | def add(a, z): 4 | return a + z 5 | 6 | def subtract(a, z): 7 | return a - z 8 | 9 | def multiply(a, z): 10 | return a * z 11 | 12 | def divide(a, z): 13 | return a / z 14 | 15 | def exponent(a, z): 16 | return a ** z 17 | 18 | print("Exponent Function added by Abhishek") 19 | 20 | print("Select operation.") 21 | print("1.Addition") 22 | print("2.Subtraction") 23 | print("3.Multiplication") 24 | print("4.Division") 25 | print("5.Exponentiation") 26 | 27 | while True: 28 | choice = input("Enter choice(1/2/3/4/5): ") 29 | 30 | if choice in ('1', '2', '3', '4', '5'): 31 | numb1 = float(input("Enter first number: ")) 32 | numb2 = float(input("Enter second number: ")) 33 | 34 | if choice == '1': 35 | print(numb1, "+", numb2, "=", add(numb1, numb2)) 36 | elif choice == '2': 37 | print(numb1, "-", numb2, "=", subtract(numb1, numb2)) 38 | elif choice == '3': 39 | print(numb1, "*", numb2, "=", multiply(numb1, numb2)) 40 | elif choice == '4': 41 | if numb2 == 0: 42 | print("Division by zero is not allowed.") 43 | else: 44 | print(numb1, "/", numb2, "=", divide(numb1, numb2)) 45 | elif choice == '5': 46 | print(numb1, "**", numb2, "=", exponent(numb1, numb2)) 47 | break 48 | else: 49 | print("Invalid Input") 50 | -------------------------------------------------------------------------------- /guessthenumber.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | import java.util.Scanner; 3 | 4 | public class GuessTheNumber { 5 | public static void main(String[] args) { 6 | Scanner scanner = new Scanner(System.in); 7 | Random random = new Random(); 8 | 9 | int lowerBound = 1; 10 | int upperBound = 100; 11 | int numberToGuess = random.nextInt(upperBound - lowerBound + 1) + lowerBound; 12 | 13 | int numberOfTries = 0; 14 | boolean hasGuessedCorrectly = false; 15 | 16 | System.out.println("Guess the Number Game -- Made by Abhishek Mishra!"); 17 | System.out.println("I have selected a number between " + lowerBound + " and " + upperBound + ". Try to guess it."); 18 | 19 | while (!hasGuessedCorrectly) { 20 | System.out.print("Enter your guess: "); 21 | int userGuess = scanner.nextInt(); 22 | numberOfTries++; 23 | 24 | if (userGuess < lowerBound || userGuess > upperBound) { 25 | System.out.println("Please guess within the specified range."); 26 | } else if (userGuess < numberToGuess) { 27 | System.out.println("Too low! Try again."); 28 | } else if (userGuess > numberToGuess) { 29 | System.out.println("Too high! Try again."); 30 | } else { 31 | hasGuessedCorrectly = true; 32 | System.out.println("Congratulations! You guessed the number in " + numberOfTries + " tries."); 33 | } 34 | } 35 | 36 | scanner.close(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Recursion/sorting/MergeSort.java: -------------------------------------------------------------------------------- 1 | package com.sorting; 2 | 3 | import java.util.Arrays; 4 | 5 | public class MergeSort { 6 | public static void main(String[] args) { 7 | int[] arr = {5,4,3,2,1}; 8 | int[] result = mergeSort(arr); 9 | System.out.println(Arrays.toString(result)); 10 | } 11 | 12 | static int[] mergeSort( int[] arr ){ 13 | if(arr.length == 1){ 14 | return arr; 15 | } 16 | 17 | int mid = arr.length / 2; 18 | 19 | int[] left = mergeSort(Arrays.copyOfRange(arr,0,mid)); 20 | int[] right = mergeSort(Arrays.copyOfRange(arr,mid,arr.length)); 21 | 22 | return merge(left,right); 23 | } 24 | 25 | static int[] merge(int[] first, int[] second){ 26 | 27 | int[] mix = new int[first.length + second.length]; 28 | 29 | int i=0; 30 | int j=0; 31 | int k=0; 32 | 33 | while(i < first.length && j < second.length){ 34 | if(first[i] < second[j]){ 35 | mix[k] = first[i]; 36 | i++; 37 | }else{ 38 | mix[k] = second[j]; 39 | j++; 40 | } 41 | k++; 42 | } 43 | 44 | //it may be possible that one of the array is incomplete 45 | //copy the remaining elements 46 | while(i < first.length){ 47 | mix[k] = first[i]; 48 | i++; 49 | k++; 50 | } 51 | 52 | while(j < second.length){ 53 | mix[k] = first[j]; 54 | j++; 55 | k++; 56 | } 57 | 58 | return mix; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /imagetransfer.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys,time 3 | import socket 4 | 5 | server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 6 | server_socket.bind(("", 5005)) 7 | server_socket.listen(5) 8 | 9 | client_socket, address = server_socket.accept() 10 | print "Conencted to - ",address,"\n" 11 | 12 | sb = '/mnt/sdcard/sb' 13 | 14 | while True: 15 | files = os.listdir(sb) 16 | pages = 0; 17 | while (files): 18 | print '\nMaybe, pending work' 19 | for au in files: 20 | if (au.find('d')>-1): # searching for folder with a d 21 | os.chdir(sb+'/'+au) 22 | imgFiles = os.listdir(sb+'/'+au) 23 | images = [img for img in imgFiles if img.endswith('.jpg')] 24 | print '\n%s user done' %au 25 | client_socket.send(au) 26 | pages = 0; 27 | #copies all .img files in the folder from server to client 28 | for imgs in images: 29 | print imgs 30 | client_socket.send(imgs) 31 | file_name = open(imgs,'r') 32 | while True: 33 | strng = file_name.readline(1024) 34 | if not strng: 35 | break 36 | client_socket.send(strng) 37 | file_name.close() 38 | print "Data sent successfully" 39 | os.remove(sb+'/'+au+'/'+imgs) 40 | pages = pages + 1 41 | 42 | time.sleep(1) 43 | os.chdir(sb) 44 | os.rmdir(au) 45 | 46 | else: 47 | time.sleep(2) 48 | exit() 49 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/task_list.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | {% block content %} 3 | 4 |
5 |
6 |

Hello {{request.user|title}}

7 |

You have {{count}} incomplete task{{ count|pluralize:"s"}}

8 |
9 | {% if request.user.is_authenticated %} 10 | Logout 11 | {% else %} 12 | Login 13 | {% endif %} 14 |
15 | 16 |
17 |
18 | 19 | 20 |
21 | + 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | {% for task in tasks %} 31 |
32 | {% if task.complete %} 33 |
34 |
35 | {{task}} 36 |
37 | × 38 | {% else %} 39 |
40 |
41 | {{task}} 42 |
43 | × 44 | {% endif %} 45 | 46 |
47 | {% empty %} 48 |

No itmes in a list

49 | {% endfor %} 50 |
51 | {% endblock %} -------------------------------------------------------------------------------- /CDF Hstogram Analysis in Python/Maths for Machine Learning Project: -------------------------------------------------------------------------------- 1 | from google.colab import files 2 | uploaded = files.upload() 3 | 4 | img = cv2.imread("Image4.jpg") 5 | cv2_imshow(img) 6 | cv2.waitKey(0) 7 | 8 | """Storing the image as an array and finally loading the image""" 9 | 10 | type(img) 11 | 12 | cv2_imshow(img) 13 | 14 | """Defining the CDF, Histogram in one plot""" 15 | 16 | hist,bins = np.histogram(img.flatten(),256,[0,256]) 17 | cdf = hist.cumsum() 18 | cdf_normalized = cdf * float(hist.max()) / cdf.max() 19 | plt.plot(cdf_normalized, color = 'b') 20 | plt.hist(img.flatten(),256,[0,256], color = 'g') 21 | plt.xlim([0,256]) 22 | plt.legend(('cdf','histogram'), loc = 'upper left') 23 | plt.show() 24 | 25 | def histeq(im, nbr_bins = 256): 26 | """ Histogram equalization of image. """ 27 | # get the image histogram 28 | imhist, bins = np.histogram(im.flatten(), nbr_bins, [0, 256]) 29 | cdf = imhist.cumsum() # cumulative distribution function 30 | cdf = imhist.max()*cdf/cdf.max() #normalize 31 | cdf_mask = np.ma.masked_equal(cdf, 0) 32 | cdf_mask = (cdf_mask - cdf_mask.min())*255/(cdf_mask.max()-cdf_mask.min()) 33 | cdf = np.ma.filled(cdf_mask,0).astype('uint8') 34 | return cdf[im.astype('uint8')] 35 | 36 | #Storing new equalized image as image_1: 37 | image_1=histeq(img) 38 | 39 | cv2_imshow(image_1) 40 | 41 | vis = np.concatenate((img, image_1), axis=1) 42 | cv2_imshow(vis) 43 | 44 | bins_edges_min_max = [0, 256] 45 | num_bins = 256 46 | bin_count, bins_edges = np.histogram(image_1, num_bins, bins_edges_min_max) 47 | bins_start = bins_edges[:-1] 48 | 49 | pdf = bin_count / np.sum(bin_count) 50 | cdf = np.cumsum(pdf) 51 | 52 | plt.hist(image_1.ravel(),bins = 256, range = [0, 256]) 53 | plt.show() 54 | 55 | def histeq(image_1, nbr_bins = 256): 56 | imhist, bins = np.histogram(im.flatten(), nbr_bins, [0, 256]) 57 | cdf = hist.cumsum() 58 | cdf_normalized = cdf * float(hist.max()) / cdf.max() 59 | plt.plot(cdf_normalized, color = 'b') 60 | plt.hist(image_1.flatten(),256,[0,256], color = 'g') 61 | plt.xlim([0,256]) 62 | plt.legend(('cdf','histogram'), loc = 'upper left') 63 | plt.show() 64 | -------------------------------------------------------------------------------- /Largest Rectangle in histogram.cpp: -------------------------------------------------------------------------------- 1 | // C++ program to find maximum rectangular area in 2 | // linear time 3 | #include 4 | using namespace std; 5 | 6 | // The main function to find the maximum rectangular 7 | // area under given histogram with n bars 8 | int getMaxArea(int hist[], int n) 9 | { 10 | // Create an empty stack. The stack holds indexes 11 | // of hist[] array. The bars stored in stack are 12 | // always in increasing order of their heights. 13 | stack s; 14 | 15 | int max_area = 0; // Initialize max area 16 | int tp; // To store top of stack 17 | int area_with_top; // To store area with top bar 18 | // as the smallest bar 19 | 20 | // Run through all bars of given histogram 21 | int i = 0; 22 | while (i < n) { 23 | // If this bar is higher than the bar on top 24 | // stack, push it to stack 25 | if (s.empty() || hist[s.top()] <= hist[i]) 26 | s.push(i++); 27 | 28 | // If this bar is lower than top of stack, 29 | // then calculate area of rectangle with stack 30 | // top as the smallest (or minimum height) bar. 31 | // 'i' is 'right index' for the top and element 32 | // before top in stack is 'left index' 33 | else { 34 | tp = s.top(); // store the top index 35 | s.pop(); // pop the top 36 | 37 | // Calculate the area with hist[tp] stack 38 | // as smallest bar 39 | area_with_top 40 | = hist[tp] 41 | * (s.empty() ? i : i - s.top() - 1); 42 | 43 | // update max area, if needed 44 | if (max_area < area_with_top) 45 | max_area = area_with_top; 46 | } 47 | } 48 | 49 | // Now pop the remaining bars from stack and calculate 50 | // area with every popped bar as the smallest bar 51 | while (s.empty() == false) { 52 | tp = s.top(); 53 | s.pop(); 54 | area_with_top 55 | = hist[tp] * (s.empty() ? i : i - s.top() - 1); 56 | 57 | if (max_area < area_with_top) 58 | max_area = area_with_top; 59 | } 60 | 61 | return max_area; 62 | } 63 | 64 | // Driver code 65 | int main() 66 | { 67 | int hist[] = { 6, 2, 5, 4, 5, 1, 6 }; 68 | int n = sizeof(hist) / sizeof(hist[0]); 69 | 70 | // Function call 71 | cout << "Maximum area is " << getMaxArea(hist, n); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /Book_allocation.java: -------------------------------------------------------------------------------- 1 | //Problem : https://www.geeksforgeeks.org/allocate-minimum-number-pages/ 2 | 3 | // Java program for optimal allocation of pages 4 | 5 | public class Book_allocation { 6 | // Utility method to check if current minimum value 7 | // is feasible or not. 8 | static boolean isPossible(int arr[], int n, int m, 9 | int curr_min) 10 | { 11 | int studentsRequired = 1; 12 | int curr_sum = 0; 13 | 14 | // iterate over all books 15 | for (int i = 0; i < n; i++) { 16 | curr_sum += arr[i]; 17 | if (curr_sum > curr_min) { 18 | studentsRequired++; // increment student 19 | // count 20 | 21 | curr_sum = arr[i]; // update curr_sum 22 | } 23 | } 24 | 25 | return studentsRequired <= m; 26 | } 27 | 28 | // method to find minimum pages 29 | static int findPages(int arr[], int n, int m) 30 | { 31 | int sum = 0; 32 | 33 | // return -1 if no. of books is less than 34 | // no. of students 35 | if (n < m) 36 | return -1; 37 | 38 | // Count total number of pages 39 | for (int i = 0; i < n; i++) 40 | sum += arr[i]; 41 | 42 | // initialize start as arr[n-1] pages(minimum answer 43 | // possible) and end as total pages(maximum answer 44 | // possible) 45 | int start = arr[n - 1], end = sum; 46 | int result = Integer.MAX_VALUE; 47 | 48 | // traverse until start <= end 49 | while (start <= end) { 50 | // check if it is possible to distribute 51 | // books by using mid is current minimum 52 | int mid = start + (end - start) / 2; 53 | if (isPossible(arr, n, m, mid)) { 54 | // update result to current distribution 55 | // as it's the best we have found till now. 56 | result = mid; 57 | 58 | // as we are finding minimum so, 59 | end = mid - 1; 60 | } 61 | 62 | else 63 | // if not possible, means pages should be 64 | // increased ,so update start = mid + 1 65 | start = mid + 1; 66 | } 67 | 68 | // at-last return minimum no. of pages 69 | return result; 70 | } 71 | 72 | // Driver Method 73 | public static void main(String[] args) 74 | { 75 | 76 | int arr[] = { 12, 34, 67, 77 | 90 }; // Number of pages in books 78 | 79 | int m = 2; // No. of students 80 | 81 | System.out.println("Minimum number of pages = " 82 | + findPages(arr, arr.length, m)); 83 | } 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Z-algorithm.cpp: -------------------------------------------------------------------------------- 1 | // A C++ program that implements Z algorithm for pattern searching 2 | #include 3 | using namespace std; 4 | 5 | void getZarr(string str, int Z[]); 6 | 7 | // prints all occurrences of pattern in text using Z algo 8 | void search(string text, string pattern) 9 | { 10 | // Create concatenated string "P$T" 11 | string concat = pattern + "$" + text; 12 | int l = concat.length(); 13 | 14 | // Construct Z array 15 | int Z[l]; 16 | getZarr(concat, Z); 17 | 18 | // now looping through Z array for matching condition 19 | for (int i = 0; i < l; ++i) 20 | { 21 | // if Z[i] (matched region) is equal to pattern 22 | // length we got the pattern 23 | if (Z[i] == pattern.length()) 24 | cout << "Pattern found at index " 25 | << i - pattern.length() -1 << endl; 26 | } 27 | } 28 | 29 | // Fills Z array for given string str[] 30 | void getZarr(string str, int Z[]) 31 | { 32 | int n = str.length(); 33 | int L, R, k; 34 | 35 | // [L,R] make a window which matches with prefix of s 36 | L = R = 0; 37 | for (int i = 1; i < n; ++i) 38 | { 39 | // if i>R nothing matches so we will calculate. 40 | // Z[i] using naive way. 41 | if (i > R) 42 | { 43 | L = R = i; 44 | 45 | // R-L = 0 in starting, so it will start 46 | // checking from 0'th index. For example, 47 | // for "ababab" and i = 1, the value of R 48 | // remains 0 and Z[i] becomes 0. For string 49 | // "aaaaaa" and i = 1, Z[i] and R become 5 50 | while (R0): 76 | result = k + tri_recursion(k-1) 77 | print(result) 78 | else: 79 | result = 0 80 | return result 81 | 82 | print("\n\n Recursion Example results") 83 | tri_recursion(6) 84 | 85 | def factorial(k): 86 | if(k == 0): 87 | return 1 88 | elif(k == 1): 89 | return 1 90 | else: 91 | return k * factorial(k-1) 92 | 93 | print(factorial(8)) 94 | 95 | def lambda_prac(n): 96 | return lambda a: a + n 97 | 98 | mine_double = lambda_prac(3) 99 | print(mine_double(2)) -------------------------------------------------------------------------------- /ToDo-List/baseApp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from django.views.generic.list import ListView 3 | from django.views.generic.detail import DetailView 4 | from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView 5 | from django.urls import reverse_lazy 6 | 7 | from django.contrib.auth.views import LoginView 8 | from django.contrib.auth.mixins import LoginRequiredMixin 9 | from django.contrib.auth.forms import UserCreationForm 10 | from django.contrib.auth import login 11 | 12 | 13 | 14 | from .models import Task 15 | 16 | #login Page 17 | class CustomLogin(LoginView): 18 | template_name = 'base/loginpage.html' 19 | fields = '__all__' 20 | redirect_authenticated_user: True 21 | 22 | def get_success_url(self): 23 | return reverse_lazy('tasks') 24 | 25 | 26 | #Register Page 27 | class RegisterPage(FormView): 28 | template_name = 'base/register.html' 29 | form_class = UserCreationForm 30 | redirect_authenticated_user: True 31 | success_url = reverse_lazy('tasks') 32 | 33 | def form_valid(self, form): 34 | user = form.save() 35 | if user is not None: 36 | login(self.request, user) 37 | return super(RegisterPage, self).form_valid(form) 38 | 39 | #authentication user not allowd to register again 40 | def get(self, *args, **kwargs): 41 | if self.request.user.is_authenticated: 42 | return redirect('tasks') 43 | return super(RegisterPage, self).get(*args, **kwargs) 44 | 45 | 46 | #Show Tasks 47 | class TaskList(LoginRequiredMixin, ListView): 48 | model = Task 49 | template_name = 'base/task_list.html' 50 | context_object_name = 'tasks' 51 | 52 | #User Specific Data 53 | def get_context_data(self, **kwargs): 54 | context = super().get_context_data(**kwargs) 55 | context['tasks'] = context['tasks'].filter(user=self.request.user) 56 | context['count'] = context['tasks'].filter(complete=False).count() 57 | 58 | #search 59 | search_input = self.request.GET.get('search_area') or '' 60 | if search_input: 61 | context['tasks'] = context['tasks'].filter(title__startswith = search_input) 62 | 63 | context['search_input'] = search_input 64 | 65 | return context 66 | 67 | #Give Detail about existing task 68 | class DetailList(LoginRequiredMixin, DetailView): 69 | model = Task 70 | template_name = 'base/task_detail.html' 71 | context_object_name = 'tasks' 72 | 73 | #Create new task 74 | class CreateList(LoginRequiredMixin, CreateView): 75 | model = Task 76 | fields = ['title', 'description', 'complete'] 77 | template_name = 'base/task_create.html' 78 | success_url = reverse_lazy('tasks') 79 | 80 | #Automatically know th current user that login 81 | def form_valid(self, form): 82 | form.instance.user = self.request.user 83 | return super(CreateList, self).form_valid(form) 84 | 85 | #Update an existing task 86 | class UpdateList(LoginRequiredMixin, UpdateView): 87 | model = Task 88 | fields = ['title', 'description', 'complete'] 89 | template_name = 'base/task_create.html' 90 | success_url = reverse_lazy('tasks') 91 | 92 | #Delete an existing task 93 | class DeleteList(LoginRequiredMixin, DeleteView): 94 | model = Task 95 | context_object_name = 'task' 96 | template_name = 'base/task_delete.html' 97 | success_url = reverse_lazy('tasks') -------------------------------------------------------------------------------- /youtube_video_downloader.py: -------------------------------------------------------------------------------- 1 | import tkinter as tk 2 | import pytube 3 | from tkinter import * 4 | from tkinter import messagebox 5 | import tkinter.font as tkFont 6 | from pytube import YouTube 7 | import os 8 | from os import path 9 | 10 | root=tk.Tk() 11 | root.geometry('950x660') 12 | root.title("YoutubeVideoDownloader") 13 | root.config(bg="#B6A19E") 14 | root.resizable(0,0) 15 | 16 | def mainf(): 17 | def sub(videos): 18 | try: 19 | n=int(user.get()) 20 | destination=str(users.get()) 21 | if path.exists(destination)==True: 22 | vid=videos[n-1] 23 | vid.download(destination) 24 | fontstyle=tkFont.Font(size=10,underline=True) 25 | messagebox.showinfo("Downloaded","The video has been downloaded!!") 26 | else: 27 | messagebox.showerror("Error!","Enter valid directory") 28 | except: 29 | messagebox.showerror("Error","INVALID INPUT\nPlease enter proper number/destination.\n or check your internet connection") 30 | global u 31 | try: 32 | frame=Frame(root) 33 | scroll=Scrollbar(frame) 34 | listbox=Listbox(frame,yscrollcommand=scroll.set,bd=3,height=8,width=140,bg="cornsilk2") 35 | url=u.get() 36 | y=YouTube(url) 37 | videos=y.streams.filter(progressive=True).all() 38 | fontstyle1=tkFont.Font(size=13,family="Arial Black") 39 | video=tk.Label(root,text="Videos:",font=fontstyle1,bd=0,fg="#1D2951",bg="#B6A19E") 40 | video.pack() 41 | fontstyle=tkFont.Font(size=12,underline=True,family="Arial Black") 42 | title=tk.Label(root,text=y.title,font=fontstyle,bd=0,fg="#1D2951",bg="#B6A19E") 43 | title.pack(pady=8) 44 | s=1 45 | for v in videos: 46 | listbox.insert(END,"\n") 47 | listbox.insert(END," "+str(s)+". "+str(v)) 48 | s+=1 49 | frame.pack() 50 | scroll.pack(side=RIGHT,fill=Y) 51 | scroll.config(command=listbox.yview) 52 | listbox.pack() 53 | 54 | fontstyle=tkFont.Font(size=11,underline=True) 55 | choice=tk.Label(root,text="Enter your choice from above numbers: ",font=fontstyle,bg="#B6A19E") 56 | choice.pack(padx=5,side=tk.LEFT) 57 | user=tk.Entry(root,width=4,bd=3) 58 | user.pack(padx=0,side=tk.LEFT) 59 | 60 | fontstyle=tkFont.Font(size=11,underline=True) 61 | choice=tk.Label(root,text='Enter destination(ex:"C:\\Users\\Public\\Downloads"):',font=fontstyle,bg="#B6A19E") 62 | choice.pack(padx=8,side=tk.LEFT) 63 | users=tk.Entry(root,width=30,bd=3) 64 | users.pack(padx=0,side=tk.LEFT) 65 | 66 | fontstyle=tkFont.Font(size=12) 67 | submit=tk.Button(root,text="Submit",fg="black",bg="bisque",font=fontstyle,command=lambda:sub(videos)) 68 | submit.pack(padx=10,side=tk.LEFT) 69 | 70 | e=tk.Label(root,text="\n",bg="#B6A19E") 71 | e.pack() 72 | except: 73 | messagebox.showerror("Error","INVALID INPUT\nPlease enter proper url\n(This video is not available for downloading).") 74 | fontstyle=tkFont.Font(size=30,family="Arial Black") 75 | t=tk.Label(root,text="YoutubeVideoDownloader",font=fontstyle,bg="#B6A19E") 76 | t.pack(pady=20) 77 | 78 | fontstyle=tkFont.Font(size=13) 79 | r=tk.Label(root,text="Paste url here:",font=fontstyle,bg="#B6A19E") 80 | r.pack() 81 | 82 | u=tk.Entry(root,width=50,bd=4) 83 | u.pack(side=tk.TOP,pady=8) 84 | 85 | fontstyle1=tkFont.Font(size=16,family="Times New Roman") 86 | button=tk.Button(root,text="Download",fg="white",bg="#192841",font=fontstyle1,command=mainf) 87 | button.pack(pady=10) 88 | 89 | root.mainloop() 90 | -------------------------------------------------------------------------------- /asteroid game.py: -------------------------------------------------------------------------------- 1 | a#!/usr/bin/env python 2 | import pyglet 3 | import random 4 | 5 | pyglet.resource.path = ["resources"] 6 | pyglet.resource.reindex() 7 | 8 | class AsteroidsWindow(pyglet.window.Window): 9 | def __init__(self): 10 | super(AsteroidsWindow, self).__init__() 11 | 12 | #Set key handler. 13 | self.keys = pyglet.window.key.KeyStateHandler() 14 | self.push_handlers(self.keys) 15 | 16 | self.set_caption("Asteroid Racer") 17 | 18 | self.ship_image = pyglet.resource.image("alienblaster.png") 19 | self.asteroid_image = pyglet.resource.image("asteroid.png") 20 | 21 | self.center_image(self.ship_image) 22 | self.center_image(self.asteroid_image) 23 | 24 | self.explosion_sound = pyglet.resource.media("bigbomb.wav", streaming=False) 25 | self.background_music = pyglet.resource.media("cyber-soldier.wav", streaming=False) 26 | 27 | self.ship = pyglet.sprite.Sprite(img=self.ship_image, x=30, y=30) 28 | self.ship.scale = 0.3 29 | self.ship.rotation = 180 30 | 31 | self.score_label = pyglet.text.Label(text="Score:0 Highscore:0", x=10, y=10) 32 | self.score = 0 33 | self.highscore = 0 34 | 35 | self.asteroids = [] 36 | self.stars = [] 37 | 38 | pyglet.clock.schedule_interval(self.game_tick, 0.005) 39 | self.background_music.play() 40 | pyglet.clock.schedule_interval(lambda x: self.background_music.play(), 13.8) 41 | 42 | def game_tick(self, dt): 43 | self.update_stars() 44 | self.update_asteroids() 45 | self.update_ship() 46 | self.update_score() 47 | self.draw_elements() 48 | 49 | def draw_elements(self): 50 | self.clear() 51 | for star in self.stars: 52 | star.draw() 53 | for asteroid in self.asteroids: 54 | asteroid.draw() 55 | self.ship.draw() 56 | self.score_label.draw() 57 | 58 | def update_stars(self): 59 | if self.score % 8 == 0: 60 | self.stars.append(pyglet.text.Label(text="*", x=random.randint(0, 800), y=600)) 61 | for star in self.stars: 62 | star.y -= 20 63 | if star.y < 0: 64 | self.stars.remove(star) 65 | 66 | def update_asteroids(self): 67 | if random.randint(0, 45) == 3: 68 | ast = pyglet.sprite.Sprite(img=self.asteroid_image, x=random.randint(0, 800), y=600) 69 | ast.scale = 0.3 70 | self.asteroids.append(ast) 71 | for asteroid in self.asteroids: 72 | asteroid.y -= 7 73 | if asteroid.y < 0: 74 | self.asteroids.remove(asteroid) 75 | for asteroid in self.asteroids: 76 | if self.sprites_collide(asteroid, self.ship): 77 | self.asteroids.remove(asteroid) 78 | self.score = 0 79 | self.explosion_sound.play() 80 | 81 | def update_ship(self): 82 | if self.keys[pyglet.window.key.LEFT] and not self.ship.x < 0: 83 | self.ship.x -= 4 84 | elif self.keys[pyglet.window.key.RIGHT] and not self.ship.x > 625: 85 | self.ship.x += 4 86 | #brought to you by code-projects.org 87 | def update_score(self): 88 | self.score += 1 89 | if self.score > self.highscore: 90 | self.highscore = self.score 91 | self.score_label.text = "Score: %s Highscore: %s" % (self.score, self.highscore) 92 | 93 | def center_image(self, image): 94 | image.anchor_x = image.width/2 95 | image.anchor_y = image.height/2 96 | 97 | def sprites_collide(self, spr1, spr2): 98 | return (spr1.x-spr2.x)**2 + (spr1.y-spr2.y)**2 < (spr1.width/2 + spr2.width/2)**2 99 | 100 | game_window = AsteroidsWindow() 101 | pyglet.app.run() 102 | -------------------------------------------------------------------------------- /ToDo-List/todo_list/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for todo_list project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.0.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.0/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'django-insecure-6)6+=qcqcyi6###bc4a4vytiu&0**yiszg29xf&@d260np!%#0' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = True 27 | 28 | ALLOWED_HOSTS = [] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'baseApp' 41 | ] 42 | 43 | MIDDLEWARE = [ 44 | 'django.middleware.security.SecurityMiddleware', 45 | 'django.contrib.sessions.middleware.SessionMiddleware', 46 | 'django.middleware.common.CommonMiddleware', 47 | 'django.middleware.csrf.CsrfViewMiddleware', 48 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 49 | 'django.contrib.messages.middleware.MessageMiddleware', 50 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 51 | ] 52 | 53 | ROOT_URLCONF = 'todo_list.urls' 54 | 55 | TEMPLATES = [ 56 | { 57 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 58 | 'DIRS': [BASE_DIR/"templates"], 59 | 'APP_DIRS': True, 60 | 'OPTIONS': { 61 | 'context_processors': [ 62 | 'django.template.context_processors.debug', 63 | 'django.template.context_processors.request', 64 | 'django.contrib.auth.context_processors.auth', 65 | 'django.contrib.messages.context_processors.messages', 66 | ], 67 | }, 68 | }, 69 | ] 70 | 71 | WSGI_APPLICATION = 'todo_list.wsgi.application' 72 | 73 | 74 | # Database 75 | # https://docs.djangoproject.com/en/4.0/ref/settings/#databases 76 | 77 | DATABASES = { 78 | 'default': { 79 | 'ENGINE': 'django.db.backends.sqlite3', 80 | 'NAME': BASE_DIR / 'db.sqlite3', 81 | } 82 | } 83 | 84 | 85 | # Password validation 86 | # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators 87 | 88 | AUTH_PASSWORD_VALIDATORS = [ 89 | { 90 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 91 | }, 92 | { 93 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 94 | }, 95 | { 96 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 97 | }, 98 | { 99 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 100 | }, 101 | ] 102 | 103 | 104 | # Internationalization 105 | # https://docs.djangoproject.com/en/4.0/topics/i18n/ 106 | 107 | LANGUAGE_CODE = 'en-us' 108 | 109 | TIME_ZONE = 'UTC' 110 | 111 | USE_I18N = True 112 | 113 | USE_TZ = True 114 | 115 | #use for login view 116 | LOGIN_URL = 'login' 117 | 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/4.0/howto/static-files/ 121 | 122 | STATIC_URL = 'static/' 123 | 124 | # Default primary key field type 125 | # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field 126 | 127 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 128 | -------------------------------------------------------------------------------- /Bellaman-ford-algo.cpp: -------------------------------------------------------------------------------- 1 | // A C++ program for Bellman-Ford's single source 2 | // shortest path algorithm. 3 | #include 4 | using namespace std; 5 | 6 | // a structure to represent a weighted edge in graph 7 | struct Edge { 8 | int src, dest, weight; 9 | }; 10 | 11 | // a structure to represent a connected, directed and 12 | // weighted graph 13 | struct Graph { 14 | // V-> Number of vertices, E-> Number of edges 15 | int V, E; 16 | 17 | // graph is represented as an array of edges. 18 | struct Edge* edge; 19 | }; 20 | 21 | // Creates a graph with V vertices and E edges 22 | struct Graph* createGraph(int V, int E) 23 | { 24 | struct Graph* graph = new Graph; 25 | graph->V = V; 26 | graph->E = E; 27 | graph->edge = new Edge[E]; 28 | return graph; 29 | } 30 | 31 | // A utility function used to print the solution 32 | void printArr(int dist[], int n) 33 | { 34 | printf("Vertex Distance from Source\n"); 35 | for (int i = 0; i < n; ++i) 36 | printf("%d \t\t %d\n", i, dist[i]); 37 | } 38 | 39 | // The main function that finds shortest distances from src 40 | // to all other vertices using Bellman-Ford algorithm. The 41 | // function also detects negative weight cycle 42 | void BellmanFord(struct Graph* graph, int src) 43 | { 44 | int V = graph->V; 45 | int E = graph->E; 46 | int dist[V]; 47 | 48 | // Step 1: Initialize distances from src to all other 49 | // vertices as INFINITE 50 | for (int i = 0; i < V; i++) 51 | dist[i] = INT_MAX; 52 | dist[src] = 0; 53 | 54 | // Step 2: Relax all edges |V| - 1 times. A simple 55 | // shortest path from src to any other vertex can have 56 | // at-most |V| - 1 edges 57 | for (int i = 1; i <= V - 1; i++) { 58 | for (int j = 0; j < E; j++) { 59 | int u = graph->edge[j].src; 60 | int v = graph->edge[j].dest; 61 | int weight = graph->edge[j].weight; 62 | if (dist[u] != INT_MAX 63 | && dist[u] + weight < dist[v]) 64 | dist[v] = dist[u] + weight; 65 | } 66 | } 67 | 68 | // Step 3: check for negative-weight cycles. The above 69 | // step guarantees shortest distances if graph doesn't 70 | // contain negative weight cycle. If we get a shorter 71 | // path, then there is a cycle. 72 | for (int i = 0; i < E; i++) { 73 | int u = graph->edge[i].src; 74 | int v = graph->edge[i].dest; 75 | int weight = graph->edge[i].weight; 76 | if (dist[u] != INT_MAX 77 | && dist[u] + weight < dist[v]) { 78 | printf("Graph contains negative weight cycle"); 79 | return; // If negative cycle is detected, simply 80 | // return 81 | } 82 | } 83 | 84 | printArr(dist, V); 85 | 86 | return; 87 | } 88 | 89 | // Driver's code 90 | int main() 91 | { 92 | /* Let us create the graph given in above example */ 93 | int V = 5; // Number of vertices in graph 94 | int E = 8; // Number of edges in graph 95 | struct Graph* graph = createGraph(V, E); 96 | 97 | // add edge 0-1 (or A-B in above figure) 98 | graph->edge[0].src = 0; 99 | graph->edge[0].dest = 1; 100 | graph->edge[0].weight = -1; 101 | 102 | // add edge 0-2 (or A-C in above figure) 103 | graph->edge[1].src = 0; 104 | graph->edge[1].dest = 2; 105 | graph->edge[1].weight = 4; 106 | 107 | // add edge 1-2 (or B-C in above figure) 108 | graph->edge[2].src = 1; 109 | graph->edge[2].dest = 2; 110 | graph->edge[2].weight = 3; 111 | 112 | // add edge 1-3 (or B-D in above figure) 113 | graph->edge[3].src = 1; 114 | graph->edge[3].dest = 3; 115 | graph->edge[3].weight = 2; 116 | 117 | // add edge 1-4 (or B-E in above figure) 118 | graph->edge[4].src = 1; 119 | graph->edge[4].dest = 4; 120 | graph->edge[4].weight = 2; 121 | 122 | // add edge 3-2 (or D-C in above figure) 123 | graph->edge[5].src = 3; 124 | graph->edge[5].dest = 2; 125 | graph->edge[5].weight = 5; 126 | 127 | // add edge 3-1 (or D-B in above figure) 128 | graph->edge[6].src = 3; 129 | graph->edge[6].dest = 1; 130 | graph->edge[6].weight = 1; 131 | 132 | // add edge 4-3 (or E-D in above figure) 133 | graph->edge[7].src = 4; 134 | graph->edge[7].dest = 3; 135 | graph->edge[7].weight = -3; 136 | 137 | // Function call 138 | BellmanFord(graph, 0); 139 | 140 | return 0; 141 | } 142 | -------------------------------------------------------------------------------- /ToDo-List/templates/base/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | To Do List 8 | 9 | 10 | 11 | 132 | 133 | 134 |
135 | {% block content %} 136 | {% endblock content%} 137 |
138 | 139 | --------------------------------------------------------------------------------