Skip to content

Instantly share code, notes, and snippets.

View KartikTalwar's full-sized avatar
🚀
Gone phishing

Kartik Talwar KartikTalwar

🚀
Gone phishing
View GitHub Profile
@KartikTalwar
KartikTalwar / GreedyCoin.py
Created July 28, 2012 00:07
Simple Greedy Coin Algorithm
def bestChange(denominations, amount):
if amount == 0:
return []
for i in denominations:
if i <= amount:
return [i] + bestChange(denominations, amount-i)
denominations = [100, 50, 20, 10, 5, 2, 1]
amount = 109
@KartikTalwar
KartikTalwar / GooglePageRankCheckSum.php
Created August 2, 2012 22:34
Google PageRank Checksum Algorithm
<?php
function fch($csm)
{
if($csm < 0)
$csm += 4294967296.0;
$a = (int)fmod($csm, 10);
$t = 1;
$b = (int)($csm / 10);
@KartikTalwar
KartikTalwar / phptest.xml
Created August 18, 2012 20:02
PHP Lib Test
<?xml version="1.0" encoding="UTF-8"?>
<test>
<case>42</case>
</test>
@KartikTalwar
KartikTalwar / TwitterCheck.php
Created August 18, 2012 20:24
Twitter Followers Prereq Check
<?php
/*
Usage:
@KartikTalwar
KartikTalwar / prof.php
Created October 16, 2012 16:32
API Prof
<?php
$url = 'http://api.uwaterloo.ca/public/v1/?';
$url .= 'key=&service=staffinfo&q='.$q[0];
$get = file_get_contents($url);
$json = json_decode($get);
$data['name'] = $json->response->data->Name;
$data['dept'] = $json->response->data->Department;
@KartikTalwar
KartikTalwar / APIPub.php
Created October 25, 2012 17:30
API Dissertation
<?php
$url = 'http://api.uwaterloo.ca/public/v1/?key=apikey&';
$url .= 'service=publicationdetails&q='.$_GET['q'];
$get = json_decode(file_get_contents($url))->response->data;
$data['title'] = $get->Title;
$data['authors'] = $get->Authors;
$data['approved'] = $get->Approved;
$data['abstract'] = $get->Abstract;
import itertools
possible = ['1', '2', '3', '4', '5']
doubles = []
brute = []
def stringPermutations(string):
rez = []
@KartikTalwar
KartikTalwar / SeasonsGreetings.md
Created December 26, 2012 20:27
Merry Christmas

Seasons Greetings

$$ y = \frac{ln(\frac{x}{m} - sa)}{r^2} $$

$$ yr^2 = ln(\frac{x}{m} - sa) $$

@KartikTalwar
KartikTalwar / g2s.txt
Created January 13, 2013 01:49
Grooveshark to Spotify Test
Grooveshark: Help, I'm Alive Metric
Spotify: Help I'm Alive Metric
spotify:track:3GcH8qkC35CQc4xt6Dhz1r
Grooveshark: Never Gonna Leave This Bed Maroon 5
Spotify: Never Gonna Leave This Bed Maroon 5
spotify:track:4ucLHLiSjvkCz5Lr5dlVUj
@KartikTalwar
KartikTalwar / FBHackerCupBeautifulStrings.py
Created January 27, 2013 08:25
Facebook HackerCup - Beautiful Strings
"""
Beautiful Strings
When John was a little kid he didn't have much to do. There was no internet, no Facebook,
and no programs to hack on. So he did the only thing he could... he evaluated the beauty
of strings in a quest to discover the most beautiful string in the world.
Given a string s, little Johnny defined the beauty of the string as the sum of the beauty
of the letters in it.