Skip to content

Instantly share code, notes, and snippets.

View MathisHammel's full-sized avatar

Mathis HAMMEL MathisHammel

View GitHub Profile
# Advent of Code template by @MathisHammel
# TODO
# - Make a snapshot of the file when a submission is correct
# - Display the rank when submission is accepted
# - Utility function to rotate/flip a 2D array
# - Cycle length detector/extrapolator to make loops faster
# - Put examples in cache
# - Warning if DAY is not the current day
import pygame # pip install pygame-ce
import random
from pygame import gfxdraw
FPS = 60
fpsClock = pygame.time.Clock()
WINDOW_WIDTH = 600
WINDOW_HEIGHT = 800
BOX_OFFSET_TOP = 100
# License : do anything you want except NFTs (fuck NFTs)
from PIL import Image
BASE_FILENAME = 'hokusai.jpeg' # 'pxfuel.jpg'
SIZE = 10 #43.3
SCAN_SIZE = 10 # 5
FLOAT_PRECISION = 4
hex_h = SIZE * (3 ** 0.5)
# Advent of Code template by @MathisHammel
import requests
from aoc_secrets import AOC_COOKIE # Put your session cookie in this variable
YEAR = '2022'
def get_input(day):
req = requests.get(f'https://adventofcode.com/{YEAR}/day/{day}/input', headers={'cookie':'session='+AOC_COOKIE})
return req.text
@MathisHammel
MathisHammel / solver.py
Created March 30, 2022 16:35
Our solver for Google Hash Code qualifier 2022 - 67th place
import json
import random
# Takes a dataset variable and returns a solution variable
def solve(dataset):
for contributor in dataset['contributors'].values():
contributor['availableAt'] = 0
# Since we levelup only in skillsByName, avoid discrepancies
del contributor['skills']
participants = '''@the_duf_
@driikolu
@Tashiqi
@PontyGuillaume
@MrAdrien79
@Nicoverflow
@dourojp
@Durab_
@Femtozer
@C_Papazian
'''
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:
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):
participants = '''@Greglimo1
@maxencedevigne
@z3gh0st
@4quatre4quatre
@YavuzSonmez_
@Tek_7987
@Maskott6
@corsicajack
@SmxPlayer
@le_jop
MiT
Smoked Chicken
Leet More
Hates Irony
sutegoma2
lollersk8ers
European Nopsled Team
Routards
Plaid Parliament of Pwning
Shellphish