On 1/1/06, Christer Nilsson <janchrister.nilsson / gmail.com> wrote:> Would be interesting to see your heuristic solution applied to something> human, like 222->999.
Ok, here's a couple. They tend to be a step or two worse than optimal,the worst case performance I've run into yet is 4x longer path (with255 -> 257.)
ruby numpuz.rb 22 999[22, 24, 12, 14, 28, 30, 60, 62, 124, 248, 496, 498, 996, 998, 1996, 1998, 999]
ruby numpuz.rb 222 999[222, 224, 112, 56, 28, 30, 60, 62, 124, 248, 496, 498, 996, 998,1996, 1998, 999]
ruby numpuz.rb 222 9999[222, 224, 112, 56, 28, 14, 16, 18, 36, 38, 76, 78, 156, 312, 624,1248, 2496, 2498, 4996, 4998, 9996, 9998, 19996, 19998, 9999]
ruby numpuz.rb 22222 99999[22222, 22224, 11112, 5556, 2778, 2780, 1390, 1392, 696, 348, 174,176, 88, 44, 22, 24, 48, 96, 192, 194, 388, 390, 780, 1560, 1562,3124, 6248, 12496, 12498, 24996, 24998, 49996, 49998, 99996, 99998,199996, 199998, 99999]