This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## 1. abs(x)\n", | |
"**Abs(x)** trả về trị tuyệt đối của số **x**\n", | |
"\n", | |
"**x** có thể là số thực (**float**), số nguyên (**int**) hoặc số phức\n", |
This file contains hidden or 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 __future__ import division | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
from datetime import timedelta | |
%matplotlib inline | |
SLEEP_INTERVAL = 5 # minutes | |
# https://www.timeanddate.com/sun/singapore/singapore?month=4&year=2018 |
This file contains hidden or 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 __future__ import division | |
import random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import imageio | |
import os | |
%matplotlib inline | |
M, P, N = 2, 3, 5 | |
A = np.random.randint(0, 2, (M, P)) |
This file contains hidden or 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
fig = plt.figure() | |
ax = fig.add_subplot(121) | |
img = plt.imread("SingaporeMap.PNG") | |
ax.imshow(img, extent=[103.6052, 104.0402, 1.2194, 1.4844]) | |
df2 = bus_route_df[bus_route_df.high_freq == False] | |
for k, g in df2.groupby('ServiceNo'): | |
lats = g.sort_values('StopSequence').Latitude.astype(float).values | |
lons = g.sort_values('StopSequence').Longitude.astype(float).values | |
ax.plot(lons, lats, 'g.') | |
# fig.set_size_inches(10, 10) |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
<html xmlns="http://www.w3.org/1999/html"> | |
<head> | |
<title>Hanoi Bus</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" /> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<style> |
This file contains hidden or 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
{"Code": "01", "Name": "Bến xe Gia Lâm - Bến xe Yên Nghĩa", "BusCount": "17", "CostInt": 7000, "Re": {"Geo": [{"Lat": 20.949815363511114, "Lng": 105.7474014011193}, {"Lat": 20.949536103496577, "Lng": 105.74697938028726}, {"Lat": 20.949430289518443, "Lng": 105.74691320915804}, {"Lat": 20.949306941115392, "Lng": 105.74690336441802}, {"Lat": 20.949209, "Lng": 105.74689999999998}, {"Lat": 20.949081, "Lng": 105.74690199999998}, {"Lat": 20.949081, "Lng": 105.74690199999998}, {"Lat": 20.949081, "Lng": 105.74690199999998}, {"Lat": 20.948864, "Lng": 105.74703499999998}, {"Lat": 20.948864, "Lng": 105.74703499999998}, {"Lat": 20.948864, "Lng": 105.74703499999998}, {"Lat": 20.951095, "Lng": 105.74997899999994}, {"Lat": 20.95135, "Lng": 105.75032299999998}, {"Lat": 20.951478, "Lng": 105.750494}, {"Lat": 20.951478, "Lng": 105.750494}, {"Lat": 20.951478, "Lng": 105.750494}, {"Lat": 20.955489, "Lng": 105.75580000000002}, {"Lat": 20.95581, "Lng": 105.75625600000001}, {"Lat": 20.956422, "Lng": 105.75717400000008}, {"Lat": 20.9 |
This file contains hidden or 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
BusStopCode | Direction | Latitude | Longitude | ServiceNo | ||
---|---|---|---|---|---|---|
0 | 1668 | 1 | 21.031915 | 105.851948 | 09 | |
1 | 340 | 1 | 21.0284166666667 | 105.851166666667 | 09 | |
2 | 32 | 1 | 21.02505 | 105.851416666667 | 09 | |
3 | 33 | 1 | 21.0220333333333 | 105.8504 | 09 | |
4 | 34 | 1 | 21.0192 | 105.849416666667 | 09 | |
5 | 768 | 1 | 21.017288 | 105.845721 | 09 | |
6 | 253 | 1 | 21.019127 | 105.837982 | 09 | |
7 | 254 | 1 | 21.019363 | 105.834084 | 09 | |
8 | 520 | 1 | 21.01581 | 105.828275 | 09 |
This file contains hidden or 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
<html> | |
<head> | |
<title>Leaflet</title> | |
<meta charset="utf-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" /> |
This file contains hidden or 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
g = {1: [2, 3], 2: [4, 5], 3: [6, 7], 6: [7], 7: [9]} | |
arr = [1] | |
visited = [1] | |
while arr: | |
n = arr[0] | |
if n not in g.keys(): | |
print arr | |
arr.pop(0) | |
else: |
This file contains hidden or 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
#https://leetcode.com/problems/island-perimeter/description/ | |
class Solution(object): | |
def islandPerimeter(self, grid): | |
""" | |
:type grid: List[List[int]] | |
:rtype: int | |
""" | |
return sum(sum(map(operator.ne, [0] + row, row + [0])) | |
for row in grid + map(list, zip(*grid))) |
NewerOlder