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
main = do | |
n <- readLn :: IO Int | |
nums <- forM (take n [1..]) (\x -> do | |
readLn :: IO Int) | |
print nums |
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
// A simple quickref for Eigen. Add anything that's missing. | |
// Main author: Keir Mierle | |
#include <Eigen/Dense> | |
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d. | |
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols. | |
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd. | |
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major. | |
Matrix3f P, Q, R; // 3x3 float matrix. |
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
class Node(object): | |
def __init__(self, val, leftchild=None, rightchild=None): | |
self.val = val | |
self.left = leftchild | |
self.right = rightchild | |
def bfs_iterative(tree, visitor): | |
q = [] | |
q.append((tree, 0)) |
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 <vector> | |
using namespace std; | |
const int trunk_size = 8 * 1024 * 1024; | |
class A { | |
public: | |
static int counter; | |
A() { id = counter++; cout << "alloc " << id << " @ " << this << endl; trunk.resize(trunk_size); } |
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 <algorithm> | |
using namespace std; | |
template <typename Container> | |
bool nextperm(Container &s) { | |
using T = Container; | |
typename T::iterator first = s.begin(); | |
typename T::iterator last = s.end() - 1; | |
typename T::iterator i = last; |
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 <time.h> | |
#include <vector> | |
using namespace std; | |
int main(int argc, char **argv) { | |
const int MAX = 10000; | |
vector<vector<double>> A(MAX, vector<double>(MAX)); | |
vector<double> x(MAX), y(MAX); | |
for(int i=0;i<MAX;++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
for /l %%x in (11, 1, 27) do ( | |
echo 0%%x | |
:: do something here | |
) |
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 <vector> | |
#include <stack> | |
#include <stdlib.h> | |
#include <algorithm> | |
#include <cfloat> | |
using namespace std; | |
struct Point { | |
Point():x(0), y(0){} |
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
vertices :: Integer -> Integer -> Integer -> [(Integer, Integer)] | |
vertices 1 w h = [(quot (w+1) 2, h)] | |
vertices n w h = foldl (\acc v -> acc ++ [((fst v) - dx, snd v), (fst v, (snd v) - dy), ((fst v) + dx, snd v)]) [] p | |
where p = vertices (n-1) w h | |
dx = quot (w+1) (2^n) | |
dy = quot h (2^(n-1)) | |
inrange :: Integer -> Integer -> Integer -> Bool | |
inrange 0 x y = abs (x - 32) < y | |
inrange n x y = inrange (n-1) x y && (foldl (\acc v -> acc && (not (abs (x-(fst v)) <= (snd v) - y && (snd v) - y < dy))) True verts) |
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 <vector> | |
#include <memory> | |
using namespace std; | |
struct dummy_t { | |
dummy_t(){} | |
dummy_t(int v):val(v){ | |
cout << "dummy " << val << " constructred." << endl; | |
} |