$ swipl -O golf_swi.pl % library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 2,120 bytes % library(error) compiled into error 0.00 sec, 9,620 bytes % library(lists) compiled into lists 0.01 sec, 22,688 bytes % library(apply) compiled into apply 0.00 sec, 6,056 bytes % library(pairs) compiled into pairs 0.00 sec, 5,240 bytes % library(clpfd) compiled into clpfd 0.05 sec, 302,936 bytes % golf_swi compiled into golf 0.06 sec, 341,404 bytes Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.7.13-1-gcba5ece) Copyright (c) 1990-2009 University of Amsterdam. SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details. For help, use ?- help(Topic). or ?- apropos(Word). ?- time(golf(8,4,9,[min],bycolall)). Week 1: 0 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 Week 2: 0 8 16 24 1 9 17 25 2 10 18 26 3 11 19 27 4 12 20 28 5 13 21 29 6 14 22 30 7 15 23 31 Week 3: 0 9 18 27 1 8 19 26 2 11 16 25 3 10 17 24 4 13 22 31 5 12 23 30 6 15 20 29 7 14 21 28 Week 4: 0 10 20 30 1 11 21 31 2 8 22 28 3 9 23 29 4 14 16 26 5 15 17 27 6 12 18 24 7 13 19 25 Week 5: 0 11 22 29 1 10 23 28 2 9 20 31 3 8 21 30 4 15 18 25 5 14 19 24 6 13 16 27 7 12 17 26 Week 6: 0 12 19 31 1 13 18 30 2 14 17 29 3 15 16 28 4 8 23 27 5 9 22 26 6 10 21 25 7 11 20 24 Week 7: 0 13 17 28 1 12 16 29 2 15 19 30 3 14 18 31 4 9 21 24 5 8 20 25 6 11 23 26 7 10 22 27 Week 8: 0 14 23 25 1 15 22 24 2 12 21 27 3 13 20 26 4 10 19 29 5 11 18 28 6 8 17 31 7 9 16 30 Week 9: 0 15 21 26 1 14 20 27 2 13 23 24 3 12 22 25 4 11 17 30 5 10 16 31 6 9 19 28 7 8 18 29 % 58,098,307 inferences, 11.55 CPU in 12.26 seconds (94% CPU, 5030156 Lips) true.