Skip to content

Instantly share code, notes, and snippets.

View MahmudHasanCSE's full-sized avatar
🎯
Focusing

Hasan MahmudHasanCSE

🎯
Focusing
View GitHub Profile
#pyramid
n=5
for i in range(0,n):
s=' '*(n-i)
s= s+ '*'*(i*2-1)
print(s)
#floyd triangle
def floyd(n):
count = 1
s = ""
for i in range(1,n+2):
for j in range(1,i):
s = s + " " + str(count)
count = count + 1
print(s)
s = ""
# a^n --- O(n)
def pow(a, n):
result = 1.0
for _ in range(n):
result = result * a
return result
print(pow(2, 2))
def pow(a, n): # a^n --- O(log n)
if n == 0: return 1
if n == 1: return a
if n % 2 == 1:
return a * pow(a, n-1)
else:
p = pow(a, n/2)
return p * p
print(pow(2, 2))
import os
import sqlite3
import operator
from collections import OrderedDict
import matplotlib.pyplot as plt
import webbrowser as wb
def parse(url):
try:
parsed_url_components = url.split('//')
import os
import configparser # configparser to read the profiles.ini file in to determine which folder to use
mozilla_profile = os.path.join(os.getenv('APPDATA'), r'Mozilla\Firefox')
mozilla_profile_ini = os.path.join(mozilla_profile, r'profiles.ini')
profile = configparser.ConfigParser()
profile.read(mozilla_profile_ini)
data_path = os.path.normpath(os.path.join(mozilla_profile, profile.get('Profile0', 'Path')))
# os.path.normpath() is used to ensure backslashes are used.
a = int(input()) # direct input with casting
a,b=input().split() # input a and b
a,b=map(int,input().split()) # input a and b with casting
@MahmudHasanCSE
MahmudHasanCSE / increment.py
Created January 2, 2019 09:45
Best way to increment of 1 in python?
# recursive abacus
def inc(x,n=0): return inc(x^(1<<n),inc(0,n)) if x&(1<<n) else x|x^(1<<n)
# there are 10 type of coders ...
lambda i: i++ (lambda j: j()**j())(type(i)) #halike
# dyslexia
lambda i: (sum(range(x))*2)/x # decrement #halike
# it's all about the context
@MahmudHasanCSE
MahmudHasanCSE / README.md
Created January 29, 2019 16:24 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@MahmudHasanCSE
MahmudHasanCSE / README.md
Created January 30, 2019 10:24 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet