Get to know this puzzle from the game "レイトン教授と不思議な町":
1から9までの数字を1回ずつ使って、○○○○○-○○○○=33333になるようにするには、どの数字をどこにいれたらよいか。
fill in the ○ using the numbers 1-9 once each:
we know that 6 - 3 = 3, 4 - 1 = 3, 8 - 5 = 3, ... by intuitive, we try to fill in column by column, pairing two numbers with difference of 3 together:
but some numbers will be repeat.
let take a look in this graph, where each neighbor difference by 3.
what we have been doing, is linking up two neighbors horizontally and fill in a column.
no matter how we pair the numbers, some of them will be leave. This means we cannot solve without borrowing.
besides horizontal link, we need other links to pair the numbers! if we can pair up all the numbers, that means we have a solution to the puzzle!
lets define "horizontal line" as "cancel", since we can fill the pairs in to any columns freely.
we also know that 11 - 8 = 3, 12 - 9 = 3. if we use the concept of borrowing, we can define more ways to pair the numbers.
lets use the following example:
this involves 2 borrowing, 11 - 8 = 3, 13(12) - 9 = 3, 6(5) - 2 = 3
starting from the hundreds digit, we have 6 - 2 = 4
however, we know that the tens digit will borrow 1 from it. this makes the result become 3.
this means we can pair up 2 numbers with difference of 4 together, if we use them at the start of borrowing.
we can link the number diagonally"╲"in the graph.
note that 7 - 3 = 4, we can define a special link for that.
back to the exmaple, the tens digit borrow from hundreds digit and get borrowed from ones digit:
the tens digit borrow from hundreds digit and get borrowed from ones digit.
it "continues" the borrowing with only 3 cases: 3 - 9 = -4, 2 - 8 = -4, 1 - 7 = -4
this means we can pair up the above numbers together, if we use them in the continuous of borrowing.
we can link the edges numbers on the same row in the graph.
lets consider the ones digit:
the ones digit end the borrowing chain with only 2 cases: 2 - 9 = -3, 1 - 8 = -3
this means we can pair up the above numbers together, if we use them in the end of borrowing.
the last rule is the case of 4 at the ten thousands digit. this will trigger the start of borrowing chain.
alright we have defined all the rules.
what we have to do, is to link/use all the numbers based on the above rules in the graph.
lets put 3 at the ten thousands digit and link the numbers by horizontal lines:
3 is cancel, we group 1 and 4, 2 and 5, 6 and 9 together, 7 and 8 is leave
2 numbers will be remain. lets try to use the borrowing chain:
3 is cancel, we start the chain using 5 and 1, and end the chain using 2 and 9, 4 and 7 is cancelled freely, 6 and 8 is leave
not work.
lets put 4 at the ten thousands digit. we can also link 1 and 7 to continue the borrowing chain.
we need to end the borrowing chain using 2 and 9. fortunately, we can link the remaining numbers freely: 3 and 6, 5 and 8.
this will concludes the first 3 columns:
and the last 2 columns with 8 - 5 and 6 - 3.
Using the graph method, we can also solve something like:
- ○○○○○-○○○○ = 22222
- ○○○○○-○○○○ = 44444
general workflow:
- create a graph with digits 1 to 9, so that each neighbor digit different by X
- define links that pairs up two digits
- link the graph so that all digits are cancelled
- rewrite the solution