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
const deg2rad = (a: number): number => { | |
a%=360; | |
a=(a+360)%360; | |
return Math.PI*a/180; | |
}; | |
class mx3 { | |
constructor(public rows: [vec3, vec3, vec3]) {} | |
transpose(): mx3 { |
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
const _ = require('lodash'); | |
const task = (n) => { | |
return new Promise((resolve, reject)=> { | |
setTimeout(() => { | |
console.log("t"+n+" done"); | |
resolve(n); | |
}, 1000*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
import Foundation | |
indirect enum Exp { | |
case num(Int) | |
case list([Exp]) | |
} | |
// [1,2,[3,[4,5],6],7,[[8,9]],10] | |
func flatten(_ e: Exp) -> [Int] { | |
var res = [Int]() |
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 Foundation | |
indirect enum Exp { | |
case add(Exp, Exp) | |
case sub(Exp, Exp) | |
case num(Int) | |
func apply() -> Int { | |
switch self { | |
case let .add(e1, e2): |
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
#define FOR(i,a,b) for(int i=(a);i<(b);++i) | |
#define REP(i,n) for(int i=0;i<(n);++i) | |
#define FORE(i,a,b) for(int i=(a);i<=(b);++i) | |
#define REPE(i,n) for(int i=0;i<=(n);++i) | |
#define FORR(x,arr) for(auto& x:arr) | |
#define SZ(a) int((a).size()) | |
#define ALL(c) (c).begin(),(c).end() | |
typedef long long LL; | |
typedef pair< int , int > II; | |
typedef unordered_map < int, int > MAPII; |
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
// type alias | |
typedef long long LL; | |
typedef pair< int , int > II; | |
typedef tuple< int, int, int > III; | |
typedef vector<int> VI; | |
typedef vector<string> VS; | |
typedef vector<vector<int>> VVI; | |
typedef unordered_map<int,int> MAPII; | |
typedef unordered_set<int> SETI; | |
template<class T> using VV=vector<vector<T>>; |
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 <algorithm> | |
#include <vector> | |
#include <string> | |
#include <sstream> | |
#include <set> | |
#include <map> | |
#include <iostream> | |
#include <utility> | |
#include <cctype> |
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 <string> | |
using namespace std; | |
// repetition | |
#define FOR(i,a,b) for(int i=(a);i<(b);++i) | |
#define REP(i,n) for(int i=0;i<(n);++i) | |
#define FORR(x,arr) for(auto& x:arr) | |
#define SZ(a) int((a).size()) |
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
protocol OptionalType { | |
associatedtype W | |
var optional: W? { get } | |
} | |
extension Optional: OptionalType { | |
typealias W = Wrapped | |
var optional: W? { return self } | |
} |
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
// http://cpp.sh | |
// Example program | |
#include <iostream> | |
#include <algorithm> // max,min | |
#include <vector> | |
#include <string> | |
#include <sstream> | |
#include <map> | |
#include <iostream> |
NewerOlder