Skip to content

Instantly share code, notes, and snippets.

@percontation
percontation / thicc_ai.py
Created April 19, 2021 16:22
thicc-tac-toe AI, pctf2021
# This is AI source for the thicc-tac-toe challenge server from PlaidCTF 2021.
# It's also the reference solution, since it loses to itself often enough.
from __future__ import print_function
from collections import Counter
import random
def ai(B, xo, randomize=True):
our_two_aways = set()
their_two_aways = set()
about_to_win = None
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
printf("Hi, I'm %s\n", argv[0]); // The first "argument" is the path-to-self
if(argc != 2) { // argc is how long argv is, including that path-to-self
puts("You need to give me exactly one argument!");
return -1;
@percontation
percontation / z3crc.py
Last active April 2, 2022 20:21
z3 crc example
#!/usr/bin/python
from z3 import *
# Data must be in 32 bit chunks, because I'm lazy.
def z3crc32(data, crc = 0):
crc ^= 0xFFFFFFFF
for c in data:
for block in range(24, -1, -8):
crc ^= LShR(c, block) & 0xFF
for i in range(8):