Skip to content

Instantly share code, notes, and snippets.

#helper function to estimate long/lat range based on long/lat and range in km
def calc_longlat_range(longitude, latitude, range_km):
from math import cos, radians, pi
r = 6370
alpha = radians(latitude)
circum = 2 * pi * cos(alpha) * r
km_per_long = circum / 360
km_per_lat = pi * r / 180
@jliu90
jliu90 / post_order.py
Last active August 29, 2015 14:02
convert in-order and pre-order tree presentation to post-order
#test cases
in_order_1 = "ABCDEFG"
pre_order_1 = "DBACEGF"
post_order_1 = "ACBFGED"
in_order_2 = "CBAD"
pre_order_2 = "BCAD"
post_order_2 = "CDAB"
def convert(in_order, pre_order):