Skip to content

Instantly share code, notes, and snippets.

View Parassharmaa's full-sized avatar
🎯
Focusing

Paras Sharma Parassharmaa

🎯
Focusing
View GitHub Profile
@Parassharmaa
Parassharmaa / string_divide.cpp
Last active November 26, 2016 12:18
Cpp program to divide the string in equal parts and sort out the substrings
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
class str_op {
string s;
@Parassharmaa
Parassharmaa / rand_word.py
Created October 15, 2016 07:55
Generate random word.
import random
df = open("sowpods.txt")
x = list(map(str,df.read().split()))
n = len(x)
r = int(input("Enter Number of words:"))
for i in range(r):
rand = random.randrange(0,n)
print(str(i+1)+"." + x[rand])
@Parassharmaa
Parassharmaa / digit_words.cpp
Last active November 12, 2016 17:31
Program to converts digits into words (International system).
/*
Program to converts digits into words (International System).
(Supports upto 18 digits)
Program by Paras Sharmaa
*/
#include <iostream>
#include <cstring>
#include <stack>
@Parassharmaa
Parassharmaa / bst.cpp
Created November 23, 2016 16:50
Binary Search Tree: Insertion and traversing.
//Binary Search Tree: Insertion and traversing.
//Coded by: Paras Sharma
# include <iostream>
using namespace std;
class node {
public:
int key;
node *left;
@Parassharmaa
Parassharmaa / car_data.cpp
Last active February 25, 2024 14:16
Program to illustrate example of file handling in c++
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
using namespace std;
class DataCar {
string brand_name;
string model_name;
@Parassharmaa
Parassharmaa / solution.py
Last active March 14, 2017 11:41
Solution to hacker rank problem
# A businessman dealing in salt goes to do business in a country named "strangeland" . The pricing of commodities in this country is quite strange indeed. Here salt is sold only in quantised packets which are multiple of 1 kilogram. The pricing is such that for a packet of i kilogram , the price is p[i] silver coins. The businessman has N kilogram of salt to sell. He wants your help to pack it so that he can earn maximum profit in "strangeland".
# Input Format
# First line of the input file contains a single integer T, the number of test cases.
# Every test case starts with a line containing the integer N , total amount of salt.
# The next line contains N space separated integers where the i-th integer is P[i] , the price of a salt packet of i Kilogram.
#int partition function
@Parassharmaa
Parassharmaa / int_partition.py
Last active March 15, 2017 08:13
Integer Partition Algorithm
def partition(n):
if n==0:
yield []
for p in partition(n-1):
p.append(1)
yield p
p.pop()
if p and (len(p)<2 or p[-2] > p[-1]):
p[-1]+=1
@Parassharmaa
Parassharmaa / bfs.py
Created March 15, 2017 13:51
Breadth First Search : : Graph - Python
import collections
class SimpleGraph:
def __init__(self):
self.edges = {}
def neighbors(self, id):
return self.edges[id]
@Parassharmaa
Parassharmaa / lastEdit.js
Created June 8, 2017 07:03
List last edit time of file in a directory (using promises and moment.js)
let Promise = require("bluebird");
let fs = Promise.promisifyAll(require("fs"));
let moment = require('moment')
let getFiles = directory => {
return fs.readdirAsync(directory)
}
let getStat = filename => {
@Parassharmaa
Parassharmaa / tw_thread_image.py
Last active August 5, 2021 23:10
Python script to download image from a tweet thread.
from bs4 import BeautifulSoup
import requests
import urllib.request
data = requests.get("https://twitter.com/AmeyShrivastav1/status/857315283253559296").text
soup = BeautifulSoup(data, "html.parser")
#array of tags
img_data = soup.find_all("div", {"class": "AdaptiveMedia-photoContainer"})