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
# This program rely on the following python SDK for sina | |
# https://github.com/michaelliao/sinaweibopy | |
from weibo import APIClient | |
APP_KEY = '1234567' # app key | |
APP_SECRET = 'abcdefghijklmn' # app secret | |
CALLBACK_URL = 'http://www.example.com/callback' # callback url | |
client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=CALLBACK_URL) | |
url = client.get_authorize_url() |
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
def mark_component(G, node, marked): | |
marked[node] = True | |
total_marked = 1 | |
for neighbor in G[node]: | |
if neighbor not in marked: | |
total_marked += mark_component(G, neighbor, marked) | |
return total_marked | |
def check_connection(G, v1, v2): | |
# Return True if v1 is connected to v2 in G |
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
# This is an algorithm that people actually implemented by hand before | |
# there were computers. Here's the Russian Peasants Algorithm in Python. | |
# | |
def russian(a, b): | |
x = a | |
y = b | |
z = 0 | |
while x > 0: |
NewerOlder