This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gcj_context import in_out, test_in_out | |
def solve_test_case(data): | |
stuff = next(data) | |
return "my_answer_from_stuff" | |
def main(): | |
#with test_in_out() as (in_file, out_file): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'robert' | |
""" | |
Implementation inspired by Petr Mitrichev's blog post http://petr-mitrichev.blogspot.co.nz/2013/05/fenwick-tree-range-updates.html | |
and | |
Yoshiya Miyata's Quora answer http://qr.ae/pHhNN | |
""" | |
class Bit: | |
def __init__(self, n): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bisect import bisect_left | |
__author__ = 'Robert' | |
""" | |
Fizz Buzz and Zing on multiples of two, three and five. | |
Find the 1000th number that doesn't have a Fizz, Buzz or Zing. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = "google.com/+robertking" | |
""" | |
One of my favorite code jam problems. | |
solution to the Treasure problem from google code jam 2013: | |
https://code.google.com/codejam/contest/dashboard?c=2270488#s=p3 | |
""" | |
from sys import stdin | |
from collections import Counter, defaultdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//google.com/+robertking | |
//One of my favorite code jam problems. | |
//solution to the Treasure problem from google code jam 2013: | |
//https://code.google.com/codejam/contest/dashboard?c=2270488#s=p3 | |
//also wrote a solution in python: https://gist.github.com/robert-king/11139975 | |
package main | |
import ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
) | |
//google.com/+robertking | |
//fastest go solutions: | |
//http://www.codechef.com/status/TSORT?sort_by=Time&sorting_order=asc&language=114&status=15&handle=&Submit=GO | |
//(It's 3.8x slower than C & C++. Slightly faster than Java.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package trie | |
import ( | |
"appengine/datastore" | |
"appengine" | |
"encoding/gob" | |
"bytes" | |
) | |
//@robertkingNZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in this example we don't need Math.floor, we just check i < j | |
function isPalindrome(phrase){ | |
alpha = []; | |
for (var char of phrase.toLowerCase()) { | |
if ('a' <= char && 'z' >= char) { | |
alpha.push(char); | |
} | |
} | |
phrase = alpha.join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# given matrix of servers, servers connect to servers in their row or column. 'C' denotes a server computer. | |
# shutdown the servers in an order such that shutdown servers pass their data on to nearby servers, such that | |
# the minimum number of servers need to stay on. | |
# author: @robertkingnz | |
def make(): | |
M = [] | |
rows = 10 | |
cols = 20 |
OlderNewer