Skip to content

Instantly share code, notes, and snippets.

Julio Di Egidio jp-diegidio

Block or report user

Report or block jp-diegidio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jp-diegidio
jp-diegidio / ilog2.pl
Last active Oct 27, 2019
Numerical Snippets in Prolog
View ilog2.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (SWI-Prolog 7.5.1)
:- module(ilog2,
[ %%
ilog2_n/3, % +X, -Y, -C
ilog2_b/3, % +X, -Y, -C
ilog2_i/3, % +X, -Y, -C
%ilog2_f/3, % +X, -Y, -C
View WhoOwnsTheFish.pl
/*
Einstein's riddle: who owns the fish?
<https://groups.google.com/d/msg/sci.physics/Xs_L2kfwvRQ/YZrpky3aCAAJ>
There are 5 houses in 5 different colors in a row. In each house lives a
person with a different nationality. The 5 owners drink a certain type of
beverage, smoke a certain brand of cigar, and keep a certain pet. No
owners have the same pet, smoke the same brand of cigar, or drink the same
beverage. Other facts:
@jp-diegidio
jp-diegidio / Nan.Kernel.Ex.pl
Created Sep 3, 2015
Answer Sources in Prolog (SWI) - Preview
View Nan.Kernel.Ex.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
Answer Sources in Prolog (SWI) - Preview
Answer Sources: Extensions
Copyright (c) 2015 Julio P. Di Egidio
http://julio.diegidio.name/
All rights reserved.
Answer Sources: Extensions
--------------------------
View MinimiseCandies.pl
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/*
How few candies does the teacher need?
--------------------------------------
Problem:
Alice is a teacher of kindergarten. She wants to give some candies to
the children in her class. All the children sit in a line and each of
them has a rating score according to his or her usual performance.
View SudokuSolver.pl
% (SWI-Prolog)
:- use_module(library(clpfd)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%! sudoku(?Rows) is nondet.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sudoku(Rows) :-
sudoku__rows(Rows),
sudoku__cols(Rows),
View DigitProbabilities.pl
/* ---------------------------------------------------------------------------
How to calculate this probability?
Originally from a question by "Houwu Chen":
https://groups.google.com/d/msg/sci.math/YgvVT-SLvRg/RLn2agzZM7kJ
https://groups.google.com/d/msg/sci.math/YgvVT-SLvRg/2TC-NcV-AqoJ
UPDATED 2015-04-27: Fixed a bug in to_digit_probs__do/4.
Question:
You can’t perform that action at this time.