Skip to content

Instantly share code, notes, and snippets.

View theabbie's full-sized avatar
❤️
Playing With Life Since 2002

Abhishek Choudhary theabbie

❤️
Playing With Life Since 2002
View GitHub Profile
@theabbie
theabbie / repost_bot.py
Created January 30, 2025 09:45
Cron-powered Repost bot for Instagram, Reddit and Imgur with Rate-limit Queue.
import os
import json
import re
import instaloader
import requests
from flask import Flask, request, jsonify
from urllib.parse import urlparse
import firebase_admin
from firebase_admin import credentials, firestore
import praw
@theabbie
theabbie / cab_booking_lld.py
Created January 19, 2025 07:43
Cab Booking Application Low-Level Design (LLD) in Python
class Status:
AVAILABLE = 0
UNAVAILABLE = 1
MAX_DISTANCE_TO_ALLOW_RIDE = 5
class Location:
def __init__(self, x, y):
self.x = x
self.y = y
@theabbie
theabbie / RandomGraphGenerator.py
Created January 24, 2024 05:09
Random Graph Generator
from random import *
# Floyd Sampler
def sampler(N, K):
res = set()
for i in range(N - K, N):
j = randint(0, i)
if j not in res:
res.add(j)
else:
@theabbie
theabbie / RandomTreeGenerator.py
Created January 23, 2024 11:02
Random Tree Generator
from random import *
def randTree(N):
edges = []
comps = [[i] for i in range(N)]
for _ in range(N - 1):
i = randint(0, len(comps) - 1)
j = randint(0, len(comps) - 2)
if j == i:
j += 1
@theabbie
theabbie / lights_out.md
Last active October 6, 2023 10:49
Python Script to solve "Lights Out" Game in optimal way using BFS.
@theabbie
theabbie / iterative_merge_sort.py
Created September 6, 2023 09:36
Iterative Merge Sort in Python
def merge(arr, i, mid, j, extra):
x = i
y = mid
while x < mid and y < j:
if arr[x] <= arr[y]:
extra[x + y - mid] = arr[x]
x += 1
else:
extra[x + y - mid] = arr[y]
y += 1
@theabbie
theabbie / leetcode.txt
Created February 21, 2023 12:42
All Leetcode Questions
1 two-sum
2 add-two-numbers
3 longest-substring-without-repeating-characters
4 median-of-two-sorted-arrays
5 longest-palindromic-substring
6 zigzag-conversion
7 reverse-integer
8 string-to-integer-atoi
9 palindrome-number
10 regular-expression-matching
@theabbie
theabbie / ascii_human.py
Last active October 22, 2022 08:12
Dancing ASCII Human in Python
import random
from time import sleep
class Human:
def __init__(self):
self.human = [[" ", "o", " "], ["/", "|", "\\"], ["/", " ", "\\"]]
self.front = False
self.commandmap = {
"left hand to head": self.leftHandToHead,
"left hand to hip": self.leftHandToHip,
@theabbie
theabbie / rle.py
Created October 15, 2022 19:16
Run-length Encoding Imlementation in Python
def encode(s):
n = len(s)
res = []
i = 0
while i < n:
ctr = 1
while i < n - 1 and s[i] == s[i + 1]:
ctr += 1
i += 1
if ctr == 1:
@theabbie
theabbie / binexp.py
Created October 11, 2022 14:27
Iterative binary exponentiation
def pow(a, b):
curr = a
res = 1
while b:
if b & 1:
res *= curr
b = b >> 1
curr *= curr
return res