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
import React from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
Animated, | |
Easing | |
} from 'react-native'; |
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 routes import Routes | |
# Graph: AB5, BC4, CD8, DC8, DE6, AD5, CE2, EB3, AE7 | |
graph = { | |
'A': {'B': 5, 'D': 5, 'E': 7 }, | |
'B': {'C': 4}, | |
'C': {'D': 8, 'E': 2}, | |
'D': {'C': 8, 'E': 6}, | |
'E': {'B': 3} | |
} |
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
class Routes: | |
def __init__(self, routesTable={}): | |
# the routesTable is our hash map DT | |
self.routesTable = routesTable |
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 distanceBetween(self, cities=[]): | |
""" | |
Calculates distance of the route | |
Args: | |
cities (str[]): The array of cities | |
Returns: | |
int: calclated distance | |
""" |
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 numStops(self, start, end, maxStops): | |
""" | |
Wrapper function to calculate the number of stops | |
Args: | |
start (str): Starting city | |
end (str): Destination city | |
maxStops (int): number of maximum stops allows | |
Returns: | |
int: calclated number of routes |
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 findPathWithExactStops(self, start, finish, exact): | |
""" | |
Wrapper function to calculate the path with exact number of stops | |
Args: | |
start (str): Starting city | |
end (str): Destination city | |
maxDistance (int): exact number of stops | |
Returns: | |
int: number of routes |
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 findShortestRoute(self, start, end , weight, shortestRoute, visited=[]): | |
""" | |
Recursive function to calculate the shortest route | |
Args: | |
start (str): Starting city | |
end (str): Destination city | |
weight (weight): weight of the route | |
shortestRoute (int): shortest path so far | |
visited (str[]): array of visited nodes |
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
const getApple = () => { | |
setTimeout(() => { | |
return { "name": "Macintosh" } | |
}, 2000); | |
}; | |
const myApple = getApple(); | |
console.log(myApple.name); |
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
const getApple = (b) => { | |
setTimeout(() => { | |
b({name: 'Macintosh'}); | |
}, 2000); | |
}; | |
getApple((apple) => { | |
console.log(apple.name); | |
}) |
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
const bt = document.querySelector("button"); | |
const result = document.getElementById("k") | |
const firstCallBack = callBack => { | |
result.textContent = "First callback loading"; | |
setTimeout(() => { | |
callBack(true); | |
}, 2000); | |
}; |
OlderNewer