Skip to content

Instantly share code, notes, and snippets.

View Superty's full-sized avatar

Arjun P Superty

  • University of Edinburgh
View GitHub Profile
arjun@acrux-3 ~/build/zsim % scons 29ms
scons: Reading SConscript files ...
Building opt zsim at build/opt
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/opt/access_tracing.os -c -fPIC -march=core2 -g -O3 -funroll-loops -g -std=c++0x -Wall -Wno-unknown-pragmas -fomit-frame-pointer -fno-stack-protector -MMD -DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32E -DHOST_IA32E -fPIC -DTARGET_LINUX -DPIN_PATH="/opt/pin/intel64/bin/pinbin" -DZSIM_PATH="/home/arjun/build/zsim/build/opt/libzsim.so" -DMT_SAFE_LOG -I/opt/pin/extras/xed-intel64/include/xed -I/opt/pin/source/include/pin -I/opt/pin/source/include/pin/gen -I/opt/pin/extras/components/include -I/opt/pin/extras/crt/include -I/usr/lib/modules/6.1.55-1-MANJARO/build/include -I/usr/lib/modules/6.1.55-1-MANJARO/build/arch/x86/include -I/usr/lib/mod
import data.finset data.multiset
import tactic
import init.classical
noncomputable theory
open_locale classical
local attribute [instance, priority 10000] classical.prop_decidable -- avoid decidability hell
universe u
variables {α β : Type u}
@Superty
Superty / ncr.lean
Last active February 21, 2020 01:50
import data.finset
open finset
variables n k : ℕ
local prefix `ι`:90 := finset.singleton
abbreviation S (n k : ℕ) := powerset_len k (range n)
def binom (n k : ℕ) : ℕ := card (S n k)
abbreviation Swith (n k : ℕ) : finset (finset ℕ) := finset.bind (S n k) (λ s, (ι(insert n s)))
universe u
namespace hidden
open nat (zero succ)
def add : ℕ → ℕ → ℕ
| n zero := n
| n (succ m) := succ (add n m)
set_option trace.app_builder true
The following methods of address collection are not considered 'opt-in' and are not recommended:
Setting a checkbox on a web form or within a piece of software to subscribe all users by default (requiring users to explicitly opt-out of mailings).
Add the following headers as described in RFC 8058:
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe: <https://example.com/unsubscribe/opaquepart>
Automatically unsubscribe users whose addresses bounce multiple pieces of mail.
Explicitly indicate the email address subscribed to your list.
@Superty
Superty / rec.cpp
Last active September 11, 2016 20:29
dp[i][j] = no. of ways to get j in the first i slots
dp[0][j] = 0, dp[0][0] = 1
dp[i][j] = sum[i - 1][b] - sum[(k = a to b)
sum[i - 1][j] = sum dp[i - 1][k] k = 1 to j
dp[i]
dp[i][j] = no. of ways to partition i into j partitions
dp[i][j] = dp[i - 1][j - 1] + j*dp[i - 1][j]
long long gcd(long long a, long long b)
{
if(b == 0) return a;
else return gcd(b, a % b);
}
@Superty
Superty / minHeap.cpp
Created January 14, 2015 09:09
min heap
int n = 0;
int heap[maxn];
const int inf = 1e9;
void update(int p, int x)
{
if(heap[p] < x)
{
heap[p] = x;
while(heap[p] > min(heap[2*p], heap[2*p + 1]))
{
@Superty
Superty / topologicalSort.cpp
Last active May 15, 2016 21:55
performing topological sort
int deg[maxn], rank[maxn];
void topologicalSort()
{
queue<int> q;
for(int i = 1; i <= n; i++)
{
if(deg[i] == 0)
{
rank[i] = 0;
@Superty
Superty / segmentTree.cpp
Last active May 15, 2016 21:55
segment tree
struct node
{
//data members
void split(node &l, node &r) { } //reset update members; update l and r
void merge(node &l, node &r) { } //update by merging l and r; reset update members
node() { }
} segTree[SIZE];
int h = 0;