Skip to content

Instantly share code, notes, and snippets.

View youxkei's full-sized avatar

Hisayuki Mima youxkei

View GitHub Profile
@youxkei
youxkei / a_puzzle_a_day.pl
Created June 24, 2021 12:11
A Puzzle A Day Solver
:- use_module(library(clpfd)).
:- use_module(library(lists)).
month_rows([
[[jan, _, _, _, _, _, xxx], [_, _, _, _, _, _, xxx]],
[[_, feb, _, _, _, _, xxx], [_, _, _, _, _, _, xxx]],
[[_, _, mar, _, _, _, xxx], [_, _, _, _, _, _, xxx]],
[[_, _, _, apr, _, _, xxx], [_, _, _, _, _, _, xxx]],
[[_, _, _, _, may, _, xxx], [_, _, _, _, _, _, xxx]],
[[_, _, _, _, _, jun, xxx], [_, _, _, _, _, _, xxx]],
@youxkei
youxkei / n_puzzle.pl
Created September 17, 2023 05:18
N-Puzzle solver
ops(+).
ops(-).
ops(*).
ops(/).
calc([], [Result], Result).
calc([+ | Rest], [B, A | Stack], Result) :- calc(Rest, [A + B | Stack], Result).
calc([- | Rest], [B, A | Stack], Result) :- calc(Rest, [A - B | Stack], Result).
calc([- | Rest], [B, A | Stack], Result) :- calc(Rest, [B - A | Stack], Result).
calc([* | Rest], [B, A | Stack], Result) :- calc(Rest, [A * B | Stack], Result).