Skip to content

Instantly share code, notes, and snippets.

View hsnice16's full-sized avatar
🏠
Working from home

Himanshu Singh hsnice16

🏠
Working from home
View GitHub Profile
@hsnice16
hsnice16 / Calculator.py
Last active July 19, 2020 21:21
My First Python Simple Project.
// re is regular expression
import re
print("Our Magical Calculator")
print("Type 'quit' to exit\n")
previous = 0
run = True
def performMath():
from bs4 import BeautifulSoup
import requests
from PIL import Image
from io import BytesIO
import os
def start_search():
search = input("search for: ")
params = {"q": search}
dir_name = search.replace(" ", "_").lower()
// Program to set border in a given image
// SimpleImage class exist in dukelearntoprogram
var image = new SimpleImage("smallpanda.png");
// thickness of border required
var thickness = 10;
// function which set the pixel received to black;
function setBlack(pixel){
@hsnice16
hsnice16 / NodeStructure
Last active January 1, 2021 07:27
Node structure for Binary Tree (in c++)
// c++
struct Node
{
int key; // value in node
Node *left, *right; // stores left/right child
bool rightThread; // stores right Thread for node exists or not
};
// c++
if (curr->key > el) // curr is a variable maintaining current node(already present in tree)
// with which comparison is taking place
// And, el is new key we have to insert
{
successor = curr; // successor only contain value if new node
// goes in left subtree of curr node
curr = curr->left; // go left subtree
}
if (curr->key < el)
{
if (curr->rightThread) // if current node has rightThread == true
{
curr->right = NULL; // make right child null of current node
curr->rightThread = false; // change value of rightThread for current node from true to false
}
curr = curr->right; // go right subtree
}
// adding thread
if (successor) // if successor is not NULL
{
// newNode stores data of new node
newNode->right = successor; // store successor value in right child of newNode
newNode->rightThread = true; // makes rightThread valur of new Node to true
}
/*
optimization of fibonacci numbers implementation
time comlexity : O(n) rather than exponential ,as in older recursive implementation.
*/
int fib(int n, int memo[])
{
if (memo[n] == -1) // if we encounter this number first number, as memo[] is initialized with -1
{
int res;
if (n == 0 || n == 1)
@hsnice16
hsnice16 / GSSOC-PRs
Last active October 15, 2022 07:24
list of all the PRs, I raised during GSSOC 2021
- https://github.com/ayan-biswas0412/gssoc2021-HotelOnTouch/pull/161
- https://github.com/Manthan933/Manthan/pull/169
- https://github.com/DhairyaBahl/React-Messenger-App/pull/43
- https://github.com/DhairyaBahl/React-Messenger-App/issues/170