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; | |
| int sudoku[9][9],ptr[162],xstart[9]={0,3,6,0,3,6,0,3,6}, ystart[9]={0,0,0,3,3,3,6,6,6}; | |
| int valid(){ | |
| int valid=1; | |
| int hashtable[10]; | |
| for(int i=0;i<9;i++){ | |
| for(int j=0;j<9;j++){ | |
| for(int k=j+1;k<9;k++){ | |
| if(sudoku[i][j]==0) continue; |
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> | |
| #define SIZE 4 | |
| #define debug(x) cout<< #x << " = "<< x <<endl | |
| #define swap(typ,A,B) { typ temp;temp=B; B=A;A=temp;} | |
| using namespace std; | |
| vector <int> permset; | |
| string flags; |
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> | |
| using namespace std; | |
| string deleteKthCharacter(string str, int k){ | |
| return str.erase(k, 1); | |
| } | |
| void permute( string dest, string source, int len){ | |
| if( dest.length() == len){ |
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<algorithm> | |
| using namespace std; | |
| int main(){ | |
| int n; | |
| char c; | |
| vector < string > next, current; |
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> | |
| #define debug(x) cout<< #x << " = "<< x <<endl | |
| #define swap(typ,A,B) { typ temp;temp=B; B=A;A=temp;} | |
| using namespace std; | |
| class Node{ | |
| friend class HuffmanTree; | |
| char ch; | |
| float prob; |
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
| # Problem 1 | |
| """Find the sum of all the multiples of 3 or 5 below 1000.""" | |
| sum( [ num for num in range(3,1000) if num % 3 == 0 or num % 5 == 0 ] ) | |
| # Problem 4 | |
| """ | |
| A palindromic number reads the same both ways. The largest palindrome | |
| made from the product of two 2-digit numbers is 9009 = 91 99. |
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
| ==================================================================== | |
| Simple-as-possible instructions to add a field (or more) using South | |
| to an existing Django model with existing data. | |
| ==================================================================== | |
| Two versions: | |
| 1. Super-condensed (the bare minimum - jfdi) | |
| 2. Detailed-but-brief (if you want more information). | |
| Notes: |
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
| char *token = strtok(char *str, char *delim); // first time. | |
| while(token != NULL){ | |
| token = strtok(NULL, delim); // to retrieve the subsequent tokens. | |
| } |
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
| /* thread 1 */ | |
| char *str1 = "1,2,3", *token; | |
| token = strtok(str1, ","); | |
| while(token != NULL){ | |
| token = strtok(NULL, delim); | |
| } | |
| /* thread 2 */ |
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
| string RainyRoad::isReachable(vector <string> road) { | |
| int n = road[0].length(); | |
| if(road[0][0] == 'W' || road[0][n-1] == 'W') | |
| return "NO"; | |
| for(int i = 0 ;i < n; i++){ | |
| if(road[0][i] == 'W' && road[1][i] == 'W') | |
| return "NO"; | |
| } | |
| return "YES"; | |
| } |
OlderNewer