This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_constraint | |
| num(+int,+int), num(+int), sum(+int), answer(+int), | |
| i2d(+int,+list(int),-list(int)), | |
| palindrome(+int), sq_sum(+int,-int), problem125. | |
| problem125 <=> sqrt(10**8//2,N), floor(N,N1), N2 is N1-2, num(N1,N2), sum(0). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- 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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_constraint num(+int,+int), answer(+int), problem100. | |
| problem100 <=> num(3,2). | |
| num(A,B) <=> X is (A+B+1)//2, Y is B//2, X+Y > 10**12 | answer(X). | |
| num(A,B) <=> A1 is A*3+B*4, B1 is A*2+B*3, num(A1,B1). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_constraint | |
| push(+list(int),+list(int)), list(+list(int)), dice(+list(int)), | |
| answer(+list(int),+list(int)), answer, count(+int), problem90. | |
| problem90 <=> numlist(5,9,L), push(L,[]), answer. | |
| push([],_) <=> true. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_constraint | |
| bin(+int), bin(+int,+int,+int,+int), | |
| num(+int), sqrt(+int), sum(+int), problem80. | |
| problem80 <=> num(100). | |
| num(N) ==> N > 1 | N1 is N-1, num(N1). | |
| num(N) <=> sqrt(N,R), floor(R,X), X*X =:= N | true. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(primality_test),[is_prime/1]). | |
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_type heap(T) ---> T-list(heap(T)). | |
| :- chr_type ratio ---> ratio(int,int,float). | |
| :- chr_constraint | |
| heap(+heap(ratio)), pop, top(+ratio), | |
| prime(+int), solve(+int), gen(+int,+int), answer(+int,+float), | |
| problem70. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(primality_test),[is_prime/1]). | |
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_constraint | |
| set(+int,+int), set(+int,+int,+int), set(+int,+int,+int,+int), | |
| prime(+int), gen(+int), answer/1, problem60. | |
| problem60 <=> gen(3). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- module(primality_test,[is_prime/1]). | |
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_constraint | |
| is_prime(+int), | |
| is_prime(+list(int),+int,+int), | |
| is_sub(+int,+int,+int), | |
| min_odd(+int,-int). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_type list(T) ---> []; [T|list(T)]. | |
| :- chr_constraint | |
| max_primes(+int,+list(int)), | |
| rev_primes(+list(int)), | |
| primes(+list(int)), | |
| answer(+int,+int), | |
| problem50. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| :- use_module(library(chr)). | |
| :- chr_option(optimize, full). | |
| :- chr_constraint solve(+int), digit(+int,+int,+int), mul(+int), problem40. | |
| problem40 <=> solve(1). | |
| solve(1000000) <=> true. | |
| solve(N) <=> digit(N,0,0), N1 is N*10, solve(N1). | |
| digit(N,0,0) <=> N < 10 | mul(N). |