View main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ROW_1 2 | |
#define ROW_2 3 | |
#define ROW_3 4 | |
#define ROW_4 5 | |
#define ROW_5 6 | |
#define ROW_6 7 | |
#define ROW_7 8 | |
#define ROW_8 9 | |
#define COL_1 10 |
View Image_and_Audio_CAPTCHA_in_Python.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Image Captcha: | |
from captcha.image import ImageCaptcha | |
image = ImageCaptcha | |
data = image.generate(‘9876543’) | |
image.write (‘9876543’,’sam.png’) |
View GraphRepresentation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UNDIRECTED GRAPH | |
''' | |
ADJ MATRIX | |
ADJ LIST | |
''' | |
''' | |
V E | |
FOR EVERY EDGE |
View BitMagic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# n convert it into binary | |
def intToBin(n): | |
return str(bin(n))[2:] | |
# bin to int | |
def binToInt(s): | |
return int(s,2) | |
# kth bit set from right | |
def kthbit(n,k): |
View BitMagic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ispowerof 2 | |
# n -> input | |
# True/False -> output | |
# check if n is a powerof 2 | |
# 512 -> True 512 = 2**9 | |
# 1024 -> True 1024 = 2**10 | |
def ispowerof2(n): | |
# T.C = O(1) | |
if n <= 0: |
View bitwise.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bitwise operator and - & | |
# bitwise operator or - | | |
# bitwise operator not - ~ | |
# bitwise operator xor - ^ | |
# bitwise operator right shift - >> | |
# bitwise operator left shift << | |
# rightshift is divide in power of 2 | |
# leftshift is multiply in power of 2 | |
def evenodd(n): | |
if n&1 == 1: |
View Sieve.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import * | |
def genprimes(n): | |
primes = [True]*(n+1) | |
primes[0] = False | |
primes[1] = False | |
for p in range(2,int(sqrt(n))+1): | |
if primes[p] == True: | |
for i in range(p*p,n+1,p): | |
primes[i] = False |
View primalitytest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prime numbers two factors 1 , Number Itself | |
# Approach One O(n) | |
# Aprroach Two: Base Case + Hint: O(1) -> O(root(N)) | |
from math import * | |
def approach1(n): | |
divcnt = 0 | |
for i in range(1,n+1): # [1,n] | |
if n%i == 0: | |
divcnt+=1 |
View divisors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 24 [1,2,3,4,6,8,12,24] | |
from math import * | |
def fun1(n): | |
# T.C = O(n) | |
div1 = [] | |
for i in range(1,n+1): # [1,n] | |
if n%i == 0: | |
div1.append(i) | |
return div1 |
View main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SoftwareSerial.h> // Import Soft Uart library | |
#include <Servo.h> // Import Servo library | |
// Bluetooth communication pins | |
#define TX 2 | |
#define RX 4 | |
// L298N communication pins | |
#define IN1 3 | |
#define IN2 5 |
NewerOlder