Things that we will be touching on this session
- React.js front end
- React Material Design
- Node.js & Express.js REST API
import React from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
Animated, | |
Easing | |
} from 'react-native'; |
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} | |
} |
class Routes: | |
def __init__(self, routesTable={}): | |
# the routesTable is our hash map DT | |
self.routesTable = routesTable |
def distanceBetween(self, cities=[]): | |
""" | |
Calculates distance of the route | |
Args: | |
cities (str[]): The array of cities | |
Returns: | |
int: calclated distance | |
""" |
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 |
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 |
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 |
const getApple = () => { | |
setTimeout(() => { | |
return { "name": "Macintosh" } | |
}, 2000); | |
}; | |
const myApple = getApple(); | |
console.log(myApple.name); |
const getApple = (b) => { | |
setTimeout(() => { | |
b({name: 'Macintosh'}); | |
}, 2000); | |
}; | |
getApple((apple) => { | |
console.log(apple.name); | |
}) |