Skip to content

Instantly share code, notes, and snippets.

@niroyb
niroyb / note_seuil.py
Last active January 3, 2016 04:59
Analyse du fichier des résultats d'un cours à l'École Polytechnique de Montréal pour déterminer les seuils de chaque note. Idée de EtiDuc : https://github.com/EtiDuc/poly-seuils-notes
'''Groupe les notes et permet de trouver les seuils'''
import re
from collections import defaultdict
with open('Resultat.txt') as f:
text = f.read()
matches = re.findall('((?:[A-F])(?:\*|\+|\s))\s*\|\s*([0-9.]+)', text)
print len(matches), 'notes :'
@niroyb
niroyb / UnionFind.hpp
Last active December 16, 2015 12:09
Template class disjoint-set data structure usefull for Kruskal's algorithm. A Disjoint-set data structure is a data structure that keeps track of a set of elements partitioned into a number of disjoint (nonoverlapping) subsets. A union-find algorithm is an algorithm that performs two useful operations on such a data structure: Find: Determine wh…
#pragma once
// @author Nicolas Roy @niroyb
// @date 2013-04-22
// Disjoint set data structure aka unionfind
// Time complexity of log(n) for all operations because of map.find()
#include <map>
template<class verticeType>
@niroyb
niroyb / IncreasingCostMST_Generator.py
Last active March 23, 2023 10:07
Searches a graph and yields all the minimum spanning trees in order of increasing cost. This could be used to solve minimum spanning trees with constraints by yielding trees until we reach the first one which satisfies a constraint. For example it could solve the degree constrained minimum spanning tree DCMST
#!/Usr/bin/env python
# -*- coding: utf-8 -*-
'''
Searches a graph and yields all the minimum spanning trees in order of increasing cost.
This could be used to solve minimum spanning trees with constraints by yielding trees until
we reach the first one which satisfies a constraint.
For example it could solve the degree constrained minimum spanning tree DCMST
'''