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
import Control.Monad (unless) | |
import Data.IntSet (IntSet) | |
import qualified Data.IntSet as IntSet | |
-- Generate and print out all combinations up to size n | |
nCombination :: Int -> IO () | |
nCombination n = do | |
print $ IntSet.toList IntSet.empty | |
combination' n IntSet.empty $ makeBaseCase 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 <stdlib.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <time.h> | |
#include <assert.h> | |
// Signature for all sorting functions | |
typedef void (*SortFunc)(int*,int); | |
void swap(int* a, int* b) |
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 <stdlib.h> | |
struct tree_node | |
{ | |
int data; | |
struct tree_node *left, *right; | |
}; | |
struct tree_node *create_node(int data) |
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
{- | |
If you want to read in Strings: getInputLinesWith id n | |
if you want to read in Ints: getInputLinesWith read n :: IO [Int] | |
where n is how many lines to take input from | |
-} | |
getInputLinesWith :: (String -> a) -> Int -> IO [a] | |
getInputLinesWith f n = fmap (map f) (replicateM n getLine) |
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 <algorithm> | |
#include <chrono> | |
#include <vector> | |
#include <map> | |
#include <iostream> | |
#include <tuple> | |
#include <string> | |
#include <ctime> | |
namespace chrono = std::chrono; |
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 <string> | |
#include <stack> | |
#include <iostream> | |
#include <algorithm> | |
#include <sstream> | |
#include <cctype> | |
#include <vector> | |
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 <queue> | |
#include <vector> | |
#include <string> | |
#include <utility> | |
#include <functional> | |
#include <cstring> | |
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> | |
#include <stack> | |
#include <queue> | |
#include <utility> | |
#include <limits> | |
#include <functional> | |
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 <vector> | |
#include <iostream> | |
using namespace std; | |
/** | |
\brief Given a complete, undirected, weighted graph in the form of an adjacency matrix, | |
returns the smallest tour that visits all nodes and starts and ends at the same | |
node. This dynamic programming solution runs in O(n^2 * 2^n). |
OlderNewer