The last puzzle of the year in Le Monde reads as follows (as far as I understand its wording!):
Iter(n,x,y) is the function
Iter=function(n,x,y){ if (n==1){ output=trunc(y/10)+x*(y%%10) }else{ output=Iter(n-1,x,Iter(1,x,y))} return output }Find the seven-digit number z such that
Iter(6,1,z)=12, Iter(6,2,z)=19, Iter(6,3,z)=29,
and Iter(6,-1,z)=Iter(6,-2,z)=Iter(6,-3,z)=0.
Obviously, the brute-force solution of listing all 90 million seven digit numbers until the six constraints are met is feasible (especially around New Year since the mainframe computer is completely at rest!). However, this sounds like the last resort solution and I thus tried first a simulated annealing approach already tested for the sudoku problem a few years ago… (This puzzle is actually of the same nature as the sudoku problem, in particular because we do know when we find the solution, except that checking for the six conditions to hold is apparently not so straightforward. For us if not for the computer.) Continue reading