This file contains hidden or 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
def calculate_earth_velocity_from_plain(v_plain, t_plain, t_diff, is_invert): | |
total_distance = v_plain * t_plain | |
return total_distance / ([t_diff, 24 - t_diff][int(is_invert)]) | |
# Wenzhe's input | |
print calculate_earth_velocity_from_plain(950.0, 14, 15, true) |
This file contains hidden or 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
#! /usr/bin/env python | |
import token | |
import symbol | |
def ast2symbol(ast): | |
if len(ast) < 2: | |
if type(ast) is type(""): | |
return ast | |
else: |
This file contains hidden or 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
def stringReceived(self, shortUrl): | |
self.transport.loseConnection() | |
self.downloadVideoFromShortUrl(shortUrl) | |
def downloadVideoFromShortUrl(self, shortUrl): | |
try: | |
url = transformShortUrl(shortUrl) | |
video = downloadVideoFromUrl(url) | |
storeVideo(video) | |
except BaseException, e: |
This file contains hidden or 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
// The output from the program compiled under gcc 3.4.4 | |
// sizeof Base: 8 | |
// sizeof Derived: 12 | |
// sizeof AnotherBase: 8 | |
// sizeof AnotherDerived: 20 | |
// And you can run the program to get the log.txt to check its content | |
// ========================================================= | |
// | |
// The inheritance relationship is as follow: | |
// class Base; |
This file contains hidden or 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
class Node: | |
def __init__(self): | |
self.left_child = None | |
self.right_child = None | |
self.num = 0 | |
def max_node(tree): | |
return visit(tree)[1] |
This file contains hidden or 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
#! /usr/bin/env python | |
# num is a integer >= 0 | |
# return a list containing the digits in base | |
# the digits are ordered from lower bits to higher bits | |
def convert_to_based_num(num, base): | |
digits = [] | |
while num > 0: | |
quotient, remainder = num / base, num % base | |
digits.append(remainder) |
This file contains hidden or 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
#include <iostream> | |
#include <cstdlib> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
using namespace std; | |
int main(int argc, char *argv[]) |
This file contains hidden or 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
class MinStack(object): | |
""" Simulate the normal stack operations while | |
providing getting minimum with O(1) complexitiy | |
""" | |
def __init__(self): | |
self.__stack = [] | |
self.__min_stack = [] | |
def push(self, n): |
This file contains hidden or 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
def least_positive(nums): | |
length = len(nums) | |
is_valid = lambda e: 0 < e <= length | |
def swap(i, j): | |
nums[i], nums[j] = nums[j], nums[i] | |
i = 0 | |
while i < length: | |
e = nums[i] |
This file contains hidden or 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
#include <string> | |
#include <iostream> | |
#include "llvm/Config/config.h" | |
#include "llvm/ADT/IntrusiveRefCntPtr.h" | |
#include "clang/Basic/Diagnostic.h" | |
#include "clang/Basic/TargetOptions.h" | |
#include "clang/Basic/TargetInfo.h" | |
#include "clang/Basic/SourceManager.h" |
OlderNewer