Skip to content

Instantly share code, notes, and snippets.

View MathisHammel's full-sized avatar

Mathis HAMMEL MathisHammel

View GitHub Profile
@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']
# 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
# 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)
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
# 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