/*
Digit 8 problem in Picat.
Standard Prolog Benchmark
"""
Benchmark (Finite Domain)
Name : digit8.pl
Title : particular 8 digit number
Original Source: Daniel Diaz - INRIA France
Adapted by : Daniel Diaz for GNU Prolog
Date : October 1993
Find the 8 digit number N such that:
- N is a square
- if we put a 1 in front of the decimal notation of N then it is
still a square
Solution:
[N,X,M,Y]
[23765625,4875,123765625,11125]
[56250000,7500,156250000,12500]
"""
This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com
See also my Picat page: http://www.hakank.org/picat/
*/
% import util.
import cp.
main => go.
go =>
statistics(runtime,_),
(digit8(L),
write(L), nl,
fail
;
print("No more solutions"), nl),
statistics(runtime,[_,Y]),
print("time : "), print(Y), nl.
digit8(L) =>
L=[N,X,M,Y],
N :: 10000000..99999999,
X**2 #= N,
100000000+N #= M,
Y**2 #= M,
solve([ff], L).