Skip to content

Instantly share code, notes, and snippets.

View solve.py
from pwn import *
import struct
def p64(x):
return struct.pack('Q', x)
def u64(x):
return struct.unpack('Q', x)[0]
def p32(x):
return struct.pack('<I', x)
def u32(x):
@danielpyon
danielpyon / trie.py
Last active Aug 20, 2022
simple trie implementation
View trie.py
# simple trie implementation
class Trie:
class Node:
def __init__(self, data=None, end=False):
self.data = data
self.children = dict()
# is this the end of a word?
self.end = end
def __str__(self):
View castle.py
'''
ID: daniel20
LANG: PYTHON3
TASK: castle
'''
global WEST, NORTH, EAST, SOUTH
WEST, NORTH, EAST, SOUTH = 0, 1, 2, 3
def closed(room, direction=NORTH):
@danielpyon
danielpyon / floodfill.py
Last active Aug 19, 2022
flood fill algorithms
View floodfill.py
# adj list, edge list, adj matrix
# in an adj list, each vertex contains a list of nodes it is adjacent to
# simple undirected, unweighted graph using adjacency list representation
class Graph:
def __init__(self):
self.graph = dict()
def add_node(self, label):
assert label not in self.graph
self.graph[label] = list()