Skip to content

Instantly share code, notes, and snippets.

View hmthanh's full-sized avatar
🐤
...

Thanh Hoang-Minh hmthanh

🐤
...
View GitHub Profile
@hmthanh
hmthanh / chain_responsibility_example.py
Created August 14, 2021 08:43
Chain Responsibility Design Pattern Example in Python
# Chain Responsibility Design Pattern Example in Python
from abc import abstractmethod
class LeaveRequest:
def __init__(self, date: int):
self.date = date
def get(self) -> int:
return self.date

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@hmthanh
hmthanh / cloudSettings
Last active February 6, 2020 07:49
Thuật toán FloyWarshall[Full]
{"lastUpload":"2020-02-06T07:49:37.695Z","extensionVersion":"v3.4.3"}
@hmthanh
hmthanh / printPath.cpp
Created April 16, 2019 07:31
Thuật toán FloyWarshall
vector<int> pathS2E = vector<int>();
while (start != end){
pathS2E.push_back(end);
end = path[start][end];
}
pathS2E.push_back(start);
for (vector<int>::iterator i = pathS2E.end(); i != pathS2E.begin(); i--)
{
cout << *(i-1) << " ";
}
@hmthanh
hmthanh / FloyWarshall.cpp
Created April 16, 2019 07:17
Thuật toán FloyWarshall
for (int k = 0; k < length; k++) {
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
if (dist[i][j] > dist[i][k] + dist[k][j]) {
dist[i][j] = dist[i][k] + dist[k][j];
path[i][j] = path[k][j];
}
}
}
}
@hmthanh
hmthanh / createDist.cpp
Last active April 16, 2019 06:58
Thuật toán FloyWarshall
path = vector<vector<int>>(length, vector<int>(length));
dist = vector<vector<int>>(length, vector<int>(length));
for (int i = 0; i < length; i++) {
for (int j = 0; j < length; j++) {
dist[i][j] = graph[i][j];
if (graph[i][j] != INF && i != j) {
path[i][j] = i;
}
else {
path[i][j] = -1;
@hmthanh
hmthanh / createGrapt.cpp
Last active April 16, 2019 06:34
Thuật toán FloyWarshall
graph = vector<vector<int>>(length, vector<int>(length));
for (int i = 0; i < length; i++){
for (int j = 0; j < length; j++){
file >> temp;
if (temp == 0 && i != j) {
graph[i][j] = INF;
}
else {
graph[i][j] = temp;
}