Skip to content

Instantly share code, notes, and snippets.

View euphwes's full-sized avatar

Wes Evans euphwes

View GitHub Profile
10:40:37 ~/dev/adventOfCode (master) (AdventOfCode)
$ python aoc.py 2022 21
Advent of Code 2022 - Day 21, part 1
monkey named root yells: 66174565793494
Ran in 10.015 ms
Advent of Code 2022 - Day 21, part 2
21830569590923 = ((354 + (331 + ((44343996218333 - ((995 + (330 + ((6 * ((((((((((((((387 + ((473 + (3 * ((((((10 * (((((((((4 * ((((((2 * (573 + ((881 + (134 + (1000 + (909 + (2 * ((4 * (441 + ((((169 + (((((((74 * (750 + ((humn - 601) / 2))) + 829) * 2) - 555) / 5) - 453) / 2)) * 2) - 170) / 2))) - 317)))))) / 3))) - 102) / 4) + 402) / 2) - 826)) - 438) * 2) + 171) / 5) - 978) + 889) /
Valve DB has flow rate=0; tunnels lead to valves AC, UN
Valve LC has flow rate=6; tunnels lead to valves UV, CM, RD, IM, YQ
Valve SU has flow rate=0; tunnels lead to valves OH, BX
Valve JS has flow rate=0; tunnels lead to valves GR, RW
Valve BX has flow rate=18; tunnels lead to valves PA, SU
Valve WI has flow rate=0; tunnels lead to valves GR, JI
Valve YQ has flow rate=0; tunnels lead to valves LC, SB
Valve HX has flow rate=10; tunnels lead to valves VR, GZ, ID
Valve RI has flow rate=0; tunnels lead to valves HF, UV
Valve JQ has flow rate=0; tunnels lead to valves AA, IF
def _is_visible(tree_coordinate, forest, forest_width, forest_height):
""" Returns whether the tree at the specified coordinate is visible from outside the forest. """
tree = forest[tree_coordinate]
cx, cy = tree_coordinate
# If the tree is on a border, it's visible.
if cx in (0, forest_width - 1) or cy in (0, forest_height - 1):
return True
@euphwes
euphwes / cstimer_cleanup.py
Created June 15, 2021 16:28
cstimer sort solves per session by solve date
from json import loads, dumps
with open('/Users/??/Downloads/cstimer_workspace.txt') as f:
data = loads(f.read())
session_names = {int(k): v['name'] for k, v in loads(data['properties']['sessionData']).items()}
for session_id, solves in [(k, v) for k, v in data.items() if k != 'properties']:
session_name = session_names[int(session_id[7:])]
print(f"\nSorting {len(solves)} solves by date for {session_name}...")
List<String> moveChoices = ["B", "U", "F", "R", "L", "D", "BR", "BL"];
Map<String, String> moveOpposites = new HashMap<String, String>() {{
put("F", "B");
put("U", "D");
put("L", "BR");
// and so on
}};
List<String> yourScramble = new List();
import argparse
import json
from sys import exit
from os.path import isfile
# TODO handle cstimer penalty -> TwistyTimer Penalty
# TODO vet TwistyTimer puzzle/category options
#-------------------------------------------------------------------------------
from string import ascii_lowercase
def increment_password(password):
password_idx = len(password) - 1
while True:
curr_char = password[password_idx]
curr_char_idx = ascii_lowercase.index(curr_char)
if curr_char_idx != 25:
@euphwes
euphwes / coolCommitHash.sh
Created March 6, 2019 16:26
continually amends a commit by tacking a counter variable onto the commit message until the commit hash matches some criteria
function coolCommitHash() {
hash=`git rev-parse HEAD`
origMsg=`git log --format=%B -n 1 $hash`
adjust=1
while [[ $hash != 0000* ]]
do
newMsg=$origMsg$"
"$adjust
git commit --amend -m "$newMsg" > /dev/null 2>&1
@euphwes
euphwes / gist:5e29097c173023e5451629e554f0e47f
Created August 30, 2018 21:34
upgraded formula for pokemon sheet
=ARRAYFORMULA(IFERROR(IF(C4:C<>"";"|" & "(★) " & C4:C & IFERROR(IFS(L4:L="Male";" (♂)";L4:L="Female";" (♀)")) & "|[](/" & LOWER(E4:E) & "ball)|" & IF(H4:H=I4:I;"**" & I4:I & "**";IF((H4:H="----")*(F4:F=I4:I);"*" & I4:I & "*";I4:I)) & "|" & J4:J & "|" & M4:M & "." & N4:N & "." & O4:O & "." & P4:P & "." & Q4:Q & "." & R4:R & "|" & X4:X & IF(NOT(ISBLANK(Y4:Y));" - " & Y4:Y;"") & IF(NOT(ISBLANK(Z4:Z));" - " & Z4:Z;"") & IF(NOT(ISBLANK(AA4:AA));" - " & AA4:AA;"") & "|" & AB4:AB & "/" & AC4:AC & "|" & AD4:AD & "|";"")))
import inspect
class limited_scope():
def __init__(self):
self.starting_locals = set()
self.ending_locals = set()
def __enter__(self, *args):
prev_frame = inspect.currentframe().f_back
self.starting_locals.update(prev_frame.f_locals)