Skip to content

Instantly share code, notes, and snippets.

@deosjr
deosjr / blue-prince.pl
Created June 16, 2025 08:33
Blue Prince code
% WARNING: SPOILERS FOR BLUE PRINCE !
core(A, B, C, D, Core) :-
Core is (A / B - C) * D.
core(A, B, C, D, Core) :-
Core is A / B * C - D.
core(A, B, C, D, Core) :-
% HAND -> 2, since 8 - 1 / 14 * 4 = 2, but is a float..
%Core is (A - B) / C * D.
Core is (A - B) * D / C.
@deosjr
deosjr / kanren.pcn
Last active December 4, 2024 16:49
MicroKanren in Fleng
// http://webyrd.net/scheme-2013/papers/HemannMuKanren2013.pdf
// https://github.com/mndrix/microkanren-prolog/blob/master/microkanren.pl
// https://gitlab.com/b2495/fleng/-/blob/master/doc/PCN-tutorial.txt
// https://github.com/awalterschulze/gominikanren
// goal: f(state) -> stream, or a relation with st/str as last two args
// variables are a tuple of one integer value
-struct(state(substitutions, variablecounter))
// test: add sleep to equalo, then change composition of disj
@deosjr
deosjr / puzzle.pl
Created April 12, 2024 15:28
Puzzle Game: reverse a list of integers
% as per https://news.ycombinator.com/item?id=40010066
:- use_module(library(clpfd)).
:- table splits/2, combines/3, map_reverse_puzzle/3.
reverse_puzzle(List) :-
reverse(List, Rev),
max_list(List, Max),
reverse_puzzle(Max, List, Rev),
write(true), nl.
@deosjr
deosjr / turtle.go
Created July 27, 2023 06:27
Lisp turtle graphics on the Gopher Badge
package main
import (
_ "embed"
"image/color"
"machine"
"math"
"math/rand"
"strings"
"time"
@deosjr
deosjr / moustache.go
Last active July 10, 2025 18:04
Print a moustache on everyone's face using openCV
package main
import (
"fmt"
"image"
"image/color"
"math"
"gocv.io/x/gocv"
)
@deosjr
deosjr / einstein.scm
Last active October 25, 2020 15:53
Einstein's puzzle in miniKanren
#! /usr/bin scheme --script
;; loads two files from https://github.com/michaelballantyne/faster-miniKanren :
;; mk.scm and mk-vicare.scm
(load "lib.scm")
(define (membero x y)
(fresh (a d)
(== y `(,a . ,d))
(conde
[(== x a)]