Skip to content

Instantly share code, notes, and snippets.

@maksverver
maksverver / generator.c
Created December 29, 2024 18:50
CodeCup 2025 Box tile generator
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static uint8_t random_data[240];
static size_t random_size = 0;
uint8_t GetRandomByte() {
@maksverver
maksverver / loopy-numbers-1.txt
Created December 11, 2024 08:30
Challenge data for Advent of Code 2024 day 11
494106250
494112500
494281250
494287500
494456250
494631250
494806250
494975000
494981250
495150000
# Almost-correct solution
from functools import cmp_to_key
import sys
order = dict()
sort_key = cmp_to_key(lambda p, q: order.get((p, q), 0))
for line in sys.stdin:
@maksverver
maksverver / player-template.js
Created November 14, 2024 23:46
Codecup Box Javascript player for Caia (compatible with Node.js and d8)
#!/usr/bin/d8 --single-threaded
// d8 defines print() and printErr() which write to stdout and stderr.
// In Node.js, we can use console.log() and console.error() for this.
const print = globalThis.print || console.log;
const printErr = globalThis.printErr || console.error;
// Global player initialization
let myColor = undefined;
let firstMove = undefined;
@maksverver
maksverver / speler.js
Last active November 12, 2024 22:31
Voorbeeld CodeCup speler Box/Square in Javascript
#!/usr/bin/d8 --single-threaded
// Voor Caia:
// 'D' voor een deterministische speler
// 'R' voor een nondeterministische speler
printErr('D', 'voorbeeldspeler');
const mijnKleur = Number(readline());
printErr('Mijn kleur:', mijnKleur);
@maksverver
maksverver / MinimaxCPU.js
Created October 20, 2024 20:06
StackAndCoquer new AI players
/**
* \file MinimaxCPU.js
*
* \section LICENSE
*
* Copyright (C) 2024 Maks Verver
*
* This file is part of StackAndConquer.
*
* StackAndConquer is free software: you can redistribute it and/or modify
#!/usr/bin/env python3
import io
import libxml2
import xml.sax.xmlreader
from drv_libxml2 import LibXml2Reader
def parse_binary():
source = xml.sax.xmlreader.InputSource()
source.setByteStream(io.BytesIO(b'<?xml version="1.0" encoding="UTF-8"?>\n<root />\n'))
@maksverver
maksverver / makepkg output
Created June 22, 2024 20:47
mingw-w64-curl 8.8.0 configure failure when wine is installed
==> Making package: mingw-w64-curl 8.8.0-1 (Sat 22 Jun 2024 10:42:22 PM CEST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
-> Found curl-8.8.0.tar.xz
==> Validating source files with sha256sums...
curl-8.8.0.tar.xz ... Passed
==> Extracting sources...
-> Extracting curl-8.8.0.tar.xz with bsdtar
==> Starting build()...
import java.util.*;
import java.util.stream.Collectors;
import com.google.common.collect.SortedMultiset;
import com.google.common.collect.TreeMultiset;
class Test {
static List<Integer> solvePriorityQueue(List<Integer> list, int m) {
PriorityQueue<Integer> pq = new PriorityQueue<>(list.subList(0, m));
List<Integer> res = new ArrayList<>(list.size() - m + 1);
Integer mth = pq.peek();
ihgfeiyxhgfvutonkhfedzylkhgklxwvutsrijknxwtspofgjknorsghklopstwxyzutonmlihgcbaghirqptqpvwnokjiihgfdefghijklmabcedcbfghijklmkjihgbcmnqruvwwvutsrnmlkjbcnmlihsrqnmihgfqpcpondeflmpqruvwxyefijlmnopqwvutsrq
jklmrsvwijewaspmjigbcexmjifjzyrsfedqonlmyvurqnehilmpqtfijmnqruvefghspbakjefddefzjknosrourqployjkdecuvcdrqponfedfnmdecdehyxnlmnofedlopstyxlkhgnqotuhiedopkjgfepoljcdenojilmcjgknoqrtsrklmghkkbutsrnojkijp
hgfnqtumlkdcbrqljihjifwnopedfpqhglkppmjihopklmdcadeyxuedcbawpocdmlirqcpqrdbecopyxlmmnantsutmnxmlcbbtwfestwxygnogolkjigficwvurqpjifkjibcznojifoppsvwgfsrqefghdcjkkbpomlkfkjbihjihponmqponxblscdghlmpighko
ijeopponuvynoijkklmkhgvutqbcgonijmnoqlkfgnqjefijbcfzwvjionuvqnmonkjgddodihgfmnqrwvklobmlwvsrqwnefklsrghiuvgfhmphpqfghhkjdihtsqrkhgnmhgdlmpqredcqryzhutpodcaijhimlblnefgghidcbgfeijdlkpqrwvmrqefikjghajkn
lkdcbqrstwxmlhgfeonljklmsrtuhimlkaabrsbelmridghksrghmlkhlmtsrklpqonfeenkjedalkjstujqpcjkxdeopvodgjmpqekjliheiljisredjilmefgxypslqpolkfekfedszrstwxnisrqnmlblkgoncbkjdihqrfeijkpohklijonstunopnmjfifcbilm
mpqraijsrbajkbacdpn