/*
Recreational mathematics in Picat.
From Pascal Van Henrentyck "The OPL Optimization Programming Language",
page 32:
"""
Consider finding an eight digit number that is a square and remains a square
when 1 is concatenated in front of its decimal notation.
"""
There are two solutions:
n=23765625
x=4875
y=11125
n=56250000
x=7500
y=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 =>
N :: 10000000..99999999,
X :: 0..20000,
Y :: 0..20000,
N #= X*X,
100000000+N #= Y*Y,
solve($[ff,split], [N,X,Y]),
println(n=N),
println(x=X),
println(y=Y),
nl,
fail,
nl.