Skip to content

Instantly share code, notes, and snippets.

View MathisHammel's full-sized avatar

Mathis HAMMEL MathisHammel

View GitHub Profile
def maxsubarr(arr):
h=len(arr)
w=len(arr[0])
bestsum=arr[0][0]
bestcoords=None
for lbeg in range(h):
for cbeg in range(w):
@MathisHammel
MathisHammel / directoryTrie.py
Created January 5, 2017 03:16
Simple implementation of a trie to show phone number autocompletion
class Trie:
def __init__(self):
self.children={}
self.label=None
def findall(self):
matches=set()
if self.label!=None:
matches.add(self.label)
for child in self.children:
Port-Vendres
Roscoff
Toulouse-Matabiau
Sarreguemines
Lyon-Part-Dieu
Romorantin-Blanc-Argent
Veynes-Dévoluy
Calais Ville
Lannion
Hazebrouck
Strasbourg
Lille Flandres
Lyon-Part-Dieu
Nancy-Ville
Marseille-St-Charles
Bordeaux-St-Jean
Toulouse-Matabiau
Nantes
Rennes
Lyon-Perrache
Strasbourg
Lille Flandres
Lyon-Perrache
Marseille-St-Charles
Metz-Ville
Bordeaux-St-Jean
Toulouse-Matabiau
Avignon-Centre
Nantes
Mulhouse
MiT
Smoked Chicken
Leet More
Hates Irony
sutegoma2
lollersk8ers
European Nopsled Team
Routards
Plaid Parliament of Pwning
Shellphish
participants = '''@Greglimo1
@maxencedevigne
@z3gh0st
@4quatre4quatre
@YavuzSonmez_
@Tek_7987
@Maskott6
@corsicajack
@SmxPlayer
@le_jop
import requests
from aoc_secrets import AOC_COOKIE
YEAR = '2016'
def get_input(day):
req = requests.get(f'https://adventofcode.com/{YEAR}/day/{day}/input', headers={'cookie':'session='+AOC_COOKIE})
return req.text
def get_example(day,offset=0):
'''
Advent of Code automation template - @MathisHammel
This template provides functions to download inputs and submit answers on AoC.
You need to paste your adventofcode.com session cookie below.
If you don't know how to get this cookie, here's a quick tutorial:
- Open your browser and go to adventofcode.com, make sure you are logged in
- Open the developer console (Ctrl+Shift+I on Firefox/Chrome)
- Get the value of your session cookie:
participants = '''@the_duf_
@driikolu
@Tashiqi
@PontyGuillaume
@MrAdrien79
@Nicoverflow
@dourojp
@Durab_
@Femtozer
@C_Papazian