Skip to content

Instantly share code, notes, and snippets.

View aishraj's full-sized avatar

Aish aishraj

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>runner</title>
<!-- WinJS references -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
(function () {
"use strict";
var nav = WinJS.Navigation;
function pin() {
// This demo code comes from
// http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.startscreen.secondarytile.aspx
// Prepare package images for use as the Tile Logo and Small Logo in our tile to be pinned.
ping www.google.com
PING www.google.com (173.194.38.178) 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
236 packets transmitted, 0 received, 100% packet loss, time 236880ms
$ ping api.nodejitsu.com
PING api.nodejitsu.com (165.225.130.178) 56(84) bytes of data.
^C
@aishraj
aishraj / rsa.c
Created November 4, 2012 06:24
RSA using gmp
/**********************************************************************
* *
* Created by Adam Brockett *
* *
* Copyright (c) 2010 *
* *
* Redistribution and use in source and binary forms, with or without *
* modification is allowed. *
* *
* But if you let me know you're using my code, that would be freaking*
@aishraj
aishraj / dynamic_alloc_reverse.c
Created November 2, 2012 10:49 — forked from jvranish/dynamic_alloc_reverse.c
Dynamic Allocation without malloc in C (with no mutation!)
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
/*
This is our integer linked list type (Null is an empty list)
(it is immutable, note the consts)
*/
typedef struct IntList_s const * const IntList;
@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;
@aishraj
aishraj / showHttp.cpp
Created May 26, 2012 02:17
The changed version of the file
#include "showHttp.h"
#include <kdebug.h>
showHttp::showHttp()
{
output();
}
showHttp::~showHttp()
{}
@aishraj
aishraj / Hint.md
Created January 8, 2012 11:49 — forked from lizzin/Hint.md
2's Compliment Solution (InterviewStreet CodeSprint Fall 2011)

The number of 1's in the range 0..X (X is positive) is easy to calculate (Can you get a simple recurrence which does this in O(log X) ?) Another observation is that the number of 1's in -X is equal to the number of 0's in ~(-X) = X - 1. Using this, it is easy to calculate the answer for negative ranges as well.

@aishraj
aishraj / Hint.md
Created January 8, 2012 11:49 — forked from lizzin/Hint.md
Insertion Sort Solutions (InterviewStreet CodeSprint Fall 2011)

The answer is the number of inversions in the array, which is the number of pairs i,j such that i < j and a[i] > a[j]. Counting this is a fairly classical problem with many solutions such as using data structures such as Balanced Trees or Binary Indexed Trees. Another particularly elegant solution involves modifying merge sort to count the number of inversions when merging the two sorted halves in the algorithm.

@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.