Skip to content

Instantly share code, notes, and snippets.

View abeaumont's full-sized avatar

Alfredo Beaumont abeaumont

View GitHub Profile
@abeaumont
abeaumont / 16.pi
Created December 22, 2022 08:25
Picat solution for Day 16 in Advent of Code 2022
import util.
final(30) => true.
final(_) => false.
table(+,max,nt)
plan({M, _, _}, P, _), final(M) => P = 0.
plan({M, V, N}, P, D@{G, R, NtV}), R[N] > 0, V[NtV[N]] == false ?=>
plan({M+1, {cond(I == NtV[N], true, V[I]) : I in 1..V.len}, N}, P1, D),
P = P1 + R[N] * (29 - M).
module Lexer = struct
type token =
Num of int
| Id
| Plus
| Minus
| Product
| Division
| Exponent
| LPar
if 0:
if 0:
if 0:
if 0:
if 0:
if 0:
if 0:
if 0:
if 0:
if 0:
public class A{public static void x(){
if(0){
if(0){
if(0){
if(0){
if(0){
if(0){
if(0){
if(0){
if(0){
@abeaumont
abeaumont / C.pi
Last active May 1, 2017 08:58
GCJ 2017 Round 1C. Problem C. Core Training
import util, mip.
go(T, N, K, U, Xs) =>
X = new_array(N),
X :: 0.0..1.0,
foreach(I in 1..N)
X[I] #>= Xs[I],
X[I] #<= Xs[I] + U
end,
sum(X) #<= sum(Xs) + U,
@abeaumont
abeaumont / memory-addressing.py
Created August 11, 2016 23:05
Get memory addressing mode stats from a binary
#!/usr/bin/env python
import sys
from collections import Counter
from elftools.elf.elffile import ELFFile
from capstone import *
from capstone.x86 import *
def get_binary(file: str) -> (bytes, int):
with open(file, 'rb') as stream:
from pwn import *
for i in range(512, 768):
t = remote('xkcd_be4bf26fcb93f9ab8aa193efaad31c3b.quals.shallweplayaga.me', 1354)
t.send('SERVER, ARE YOU STILL THERE? IF SO, REPLY "' + 'A' * 512 + '" ({} LETTERS)\n'.format(i))
print t.recvline()
t.close()
@abeaumont
abeaumont / catch.c
Created May 10, 2016 22:01
Solution for Catch Me challenge in ASIS CTF 2016 Quals
#include <stdio.h>
int is_valid(unsigned char c) {
return c == 0 || c == 45 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c == 95 || c >= 97 && c <= 122;
}
int main () {
unsigned char h1[17] = {0x87, 0x29, 0x34, 0xC5, 0x55, 0xB0, 0xC2, 0x2D, 0xEE, 0x60, 0x34, 0xD4, 0x55, 0xEE, 0x80, 0x7C, 0};
unsigned char h2[17] = {0xEE, 0x2F, 0x37, 0x96, 0x3D, 0xEB, 0x9C, 0x79, 0xEE, 0x2C, 0x33, 0x95, 0x78, 0xED, 0xC1, 0x2B, 0};
module: string-aref-test
define function main ()
let t = "abcdefg";
let (a, b) = method() values(t[2], 'c') end();
format-out("%= %=\n", a, b);
let (c, d) = values(t[2], 'c');
format-out("%= %=\n", c, d);
let x = #[1, 2, 3, 4];
let (e, f) = method() values(x[2], 'c') end();
@abeaumont
abeaumont / tlang.lisp
Last active August 29, 2015 14:12
Solution for TLang problem, (ab)using reader macros https://contest.tuenti.net/resources/2011/Question_2.html
(defun transform-expr (expr)
(if (symbolp expr)
(let ((s (symbol-name expr)))
(cond ((string-equal s "=") '+)
((string-equal s "@") '-)
(t expr)))
expr))
(defun read-next-object (delimiter &optional (stream *standard-input*))
(if (and delimiter (char= (peek-char t stream t nil t) delimiter))