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
#x = ['1', '6', 'f', '1c', '2d', '42', '5b', '78', '99'] | |
#x = [ int(i,16) for i in x ] | |
#for i in x: | |
# print hex(i) | |
#print x | |
#for i in range(1, len(x)): | |
# print x[i]-x[i-1] | |
def lessthanf(x): | |
for i in x: |
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 <vector> | |
#include <iostream> | |
using namespace std; | |
void msort(vector<int>&); | |
void merge(vector<int>&, vector<int>&, vector<int>&); | |
void print(vector<int>&); | |
int main(int argc, char* argv[]){ | |
int d[] = { 1, 3, 5, 4, 12, 23, 11, 12, 0}; |
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 <iostream> | |
#include <string> | |
using namespace std; | |
bool is_pal( string x ){ | |
int j = x.length()-1; | |
for( int i = 0; i < x.length()-1; ++i){ | |
if( x[i] != x[j--]) return false; | |
} |
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 <iostream> | |
#include <string> | |
using namespace std; | |
void rev(string &x){ | |
int j = x.length()-1; | |
for( int i = 0; i < x.length()/2; ++i){ | |
swap(x[i], x[j--]); | |
} |
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 "sorter.hpp" | |
using namespace std; | |
int main(){ | |
int d[] = {0,1,2,5,5,5,6,5,5}; | |
vector<int> x(begin(d), end(d)); | |
srand(time(0)); | |
Sorter s(x); | |
s.print(); | |
s.quicksort(); |
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 "hanoi.hpp" | |
Hanoi::Hanoi(){ | |
x = 4; | |
for( int i = x-1; i >= 0; --i) | |
peg[0].push(i); | |
} | |
Hanoi::Hanoi(int n){ | |
x = n; |
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 <iostream> | |
#include <vector> | |
#include <fstream> | |
#include <string> | |
#include <sstream> | |
#include <map> | |
#include <set> | |
#include <algorithm> | |
using namespace std; |
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 <iostream> | |
#include <vector> | |
using namespace std; | |
int xcount = 0; | |
void getset( int i, int j, vector<int> nums, int sum){ | |
if( j >= i ) return ; | |
if( sum+nums[j] == nums[i] ){ | |
xcount++; |
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 <iostream> | |
#include <string> | |
#include <map> | |
using namespace std; | |
bool ransom( string note, string mag ){ | |
if( mag.empty() ) return false; | |
if( note.empty()) return true; | |
int length = note.length(); | |
int length_mag = mag.length(); |
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 <vector> | |
#include <iostream> | |
#include <random> | |
#include <time.h> | |
#include <queue> | |
using namespace std; | |
class Node{ | |
public: | |
Node():data(0),left(nullptr),right(nullptr),parent(nullptr) {} |