This file contains hidden or 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
| 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 |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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 <iostream> | |
| #include <fstream> | |
| #include <iomanip> | |
| #include <cstdio> | |
| using namespace std; | |
| class DataCar { | |
| string brand_name; | |
| string model_name; |
This file contains hidden or 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
| //Binary Search Tree: Insertion and traversing. | |
| //Coded by: Paras Sharma | |
| # include <iostream> | |
| using namespace std; | |
| class node { | |
| public: | |
| int key; | |
| node *left; |
This file contains hidden or 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
| /* | |
| Program to converts digits into words (International System). | |
| (Supports upto 18 digits) | |
| Program by Paras Sharmaa | |
| */ | |
| #include <iostream> | |
| #include <cstring> | |
| #include <stack> |
This file contains hidden or 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
| 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]) | |
This file contains hidden or 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 <iostream> | |
| #include <cstdlib> | |
| #include <cstring> | |
| #include <vector> | |
| #include <algorithm> | |
| using namespace std; | |
| class str_op { | |
| string s; |
This file contains hidden or 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
| def mul(s): | |
| l = len(s) | |
| for i in range(2, l): | |
| if l%i==0: | |
| return(i) | |
| break | |
| else: | |
| return 1 | |
| s = input("Input String:") |
This file contains hidden or 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 <iostream> | |
| #include <cstring> | |
| using namespace std; | |
| class stack { | |
| int top; | |
| int size; | |
| int *arr; |
This file contains hidden or 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 <iostream> | |
| using namespace std; | |
| class queue { | |
| int *arr; | |
| int f,r, max; | |
| public: | |
| queue(int n) { |