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 <string> | |
| #include <vector> | |
| #include <math.h> | |
| #include <map> | |
| #include <fstream> | |
| #include < ctime > | |
| #include <algorithm> | |
| #include <numeric> | |
| #include <set> |
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
| int main(){ | |
| Node a(1), b(2), c(3); | |
| Node d(4), e(5), f(6); | |
| a.next = &c; | |
| //b.next = &c; | |
| d.next = &e; e.next = &f; | |
| Node *temp = &a, *curr; | |
| Node *next = &d; | |
| while(temp){ |
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
| void parn( int index, int max, vector<set<string>> &all){ | |
| string *me, *one, *two, *three; | |
| set<string> x; | |
| if (index < 0 || index >= max ) return; | |
| else if (index == 0){ | |
| string *d = new string("()"); | |
| all[index].insert(*d); | |
| parn(index+1, max, all); | |
| } | |
| else{ |
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
| void getss(vector<int>& x, int index, vector<vector<int>>& all){ | |
| if ( index > x.size() || index < 0 ) return; | |
| if (index == 0 ){ | |
| vector<int> empty; | |
| all.push_back(empty); | |
| getss(x,index+1,all); | |
| } | |
| else{ | |
| vector<vector<int>> copyall(all); | |
| for( auto i = copyall.begin(); i != copyall.end(); ++i){ |
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
| int main() { | |
| rbtree<int> tree; | |
| int n = 10; | |
| vector<int> cur(n), prev(n,1); | |
| vector<vector<int>> board(n, vector<int>(n)); | |
| /// | |
| //iota(prev.begin(), prev.end(), 0); | |
| cout <<endl; |
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
| Sometimes it is necessary to keep a variable with in a certain range. ex. 0 - 255, 0 - 127, etc. I will show you an easy way to do modulo base 2 numbers with bitwise masking. | |
| First off, a little background on what modulus does. Modulus finds the remainder after division of two numbers. So the result of a % b will always be in between 0 and one less than b. | |
| Secondly, you need to know how the bitwise AND, &, works. It will compare the corresponding bits in each term, and only set the bit in the result if both bits in each term are set. | |
| 0101 | |
| AND 0011 | |
| = 0001 |
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 socket | |
| HOST = 'google.com' # The remote host | |
| PORT = 80 # The same port as used by the server | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect((HOST, PORT)) | |
| s.send('GET / HTTP/1.1\r\nHost: google.com\r\n\r\n') | |
| data = s.recv(1024) | |
| s.close() | |
| print 'Received', repr(data) |
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 <string> | |
| #include <vector> | |
| #include <math.h> | |
| #include <map> | |
| #include <fstream> | |
| using namespace std; | |
| vector<int> x; | |
| struct pan { |
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 <string> | |
| void perm(std::string x, int last){ | |
| if( last == 0 ){ | |
| std::cout << x << std::endl; | |
| return; | |
| } | |
| for( int i = 0; i <=last; i++){ |
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 send_email(): | |
| import smtplib | |
| gmail_user = "[email protected]" | |
| gmail_pwd = "secret" | |
| FROM = '[email protected]' | |
| TO = ['[email protected]'] #must be a list | |
| SUBJECT = "Testing sending using gmail" | |
| TEXT = "Testing sending mail using gmail servers" |