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
void placeQueen(vector<int>& colNo, vector<bool>& usedCol, vector<bool>& rowPlusCol, vector<bool>& rowMinusCol, int row, vector<vector<string>>& result) | |
{ | |
int n = usedCol.size(); | |
if (row == n) | |
{ | |
//all queens have been placed | |
vector<string> board(n, string(n, '.')); | |
int i; | |
for (i = 0; i < n; ++i) |
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; | |
bool isPowerOf2 (long long x) | |
{ | |
/* First x in the below expression is for the case when x is 0 */ | |
return x && (!(x&(x-1))); | |
} |
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<stdio.h> | |
#include<mpi.h> | |
int main(int argc, char **argv) | |
{ | |
int rank=0, n, src, dest; | |
MPI_Init(&argc, &argv); | |
MPI_Status status; | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
MPI_Comm_size(MPI_COMM_WORLD, &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
/* | |
* Header containing function primeFactorisation which returns std::map of prime factorisation of number | |
* PROTOTYPE: | |
* std::map<int, int> GS::primeFactorisation(int num); | |
* 'num' is the number for which prime factorisation is required | |
* In the map returned, for each element (i.e. pair), first element is factor and second is its power | |
* E.g. | |
* Prime factorisation of 49 = 2 * 7 * 7 = (2^1) * (7^2) | |
* So, the map would contain pairs (2, 1) and (7, 2), | |
*/ |
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> | |
using namespace std; | |
#include<stdexcept> | |
#include<string.h> | |
char strToEscSeq(const char str[]) | |
{ |
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<stdio.h> | |
void First(); | |
void Last(); | |
#pragma startup First | |
#pragma exit Last | |
void First() | |
{ |
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
/* | |
Usage : | |
"test.cpp" | |
---------- | |
#include <iostream> | |
#define _START_ begin | |
#define _EXIT_ end | |
#include "Startup_Exit.h" |
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
#ifndef IsInteger | |
#define IsInteger | |
// Note: Here, RealNumberType should be convertible to int | |
// and the value contained in RealNumberType should not be greater than | |
// max value of int | |
//Maybe IntegerType should only be take as template arguement (seems necessary) | |
//Original type of arguement might be found using typeinfo or something...(Not sure, check) |