Skip to content

Instantly share code, notes, and snippets.

View jeremiahbiard's full-sized avatar

Jeremiah Biard jeremiahbiard

View GitHub Profile
@jeremiahbiard
jeremiahbiard / framework.css
Created November 6, 2016 02:43
Simple diy css framework for FCC front end projects.
* {
border: 1px solid red !important;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
// Given a route like this:
<route path="/course/:courseId" handler={Course} />
// and a URL like this:
'/course/clean-code?module=3'
// The components props will be populated
var Course = React.createClasss({
render: function() {
this.props.params.courseId; // clean-code
'use strict';
var Lexer = exports.Lexer = function() {
this.pos = 0;
this.buf = null;
this.buflen = 0;
// Operator table, mapping operator -> token name
this.optable = {
'+': 'PLUS',
//Node Code Here
//Add more files in the file editor.
//Run the code, test it and share it.
//app.js is your main file which will execute.
//You can add more files and directories in the file Explorer in the left.
"use strict";
var assert = require('assert');
var evalScheem = function (expr, env) {
// Numbers evaluate to themselves
if (typeof expr === 'number') {
start =
expression
validchar
= [0-9a-zA-Z_?!+\-=@#$%^&*/.]
_ =
" "*
list
@jeremiahbiard
jeremiahbiard / Hint.md
Last active August 29, 2015 14:27 — forked from yuvipanda/Hint.md
Polygon Diagonals Solution (InterviewStreet CodeSprint Fall 2011)

`The required answer is : 1 / (n + k) * n-choose-r(n - 3,k) * n-choose-r(n + k, n - 1).

While I am not aware of a simple way to prove this which I can describe here, here's some practical advice on how such problems can be approached. It helps to write down a simpler solution and searching Google or OEIS (Online Encyclopedia of Integer Sequences) for small inputs like k = 3 and N = 1,2,...10. This usually gives you a formula describing the sequence, and possibly generalizations for the same.

Computing the answer using the above formula requires calculating the power of MOD (1e6 + 3) in the numerator and the demonimator. If the power of MOD is bigger in the numerator, the answer is 0. Otherwise, we can calculate all the factorials with the powers of MOD cast out. For example, if MOD = 3 and N = 11, we would calculate the product 1 * 2 * 3 / 3 * 4 * 5 * (6 / 3) * 7 * 8 * (9 / 9) * 10 * 11. This can be done easily in O(MOD). Once we have that, we can multiply the values in the numerator and mltiply with the mo

@jeremiahbiard
jeremiahbiard / polygons2
Last active August 29, 2015 14:25
More polygons
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <map>
using namespace std;
long long degree(long long a, long long k, long long p) {
@jeremiahbiard
jeremiahbiard / polygons.cpp
Created July 17, 2015 23:05
polygons solution
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <map>
using namespace std;
long long degree(long long a, long long k, long long p) {
Beginner: Linked List, Stack, Queue, Binary Search Tree.
Intermediate: Heap, Priority Queue, Huffman Tree, Union Find, Tries, Hash Table, Tree Map.
Proficient: Segment Tree, Binary Indexed Tree, Suffix Array, Sparse Table, Lowest Common Ancestor, Range Tree.
Expert: Suffix Automaton, Suffix Tree, Heavy-Light Decomposition, Treap, Aho-Corasick, K-d tree, Link-Cut Tree, Splay Tree, Palindromic Tree, Rope, Dancing Links, Radix Tree, Dynamic Suffix Array.
int fast_pow(long long base, long long n,long long M)
{
if(n==0)
return 1;
if(n==1)
return base;
long long halfn=fast_pow(base,n/2,M);
if(n%2==0)
return ( halfn * halfn ) % M;
else