Skip to content

Instantly share code, notes, and snippets.

View aishraj's full-sized avatar

Aish aishraj

View GitHub Profile
@evandrix
evandrix / solution.py
Created July 29, 2011 22:33
Dropbox Challenge - 1 Packing Your Dropbox
#!/usr/bin/python
"""
Amar Pai (jcruelty@gmail.com)
Solution to Dropbox challenge - Packing Your Dropbox
http://www.dropbox.com/jobs/challenges#packing-your-dropbox
I've had this problem on the brain and have been unable to
stop thinking about it, so I finally hacked out a rudimentary
@pilate
pilate / DataTableToCSV.js
Created December 14, 2011 16:43
Convert instance of 'google.visualization.DataTable' to CSV
/**
* Convert an instance of google.visualization.DataTable to CSV
* @param {google.visualization.DataTable} dataTable_arg DataTable to convert
* @return {String} Converted CSV String
*/
function dataTableToCSV(dataTable_arg) {
var dt_cols = dataTable_arg.getNumberOfColumns();
var dt_rows = dataTable_arg.getNumberOfRows();
var csv_cols = [];
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu
@phaniram
phaniram / Solution.java
Created December 29, 2011 22:41
Interview Street Challenges - String similarity
package com.interviewstreet.puzzles;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scanner;
Solution sr = new Solution();
scanner = new Scanner(System.in);
int no_cases = scanner.nextInt();
for (int i = 0; i < no_cases; i++) {
@aishraj
aishraj / Hint.md
Created January 8, 2012 11:48 — forked from lizzin/Hint.md
Repair Roads Solution (InterviewStreet CodeSprint Fall 2011)

The line graph of a graph G is a graph having the edges of G as it's nodes and edges between them if the corresponding edges in G are adjacent. The Hamiltonian Completion Number is the minimum number of edges to be added to a graph for it to have a Hamiltonian Cycle.

Formally, the problem can be stated as asking for the Hamiltonian Completion Number of the line graph of a tree. While this problem is NP-Complete for the general case, it is in fact solvable in polynomial (linear actually) time for trees. Again, I do not have a simple algorithm, or a proof of why the algorithm works. Feel free to look at solutions or read up more about the problem online. See: http://en.wikipedia.org/wiki/Hamiltonian_completion http://www.sciencedirect.com/science/article/pii/S0020019000001642

Note that the caterpiller trees discussed above are precisely the trees for which the Hamiltonian Completion Number of their line graphs is 0.

import sys
def negVector(lst):
return [-x for x in lst]
def addVectors(l1, l2):
return [l1[i] + l2[i] for i in range(len(l1))]
def multVectors(l1, l2):
return [l1[i] * l2[i] for i in range(len(l1))]
@jboner
jboner / latency.txt
Last active June 27, 2024 14:47
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@aishraj
aishraj / dotsandboxes.cc
Created June 9, 2012 13:27 — forked from rvivek/dotsandboxes.cc
Dots and Boxes
#include<iostream>
using namespace std;
#define odd(x) (x&1)
#define even(x) (!(x&1))
int main(){
int x;
cin >> x;
@msg555
msg555 / gangnam.py
Created January 27, 2013 21:21
Create plots from discrete set of points. It's set to connect the first and last point together, currently.
#!/usr/bin/python
#
# Example usage
# $ ./gangnam.py | gnuplot
# 9
# 0 0
# 1 1
# 2 2
# 0 2
# 1 1
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active June 13, 2024 10:59
A badass list of frontend development resources I collected over time.