Skip to content

Instantly share code, notes, and snippets.

View afvanwoudenberg's full-sized avatar

Aswin van Woudenberg afvanwoudenberg

View GitHub Profile
@afvanwoudenberg
afvanwoudenberg / sudoku.ipynb
Created May 1, 2023 08:26
A Sudoku widget and solver
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
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
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:'),
@afvanwoudenberg
afvanwoudenberg / einstein.pl
Created March 24, 2023 22:18
A Prolog solver for the Zebra puzzle a.k.a. Einstein's riddle
% A Prolog solver for the Zebra puzzle a.k.a. Einstein's riddle.
% https://en.wikipedia.org/wiki/Zebra_Puzzle
einstein :-
einstein(Solution),
write_sol(Solution).
einstein(Sol) :-
Sol = [
[1,N1,C1,P1,D1,S1], % There are five houses.
@afvanwoudenberg
afvanwoudenberg / icosian.pl
Last active March 29, 2023 17:14
Prolog code to solve the icosian game
% A Prolog solver for the Icosian game
% https://en.wikipedia.org/wiki/Icosian_game
icosian_puzzle_edges([
(b,c), (b,g), (b,z), (c,d), (c,p), (d,f), (d,m), (f,g), (f,k), (g,h),
(h,j), (h,x), (j,k), (j,v), (k,l), (l,t), (l,m), (m,n), (n,p), (n,s),
(p,q), (q,z), (q,r), (r,s), (r,w), (s,t), (t,v), (v,w), (w,x), (x,z)
]).
connected(Adj,P,Q) :- member((P,Q),Adj); member((Q,P),Adj).
@afvanwoudenberg
afvanwoudenberg / modValidIban.bas
Created October 19, 2018 13:06
VBA code to check if an IBAN bank account number is valid or not
Option Compare Database
Option Explicit
' http://en.wikipedia.org/wiki/International_Bank_Account_Number
Private Const IbanCountryLengths As String = "AL28AD24AT20AZ28BH22BE16BA20BR29BG22CR21HR21CY28CZ24DK18DO28EE20FO18" & _
"FI18FR27GE22DE22GI23GR27GL18GT28HU28IS26IE22IL23IT27KZ20KW30LV21LB28" & _
"LI21LT20LU20MK19MT31MR27MU30MC27MD24ME22NL18NO15PK24PS29PL28PT25RO24" & _
"SM27SA24RS22SK24SI19ES24SE24CH21TN24TR26AE23GB22VG24QA29"
Private Function ValidIbanCountryLength(CountryCode As String, IbanLength As Integer) As Boolean
@afvanwoudenberg
afvanwoudenberg / modKeyboardLeds.bas
Last active October 19, 2018 13:00
VBA code to turn the keyboard LEDs (Num Lock, Caps Lock and Scroll Lock) on and off
' modKeyboardLeds
' Aswin van Woudenberg
Option Explicit
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
@afvanwoudenberg
afvanwoudenberg / setres.cpp
Created October 19, 2018 12:51
Small program to change the screen resolution from the windows command line
// setres.cpp
// Aswin van Woudenberg
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{