Skip to content

Instantly share code, notes, and snippets.

@maksverver
maksverver / PKGBUILD
Created February 7, 2023 20:09
syasokoban-2.0.1
# Contributor: Franck Barbenoire <contact@franck-barbenoire.fr>
pkgname=syasokoban
pkgver=2.0.1
pkgrel=2
pkgdesc="Still Yet Another Sokoban"
arch=('i686' 'x86_64')
license=('GPL')
url="http://grayskygames.com/sokoban.html"
depends=('sdl')
package com.janoz.aoc.y2022.day13;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class Package implements Comparable<Package> {
private final AList contents;
from functools import cmp_to_key
import sys
def ParseLine(line):
stack = [[]]
i = 0
while i < len(line):
ch = line[i]
if ch.isdigit():
j = i + 1
@maksverver
maksverver / 13.py
Last active December 13, 2022 13:21
import sys
import json
def ParsePart(part):
a, b = part.splitlines()
return json.loads(a), json.loads(b)
pairs = list(map(ParsePart, sys.stdin.read().split('\n\n')))
#include <cassert>
#include <chrono>
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
namespace {
struct Point {
Monkey 0:
Starting items: 1
Operation: new = old * 3
Test: divisible by 2
If true: throw to monkey 1
If false: throw to monkey 2
Monkey 1:
Starting items: 1
Operation: new = old * 3
--- a/Problem9/Problem9.cpp
+++ b/Problem9/Problem9.cpp
@@ -218,20 +218,19 @@ bool Run(const std::filesystem::path &file)
{
int d = dir;
Move lastMove;
- for (int k = 0; k < NumKnots /*&& d != None*/; k++)
+ for (int k = 0; k < NumKnots; k++)
{
auto& state = knotStates[k];
@@ -349,7 +350,8 @@
//int minx = 0, miny = 0, maxx = 0, maxy = 0;
BitGrid grid;
- int numCells = 0;
+ grid.Set(0, 0);
+ int numCells = 1;
while (ptr < end)
{
@maksverver
maksverver / 09-mt.cc
Created December 9, 2022 19:22
Advent of Code 2022 Day 9 solution with online deduplication
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <map>
#include <mutex>
#include <string>
#include <thread>
#include <utility>
@maksverver
maksverver / 09-vectors.cc
Created December 9, 2022 19:18
Advent of Code 2022 Day 9 solution with std::vectors
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
namespace {