Skip to content

Instantly share code, notes, and snippets.

View afvanwoudenberg's full-sized avatar

Aswin van Woudenberg afvanwoudenberg

View GitHub Profile
@afvanwoudenberg
afvanwoudenberg / weaver.pl
Created June 1, 2023 15:37
A Prolog solver for the Weaver (word ladder) puzzle
% A Prolog solver for the Weaver (word ladder) puzzle
% https://wordwormdormdork.com/
:- dynamic goal/1.
weaver(Start, Goal, Solution) :-
retractall(goal(_)),
assert(goal(Goal)),
a_star(Start, Solution).
@afvanwoudenberg
afvanwoudenberg / menace.ipynb
Created May 27, 2023 12:04
A Python implementation of MENACE (Matchbox Educable Noughts and Crosses Engine)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / fun_logger.py
Created May 16, 2023 14:32
A Python decorator and custom logging handler to create call graphs
# fun_logger.py
# For details see: https://www.aswinvanwoudenberg.com/posts/call-me-maybe/
import logging
import graphviz
from logging import StreamHandler
from functools import wraps, partial
def fun_logger(func=None, *, logging=logging, indent=' ', exit=False):
if func is None:
@afvanwoudenberg
afvanwoudenberg / time-lapse.ipynb
Created May 6, 2023 19:52
Create a time-lapse video from a collection of selfies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / blocbirds.ipynb
Created May 3, 2023 12:47
Create your own BLOCBIRDS-style artwork (https://blocbirds.nl/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / sudoku.ipynb
Created May 1, 2023 08:26
A Sudoku widget and solver
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / algorithm_visualization.ipynb
Created April 8, 2023 11:08
(Sorting) algorithm visualization
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / nqueens.ipynb
Last active April 8, 2023 11:02
A solver for the n-queens problem
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@afvanwoudenberg
afvanwoudenberg / skyline.pl
Created March 29, 2023 12:21
A Prolog solver for the Skyline puzzle
% A Prolog solver for the Skyline puzzle
% http://www.constantin-jean-clau.de/
print_solution(X,Y) :- solve(X,Y,Sol), print_board(Sol).
pos(X,Y,_) :- member(X,[1,2,3,4,5,6,7]), member(Y,[1,2,3,4,5,6,7]).
board(Board) :- findall(pos(X,Y,_),pos(X,Y,_),Board).
solve(X,Y,Board) :-
@afvanwoudenberg
afvanwoudenberg / bridge.pl
Last active March 25, 2023 13:56
A Prolog solver for the bridge and torch puzzle
% A Prolog solver for the bridge and torch puzzle
% https://en.wikipedia.org/wiki/Bridge_and_torch_problem
print_all_solutions :-
findall(_,print_solution,_).
print_solution :-
init(State),
solve(State,Solution,EndState),
writeln('Start state:'),