Skip to content

Instantly share code, notes, and snippets.

@jsbueno
jsbueno / day15_2022.py
Created December 16, 2022 18:06
advent_!5_2022
"""
SPOILER ALERT
Puzzle at: https://adventofcode.com/2022/day/15
Part 2 could be brute-forced with the use of "part1" in less
than 10 minutes, I guess.
I opted for a rectangle-splitting approach, and checking if
@jsbueno
jsbueno / advent_14_2022.py
Created December 14, 2022 17:47
Advent of code 2022 - day 14
"""
SPOILER ALERT!
Problem at: https://adventofcode.com/2022/day/14
I guess, no special comments this time.
Just that terminedia.V2 is truly great!
"""
import terminedia as TM
"""
SPOILER ALERT!
Problem at: https://adventofcode.com/2022/day/13
This one was made quite easy by using Python's native comparison heuristics
along with operator overloading.
Part 2 was ready without a single new line of code on the class- just adding the markers,
@jsbueno
jsbueno / advent_12_2022.py
Last active December 13, 2022 20:19
Advent of Code, day 12 - 2022
"""
SPOILER ALERT
Advent of Code, day 12 - 2022
At least, I am using terminedia for something
beyond the 2D vectors -
"""
@jsbueno
jsbueno / day11_2022.py
Created December 12, 2022 22:35
Advent of code 2022, day 11
"""
SPOILER ALERT
As usual, these are snippets used to get the answer in interactive mode, not
a self-contained interactive program.
"""
class Monkey:
monkeys = []
@jsbueno
jsbueno / day8.py
Last active December 8, 2022 19:39
Advent of code 2022, day8
"""
Puzzles at: https://adventofcode.com/2022/day/8
SPOILER ALERT!!!
Not super-smart - but very conffy to look and operate at the map.
Probably with some heavy caching (using attached dicts) could go from quadractic time to near linear time.
(Or O(MxN) M being the total points, N being max (Width, Height))
@jsbueno
jsbueno / gist:19490688b6f001cfd5ba691d6e69c9e3
Created December 6, 2022 21:43
Advent of code 2022 day 6 , Dec 6-
"""Problem at https://adventofcode.com/2022/day/6
SPOILER ALERT!
This is a problem that could easily be solved by "brute-force" and simply
creating a set for each 14-character window and checking its length.
I created a "counter of counters" that I think could hold
constant time for counting, and therefore, linear time to
find large un-repeated sequences in large (multi GB) datasets
@jsbueno
jsbueno / day5.py
Created December 5, 2022 20:29
Advent of code, 5, Dec 2022
"""
( https://adventofcode.com/2022/day/5 )
SPOILER ALERT!
Instead of the end-to-end solution, just the class I've used
which can display the animation of containers been
moved around -
@jsbueno
jsbueno / day4.py
Last active December 5, 2022 19:02
Advent of code, dec, 4th 2022, parts 1 and 2
"""
( https://adventofcode.com/2022/day/4 )
SPOILER ALERT! The snippets in here present a complete solution
This is both "my style" and what I like most about Python:
creating a minimal class which implements one or more operators
turns the solving of thiz puzzle into a super-readable
one liner!
@jsbueno
jsbueno / index.html
Created November 14, 2022 15:47
brython "hello world" showing the easy-to use DOM integration that is lacking on other python-on-browsers.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="brython.js"></script>
<script type="text/javascript" src="brython_stdlib.js"></script>
</head>
<body onload="brython(1)">