File: digit8.pl

package info (click to toggle)
gprolog 1.3.0-6
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,708 kB
  • ctags: 8,388
  • sloc: ansic: 57,431; perl: 16,620; sh: 5,900; makefile: 1,284
file content (70 lines) | stat: -rw-r--r-- 2,222 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*-------------------------------------------------------------------------*/
/* 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]                                        */
/*-------------------------------------------------------------------------*/

q:-     get_fd_labeling(Lab),
        statistics(runtime,_),
        (digit8(L,Lab), 
         write(L), nl,
         fail
           ;
         write('No more solutions'), nl),
	statistics(runtime,[_,Y]),
        write('time : '), write(Y), nl.




digit8(L,Lab):-
	L=[N,X,M,Y],
	N #>= 10000000, 
	N#=<99999999,
        X**2 #= N,
	100000000+N #= M,
        Y**2 #= M,
	lab(Lab,L).




lab(normal,L):-
        fd_labeling(L).

lab(ff,L):-
        fd_labelingff(L).




get_fd_labeling(Lab):-
        argument_counter(C),
        get_labeling1(C,Lab).


get_labeling1(1,normal).

get_labeling1(2,Lab):-
        argument_value(1,Lab).




:- initialization(q).