do you like pre-stuff?

This commit is contained in:
basicbonobo 2023-12-01 00:49:28 +01:00 committed by Eivind Øksnevad
commit 1334307ac1
7 changed files with 107 additions and 0 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
gettoday merge=ours

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
*.sw?
aids
__pycache__/
tmp
a.out
response*
*.hi
*.o
cookie
tags
22

13
1 Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
year=$(date +%Y)
day=$(date +%d | sed 's/^0//')
case $# in
2)
year=$2
day=$1
specifyyear=_$year;;
1)
day=$1
esac
curl "https://adventofcode.com/$year/day/$day/answer" -X POST -H "Cookie: session=$(cat cookie)" --data-raw "level=1&answer=$(sed 1q)"

13
2 Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
year=$(date +%Y)
day=$(date +%d | sed 's/^0//')
case $# in
2)
year=$2
day=$1
specifyyear=_$year;;
1)
day=$1
esac
curl "https://adventofcode.com/$year/day/$day/answer" -X POST -H "Cookie: session=$(cat cookie)" --data-raw "level=2&answer=$(sed -n 2p\;2q)"

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# Advent of Code 2023 solutions
A set of 25 puzzle inputs and 50 puzzle solutions, two for each day. Most can
be solved in minutes. The puzzles can be found
[here](https://adventofcode.com/2023/), although only the first one for each
day is visible until you solve it.
Most solutions output at most two lines, the answers to part 1 and 2; but some
provide more information in the form of e.g. graphics.
Run a solution by passing the puzzle input to the program.

18
gettoday Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
year=$(date +%Y)
day=$(date +%d | sed 's/^0//')
case $# in
2)
year=$2
day=$1
specifyyear=_$year;;
1)
day=$1
esac
file=input$day$specifyyear
curl -s -o "$file" -H "Cookie: session=$(cat cookie)" \
"https://adventofcode.com/$year/day/$day/input"
git add "$file"

40
useful.py Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env python3
from functools import cache, reduce
from itertools import permutations, product, combinations, pairwise, groupby, takewhile
from more_itertools import batched, sliding_window
from collections import defaultdict, deque
import re, sys
import math
import numpy as np
import cv2 as cv
from icecream import ic
import torch.nn.functional as F
from copy import deepcopy
def commaline(line):
return [int(n) for n in line.strip().split(',')]
def headerfooter(f):
return f.read().split('\n\n', maxsplit=1)
def pgphs(text):
return text.strip().split('\n\n')
def hfl(f): # header footer lines
return [p.strip().split('\n') for p in headerfooter(f)]
def numbers(l): # usually what we want really
return [int(x) for x in re.findall(r'-?[0-9]+', l)]
def lines(f):
return [l.strip() for l in f.readlines()]
def dprint(*args):
sep = False
for arg in args:
if sep:
print('--------')
sep = True
for a, b in arg.items():
print('%10s: %s' % (a, ','.join(b)))
print()