Skip to content

Instantly share code, notes, and snippets.

View mdsrosa's full-sized avatar

Matheus Rosa mdsrosa

View GitHub Profile
@mdsrosa
mdsrosa / dijkstra.py
Last active April 14, 2016 20:32 — forked from econchick/gist:4666413
Python implementation of Dijkstra's Algorithm
class Graph:
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
self.nodes.add(value)
def add_edge(self, from_node, to_node, distance):
@mdsrosa
mdsrosa / dijkstra.py
Created November 21, 2015 04:36
Modified Python implementation of Dijkstra's Algorithm (https://gist.github.com/econchick/4666413)
from collections import defaultdict, deque
class Graph(object):
def __init__(self):
self.nodes = set()
self.edges = defaultdict(list)
self.distances = {}
def add_node(self, value):
@mdsrosa
mdsrosa / date_challenge.py
Created October 28, 2015 14:50
Add minutes to a date and subtract minutes from a date without using any Python library
import sys
def sum_minutes_to_date(str_date, minutes):
date, hour = str_date.split(' ')
day, month, year = date.split('/')
day = int(day)
month_start_with_0 = False
if month.startswith('0'): month_start_with_0 = True
month = int(month)