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
/* | |
* The function flattens an arbitrarily nested array of k-dimensions using recursion. | |
* The implementation is quite fast (i.e. O(n) where n is the total number of | |
* elements in the k-th dimensional array where k >= 1). | |
* However stack overflow errors could occur in cases where k is particularly large - | |
* thus requiring a very deep level of recursion. | |
* | |
* @param {number[][]} - A k-dimensional array where k >= 1 | |
* @returns {number[]} - A 1-dimensional flattened array | |
*/ |
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 fib(int n): | |
cdef int i | |
cdef double a=0.0, b=1.0 | |
for i in range(n): | |
a, b = a+b, a | |
return 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
# This is the class definition | |
class House(object): | |
def __init__(self, address, longitude, latitude): # This is the constructor | |
self.address = address | |
self.longitude = longitude | |
self.latitude = latitude | |
def get_house_position(self): | |
return "<House @ (%, %)>".format(self.longitude, self.latitude) | |