15 |
16 | {% endblock content %}
17 |
--------------------------------------------------------------------------------
/ToDo-List/templates/base/loginpage.html:
--------------------------------------------------------------------------------
1 | {% extends 'base/base.html' %}
2 | {% block content %}
3 |
4 |
7 |
8 |
9 |
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 |
7 |
8 |
9 |
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