How to find 3 x 3 digit numbers adding to 1200 1300 1400

kdb

New member
Joined
Nov 26, 2012
Messages
3
Hi...
I am converting a game from one platform to another. The game involves a 3 x 3 digit square and the numbers 0 thru 9. The player needs to move the digits into each place in the grid to make a total which matches a given target. Each digit can be used only once and of course 1 will be left out.

i already have the possible solutions for several targets but would like to extend the range to 1200, 1300 and 1400 but don't know the best way to work out all the possible solutions.
i do need to have the solutions worked out beforehand so that I can place clue digits.

Any help would be appreciated.

Kdb
 
Not sure what you're asking...
finding stuff like 150 + 263 + 987 = 1400 ?

If not, give an example of what you're after.

Here is an example:

For the target number of 500 and omitting the digit 4 I have 3 possible solutions:

The hundreds column Tens column. Units column

0,1,2 3,6,9. 5,7,8
0,1,2. 3,7,8. 5,6,9
0,1,2. 5,6,7. 3,8,9

So for a correct answer according to solution 1 the grid might look like this:

0. 6. 8
2. 9. 5
1. 3. 7

Or this

1. 9. 5
0. 6. 7
2. 3. 8

I hope this makes it clearer...
Regards kdb
 
Well, that gave me a headache just looking at it...
so I'll leave it for Jeff :wink:
Thanks denis. Just for that I gave those hockey tickets on center ice to my neighbor.

I am fairly sure that the problem is:

Given a target number of three or four digits, find all the sets of three three-digit numbers (leading zero is permitted) such that (1) the sum of the three numbers equals the target number, and (2) each numeral from 0 to 9 appears at most once in any of the three numbers. I have thought about that problem briefly, and it makes my head ache.

Given 100u + 10v + w, where u, v, and w are integers from 0 through 9,

(A) find every set, if any exist, {a, b, c, d, e, f, g, h, i} such that

(1) all letters in the set are integers from 0 through 9,

(2) the set {a, b, c, d, e, f, g, h, i} contains nine different integers, and

(3) 100(a + d + g) + 10(b + e + h) + (c + f + i) = 100w + 10v + u, and then

(B) For each set {a, b, c, d, e, f, g, h, i}, list all the tripletons:
100a + 10b + c, 100d + 10e + f, 100g + 10h + i;
100a + 10b + f, 100d + 10e + c, 100g + 10h + i; etc.

I'll leave this one to people who know some real mathematics.
 
Thanks denis. Just for that I gave those hockey tickets on center ice to my neighbor.

I am fairly sure that the problem is:

Given a target number of three or four digits, find all the sets of three three-digit numbers (leading zero is permitted) such that (1) the sum of the three numbers equals the target number, and (2) each numeral from 0 to 9 appears at most once in any of the three numbers. I have thought about that problem briefly, and it makes my head ache.

Given 100u + 10v + w, where u, v, and w are integers from 0 through 9,

(A) find every set, if any exist, {a, b, c, d, e, f, g, h, i} such that

(1) all letters in the set are integers from 0 through 9,

(2) the set {a, b, c, d, e, f, g, h, i} contains nine different integers, and

(3) 100(a + d + g) + 10(b + e + h) + (c + f + i) = 100w + 10v + u, and then

(B) For each set {a, b, c, d, e, f, g, h, i}, list all the tripletons:
100a + 10b + c, 100d + 10e + f, 100g + 10h + i;
100a + 10b + f, 100d + 10e + c, 100g + 10h + i; etc.

I'll leave this one to people who know some real mathematics.

You guys sound like real mathematicians to me - I'm more into logic seeing as I am into programming (I started before there were requirements to do real math(s)).
How would you suggest that we get someone you consider to be a "real" mathematician to help.

kdb
 
You guys sound like real mathematicians to me - I'm more into logic seeing as I am into programming (I started before there were requirements to do real math(s)).
How would you suggest that we get someone you consider to be a "real" mathematician to help.

kdb

May be consult with a professor in the University near you....
 
You guys sound like real mathematicians to me - I'm more into logic seeing as I am into programming (I started before there were requirements to do real math(s)).
How would you suggest that we get someone you consider to be a "real" mathematician to help.

kdb
IF I HAVE UNDERSTOOD YOUR PROBLEM and storage is not a problem, I can give you (I think) a simple coding solution that will operate in real time very quickly. If storage is a problem, you will have to take Subhotosh Khan's advice.

Step I: Build a preliminary table. (This is not done real time, but in advance one time.)

For your first three-digit number, you have 10 * 9 * 8 ways to construct it. For your second three-digit number, you have 7 * 6 * 5 ways. In short, to construct three three-digit numbers that use the digits 0 through 9 no more than once, there are 10! possibilities. One of them is x, y, and z. But for your purposes, x, z, and y has the same properties as x, y, and z so there are six equivalent sequences of tripletons. let's use as the identifying sequence the one where x < y < z. So, your table will need 10! / 6 = 604800 rows.

Each row will contain: first 3-digit number, second 3-digit number, third 3-digit number, their sum, and (if it is useful) the digit not used in constructing the three 3-digit numbers.

You can build the table using loops so the first four rows will look like this

012, 345, 678, 1035, 9
012, 345, 679, 1036, 8
012, 345, 687, 1044, 9
012, 345, 697, 1054, 8

Step 2: Build a sorted table and store it on disk. (Again, this can be done in advance one time)
You are going to construct a new table by sorting on the sum the preliminary table.

Step 3: Use the sorted table (which happens in real time)
Take your target number. If it is greater than the number of rows in your table, this target number has no solutions.

Otherwise, do a binary search against your stored, sorted table. On average, it should take 11 reads to find ONE of the possible solutions. Max 20 reads.

WARNING: I have not tested this. In fact, I have not coded it. I think it works, but I have written much code that I thought would work until I tested it.
 
Top