Skip to content

Instantly share code, notes, and snippets.

View xennygrimmato's full-sized avatar

Vaibhav Tulsyan xennygrimmato

View GitHub Profile
export OCAMLFIND_CONF="$(pwd)/_build/ocamlfind/lib/findlib.conf" && export PATH="/Users/vaibhavtulsyan/learn-reason/ExampleProject/node_modules/nopam:$PATH" && export opam_bin="$(pwd)/./_build/ocamlfind/bin" && export opam_doc="$(pwd)/./_build/ocamlfind/doc" && export opam_lib="$(pwd)/./_build/ocamlfind/lib" && export opam_man="$(pwd)/./_build/ocamlfind/man" && export opam_prefix="$(pwd)/./_build/ocamlfind" && export opam_sbin="$(pwd)/./_build/ocamlfind/sbin" && export PATH="/Users/vaibhavtulsyan/learn-reason/ExampleProject/node_modules/opam-installer-bin/_build/ocamlfind/bin:$PATH" && export CHECK_IF_PREINSTALLED="false" && export OCAMLLIB="/Users/vaibhavtulsyan/learn-reason/ExampleProject/node_modules/ocaml/lib/ocaml" && export OCAMLPARAM="_,g=1" && export OCAML_TOPLEVEL_PATH="/Users/vaibhavtulsyan/learn-reason/ExampleProject/node_modules/ocaml/lib/ocaml" && export OCAML__SOME_VAR="see how this must be prefixed by OCAML__ because the package name is ocaml, and this wasnt marked global:true" && export PATH="
@xennygrimmato
xennygrimmato / NAJKRACI.cpp
Created March 12, 2018 18:48
SPOJ - NAJKRACI
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int N = 6502;
const int INF = 1000000000;
const int MOD = 1000000007;
typedef vector<int> vi;
@xennygrimmato
xennygrimmato / russian_dolls_ways.py
Last active March 15, 2018 03:20
CSAcademy - #73 - Russian Dolls Ways
from collections import Counter
MOD, N = 10**9 + 7, 10**5 + 2
fact = [1] + [j for j in [1] for i in xrange(1, N) for j in [(j * i) % MOD]]
inv = [pow(fact[i], MOD - 2, MOD) for i in xrange(N)]
def C(h, k): return (fact[h] * inv[k] * inv[h - k]) % MOD
n, d = raw_input(), Counter(map(int, raw_input().split())).most_common()
print (reduce(lambda x, y: (x * C(d[0][1], y[1]) * fact[y[1]]) % MOD, d, 1) * inv[d[0][1]]) % MOD
@xennygrimmato
xennygrimmato / russian_dolls_ways.py
Last active March 15, 2018 03:21
CSAcademy - #73 - Russian Dolls Ways
fact, n, d = [1] + [j for j in [1] for i in xrange(1, 10**5+2) for j in [(j * i) % (10**9+7)]], raw_input(), __import__('collections').Counter(map(int, raw_input().split())).most_common();print (reduce(lambda x, y: (x * fact[d[0][1]] * pow(fact[d[0][1] - y[1]], (10**9+7) - 2, (10**9+7))) % (10**9+7), d, 1) * pow(fact[d[0][1]], 10**9+5, 10**9+7)) % (10**9+7)
@xennygrimmato
xennygrimmato / TheLotteryBothDivs
Last active March 18, 2018 11:48
Topcoder SRM 502 - Div2 500
# https://community.topcoder.com/stat?c=problem_statement&pm=11359
class TheLotteryBothDivs:
def find(self, goodSuffixes):
s = goodSuffixes
s = sorted(s, key=lambda x: len(x))
st = set()
for t in s:
for i in xrange(len(t)):
if t[i:] in st:
@xennygrimmato
xennygrimmato / spoj_pt07x.py
Last active April 20, 2018 14:03
SPOJ - PT07X
# http://www.spoj.com/problems/PT07X/
from functools import lru_cache
d = {}
@lru_cache(maxsize=None)
def f(u, taken, parent):
s0, s1 = 0, 0
for v in d[u]:
if taken and v!=parent: s0 += min(f(v, 1, u), f(v, 0, u))
elif v!=parent: s1 += f(v, 1, u)
if taken: return 1 + s0

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@xennygrimmato
xennygrimmato / infer_output.txt
Created July 24, 2018 10:15
infer issue with sub-modules
Summary of the reports:
...
(not shared for privacy)
Error while running epilogue "restoring Maven's pom.xml to its original state":
(Unix.Unix_error "No such file or directory" rename
"((src /Users/vaibhavtulsyan/infer_test_run/portal/rest-utils/pom.xml.infer-orig) (dst /Users/vaibhavtulsyan/infer_test_run/portal/rest-utils/pom.xml))").
Powering through...
Error while running epilogue "restoring Maven's pom.xml to its original state":
(Unix.Unix_error "No such file or directory" rename
...
copying bblfsh/github/com/gogo/protobuf/gogoproto/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/bblfsh/github/com/gogo/protobuf/gogoproto
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'bblfsh.pyuast' extension
creating build/temp.macosx-10.12-x86_64-3.6
creating build/temp.macosx-10.12-x86_64-3.6/bblfsh
creating build/temp.macosx-10.12-x86_64-3.6/bblfsh/libuast
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ibblfsh/libuast -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/include -I/usr/include/libxml2 -I/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c bblfsh/pyuast.cc -o build/temp.macosx-10.12-x86_64-3.6/bblfsh/pyuast.o -std=c++11
...
copying bblfsh/github/com/gogo/protobuf/gogoproto/__init__.py -> build/lib.macosx-10.12-x86_64-3.6/bblfsh/github/com/gogo/protobuf/gogoproto
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building 'bblfsh.pyuast' extension
creating build/temp.macosx-10.12-x86_64-3.6
creating build/temp.macosx-10.12-x86_64-3.6/bblfsh
creating build/temp.macosx-10.12-x86_64-3.6/bblfsh/libuast
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ibblfsh/libuast -I/usr/local/include -I/usr/local/include/libxml2 -I/usr/include -I/usr/include/libxml2 -I/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c bblfsh/pyuast.cc -o build/temp.macosx-10.12-x86_64-3.6/bblfsh/pyuast.o -std=c++11