How to programmatically solve the 15 (moving numbers) puzzle?

后端 未结 7 1793
礼貌的吻别
礼貌的吻别 2021-02-04 08:02

all of you have probably seen the moving number/picture puzzle. The one where you have numbers from 1 to 15 in a 4x4 grid, and are trying to get them from random starting positi

7条回答
  •  深忆病人
    2021-02-04 08:42

    By reduction the only possible case you can't solve must be of the form
    1 3
    2 X
    and you want to get it to
    1 2
    3 X

    by using an additional row and column you can move those to the proper positions with a simple precomputed sequence

提交回复
热议问题