Skip to content

Instantly share code, notes, and snippets.

@Koitaro
Created July 3, 2011 19:54
Show Gist options
  • Select an option

  • Save Koitaro/1062551 to your computer and use it in GitHub Desktop.

Select an option

Save Koitaro/1062551 to your computer and use it in GitHub Desktop.
CHR : Project Euler 110-119
:- use_module(library(primality_test),[is_prime/1]).
:- use_module(library(digits),[d2i/2]).
:- use_module(library(chr)).
:- chr_option(optimize, full).
:- chr_type list(T) ---> []; [T|list(T)].
:- chr_constraint list(+list(int)), answer(+int), problem118.
problem118 <=> aggregate_all(count,set,X), answer(X).
set :- numlist(1,9,L), permutation(L,L1), divide(L1).
divide([]) :- true.
divide(L) :- append(L1,L2,L), min_list(L,N), member(N,L1), list(L1), divide(L2).
list(L) <=> d2i(L,N), \+ is_prime(N) | false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment