Skip to content

Instantly share code, notes, and snippets.

View supritashankar's full-sized avatar
🙃

Suprita Shankar supritashankar

🙃
  • San Francisco
View GitHub Profile
@supritashankar
supritashankar / lists-mindblown.py
Created June 16, 2016 07:11
Find the bug in this program?!
"""
Find all possible combinations of k numbers that add up to a number n,
given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.
For example: if n = 7 k = 3
ans [1,2,4]
k = 3 n = 9
[[1,2,6], [1,3,5], [2,3,4]]
"""
To Watch
- The Room
- Brooklyn
- There's no tomorrow
- True Cost
- Ghetto Physics
- Garbage warriors
- P Sainath Corporate hijack of Indian agriculture
Watched
@supritashankar
supritashankar / meeting.java
Created February 12, 2016 19:01
MeetingInvite
class Event {
int start;
int end;
}
class myE {
int isStart;
int time;
}
void maxparticipants(event[] events){
@supritashankar
supritashankar / meeting.py
Created February 11, 2016 01:54
Meeting Calendar problem with sets
timeline = {
'1': set([0,1,2,3,4]),
'2': set([3,4,5,6,7]),
'3': set([2,3,4])}
def get_meeting_time(timeline):
"""
get intersection of all the person
"""
'use strict';
module.exports = function mochacli(grunt) {
// Load task
grunt.loadNpmTasks('grunt-mocha-cli');
// Options
return {
src: ['test/unit/**/*.js'],
"""
Buckets Robo problem
Attempt #1
"""
begin = -1;
end = len(no_of_buckets);
loc = 0;
while (loc<end) {
switch (color) {
@supritashankar
supritashankar / reversal-string
Created May 16, 2014 01:02
Best way to reverse a string in python!
def reverse(_string):
return ''.join(reversed(_string))
def is_valid(grid):
if len(grid)!=81:
return False
for a in grid:
val = int(a)
if type(val)!= int or val == 0:
return False
k = 0
puzzle = [[0 for x in xrange(9)] for x in xrange(9)]
class Info:
def __init__(self, index, name):
self.name = name
self.index = index
def __repr__(self):
return repr((self.name, self.index))
inf1 = Info(2, "two")
inf2 = Info(1, "one")
inf3 = Info(-1, "Minus-one")
@supritashankar
supritashankar / leibniz.py
Created February 3, 2013 04:36
Leibniz formula for pi
from decimal import *
getcontext().prec = 15
t=[]
for i in range(int(raw_input())):
t.append(raw_input())
for i in range(len(t)):
o=t[i]
l=[]
for j in range(int(o)):
p=Decimal((2*j) + 1)