Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SumuduF's full-sized avatar

Sumudu Fernando SumuduF

View GitHub Profile
@SumuduF
SumuduF / cake_cutting.py
Last active December 12, 2015 08:59
Solutions for Facebook Hacker Cup Round 2 I got stuck on problem 2 during the actual round due to a bit of a nasty off-by-one error (fixed below); in retrospect it would have been better to try #3 to have a chance at qualifying. Added solution to problem #3; essentially a standard DP on a tree + a bit of cleverness to ensure proper counting. Dur…
import sys
def main():
for (i, (n, a)) in enumerate(testcases()):
print "Case #{0}: {1}".format(i+1, regions(n, a))
def testcases(cin=sys.stdin):
nc = int(cin.next())
for _ in xrange(nc):
nums = map(int, cin.next().split())
@SumuduF
SumuduF / card_game.py
Created February 3, 2013 21:30
Solutions for Facebook Hacker Cup 2013 / Round 1 No explanations for now...
import sys
MOD = 1000000007
def main():
for (i, (n, k, cards)) in enumerate(testcases()):
print "Case #{0}: {1}".format(i+1, subsum(n, k, cards))
def testcases(cin=sys.stdin):
m = int(cin.next())