Integers in Cells puzzle (sudoko-like)
$begingroup$
All the whole numbers 2-222
are placed in the 2
bocks A absolute value sign is placed in front of some numbers. The letters 5-55
are products of 34
or 5
of the numbers. Find all realsolutions.
A=1191
B=162
C=3333
D=−4545
E=11111
F=−243335
logical-deduction sudoku
$endgroup$
add a comment |
$begingroup$
All the whole numbers 2-222
are placed in the 2
bocks A absolute value sign is placed in front of some numbers. The letters 5-55
are products of 34
or 5
of the numbers. Find all realsolutions.
A=1191
B=162
C=3333
D=−4545
E=11111
F=−243335
logical-deduction sudoku
$endgroup$
1
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago
add a comment |
$begingroup$
All the whole numbers 2-222
are placed in the 2
bocks A absolute value sign is placed in front of some numbers. The letters 5-55
are products of 34
or 5
of the numbers. Find all realsolutions.
A=1191
B=162
C=3333
D=−4545
E=11111
F=−243335
logical-deduction sudoku
$endgroup$
All the whole numbers 2-222
are placed in the 2
bocks A absolute value sign is placed in front of some numbers. The letters 5-55
are products of 34
or 5
of the numbers. Find all realsolutions.
A=1191
B=162
C=3333
D=−4545
E=11111
F=−243335
logical-deduction sudoku
logical-deduction sudoku
edited 30 mins ago
user18842sos
asked Mar 7 '18 at 0:49
user18842sosuser18842sos
1023
1023
1
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago
add a comment |
1
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago
1
1
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Completed grid without minus signs:
Signs:
One possibility is that 5 is negative and all others are positive. [EDITED to add:] No, wait, that's nonsense; thanks to "w l" for pointing that out in comments. Instead, take the following configuration: 6,3,7 are negative, all others positive. There are then three independent changes we can make that leave all the given products unchanged: we can flip the signs of all three corners (1,2,7); we can flip the signs of all of 8,6,4,3; we can flip the signs of all of 5,8,3,9. (You might look at those last two and say "what about the third option: 5,4,6,9?" That one's good too, but it's not independent: it's the same as doing both of the last two.)
Sketch of solution process:
Let's begin by ignoring the +/- signs. First of all, it's easy to get the corners: we know the product of all the cells, and then pairs like A,B give us the product of "all but X" for each corner X. Now we can look at the three remaining cells on each long side, and pin down what numbers have to be there; e.g., the remaining cells on the NW side have a product of 160, which can be implemented only as 4x5x8. The rest is straightforward.
We then
have to figure out the signs. There are 9 cells and 6 constraints on the signs (which you can think of as linear relations over the field with 2 elements, if you're feeling fancy) and it's fairly clear that they're independent: so there must be 9-6=3 independent things you can do without changing the signs of the given products, and a little trial and error suffices to discover what they are. Then we just need to find one configuration of signs that gives the right results. Considering once again the products of all numbers and all-but-a-corner, we see that the SE corner has to differ from the other two; let's make it negative and the others positive. The given products have a symmetry about the obvious line through that corner, so let's look for patterns symmetrical about that line. Then it's just a little trial and error again.
$endgroup$
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
add a comment |
$begingroup$
Here's verification that Gareth's solution is unique. I wrote a C program that just runs through every combination, with just about no smarts to speed it up since it just wasn't required. It found just the one given solution, runtime 5 milliseconds. The variables i0 through i8 correspond to triangle locations
7
012
65438
I modified it to output all possible sets of targets, and sorted them in order of "smallest total difference between all length 3 products and all length 5 products" (ie add up three differences between the three length 5 products and the three differences between the three length 3 products) and the smallest was a sum of 92, with length 6 targets (1120,1134,1152) and length three targets (40,45,54). I also checked how many sets of targets had multiple solutions. Of the 322560 sets of targets, 309888 were distinct, with 309840 being unique, 12433 having two solutions, and 48 having 6 solutions. Examples of target sets with 6 solutions are (6048, 12, 1080, 48, 840, 48) and (1680, 24, 2160, 24, 3024, 24)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int targets[6]={320,162,6048,60,756,240};
int maxval=9;
int minval=1;
unsigned long Total_secs; // time run so far
int Milli_secs; // plus millisecs
static long starttime;
// Gets the system time
void Time(int First)
{
static clock_t ticks, lticks;
ticks = clock();
if (First != 1)
{
double Tsecs;
Tsecs = ((double) ticks-lticks) / CLK_TCK;
Total_secs += (unsigned long) Tsecs;
Milli_secs += (int) (1000.0 * (Tsecs - (double) ((unsigned long) Tsecs)));
if (Milli_secs >= 1000)
{
Milli_secs -= 1000;
Total_secs++;
}
if (Milli_secs < 0)
{
Milli_secs += 1000;
Total_secs--;
}
}
else
{
Total_secs = 0;
Milli_secs = 0;
}
lticks = ticks;
}
void main(int argc, char **argv)
{
int i0,i1,i2,i3,i4,i5,i6,i7,i8,isols=0;
Time(1); // Initialise time registers
for (i0=minval;i0<=maxval;i0++)
{
for (i1=minval;i1<maxval;i1++)
{
if (i1==i0) continue;
for (i2=minval;i2<=maxval;i2++)
{
if (i2==i0 || i2==i1) continue;
if (i0*i1*i2 != targets[5]) continue;
for (i3=minval;i3<=maxval;i3++)
{
if (i3==i0 || i3==i1 || i3==i2) continue;
for (i4=minval;i4<=maxval;i4++)
{
if (i4==i0 || i4==i1 || i4==i2 || i4==i3) continue;
if (i2*i3*i4 != targets[1]) continue;
for (i5=minval;i5<=maxval;i5++)
{
if (i5==i0 || i5==i1 || i5==i2 || i5==i3 || i5==i4) continue;
if (i0*i4*i5 != targets[3]) continue;
for (i6=minval;i6<=maxval;i6++)
{
if (i6==i0 || i6==i1 || i6==i2 || i6==i3 || i6==i4 || i6==i5) continue;
for (i7=minval;i7<=maxval;i7++)
{
if (i7==i0 || i7==i1 || i7==i2 || i7==i3 || i7==i4 || i7==i5 || i7==i6) continue;
if (i6*i5*i0*i1*i7 != targets[0]) continue;
for (i8=minval;i8<=maxval;i8++)
{
if (i8==i0 || i8==i1 || i8==i2 || i8==i3 || i8==i4 || i8==i5 || i8==i6 || i8==i7) continue;
if (i7*i1*i2*i3*i8 != targets[2]) continue;
if (i8*i3*i4*i5*i6 != targets[4]) continue;
isols++;
printf("Sol %dn", isols);
printf(" %1d n",i7);
printf(" %1d%1d%1d n",i0,i1,i2);
printf("%1d%1d%1d%1d%1dn", i6,i5,i4,i3,i8);
}
}
}
}
}
}
}
}
}
printf("Found %d solsn",isols);
Time(2);
printf("Time taken: %d.%dn", Total_secs, Milli_secs);
}
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "559"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f61436%2fintegers-in-cells-puzzle-sudoko-like%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Completed grid without minus signs:
Signs:
One possibility is that 5 is negative and all others are positive. [EDITED to add:] No, wait, that's nonsense; thanks to "w l" for pointing that out in comments. Instead, take the following configuration: 6,3,7 are negative, all others positive. There are then three independent changes we can make that leave all the given products unchanged: we can flip the signs of all three corners (1,2,7); we can flip the signs of all of 8,6,4,3; we can flip the signs of all of 5,8,3,9. (You might look at those last two and say "what about the third option: 5,4,6,9?" That one's good too, but it's not independent: it's the same as doing both of the last two.)
Sketch of solution process:
Let's begin by ignoring the +/- signs. First of all, it's easy to get the corners: we know the product of all the cells, and then pairs like A,B give us the product of "all but X" for each corner X. Now we can look at the three remaining cells on each long side, and pin down what numbers have to be there; e.g., the remaining cells on the NW side have a product of 160, which can be implemented only as 4x5x8. The rest is straightforward.
We then
have to figure out the signs. There are 9 cells and 6 constraints on the signs (which you can think of as linear relations over the field with 2 elements, if you're feeling fancy) and it's fairly clear that they're independent: so there must be 9-6=3 independent things you can do without changing the signs of the given products, and a little trial and error suffices to discover what they are. Then we just need to find one configuration of signs that gives the right results. Considering once again the products of all numbers and all-but-a-corner, we see that the SE corner has to differ from the other two; let's make it negative and the others positive. The given products have a symmetry about the obvious line through that corner, so let's look for patterns symmetrical about that line. Then it's just a little trial and error again.
$endgroup$
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
add a comment |
$begingroup$
Completed grid without minus signs:
Signs:
One possibility is that 5 is negative and all others are positive. [EDITED to add:] No, wait, that's nonsense; thanks to "w l" for pointing that out in comments. Instead, take the following configuration: 6,3,7 are negative, all others positive. There are then three independent changes we can make that leave all the given products unchanged: we can flip the signs of all three corners (1,2,7); we can flip the signs of all of 8,6,4,3; we can flip the signs of all of 5,8,3,9. (You might look at those last two and say "what about the third option: 5,4,6,9?" That one's good too, but it's not independent: it's the same as doing both of the last two.)
Sketch of solution process:
Let's begin by ignoring the +/- signs. First of all, it's easy to get the corners: we know the product of all the cells, and then pairs like A,B give us the product of "all but X" for each corner X. Now we can look at the three remaining cells on each long side, and pin down what numbers have to be there; e.g., the remaining cells on the NW side have a product of 160, which can be implemented only as 4x5x8. The rest is straightforward.
We then
have to figure out the signs. There are 9 cells and 6 constraints on the signs (which you can think of as linear relations over the field with 2 elements, if you're feeling fancy) and it's fairly clear that they're independent: so there must be 9-6=3 independent things you can do without changing the signs of the given products, and a little trial and error suffices to discover what they are. Then we just need to find one configuration of signs that gives the right results. Considering once again the products of all numbers and all-but-a-corner, we see that the SE corner has to differ from the other two; let's make it negative and the others positive. The given products have a symmetry about the obvious line through that corner, so let's look for patterns symmetrical about that line. Then it's just a little trial and error again.
$endgroup$
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
add a comment |
$begingroup$
Completed grid without minus signs:
Signs:
One possibility is that 5 is negative and all others are positive. [EDITED to add:] No, wait, that's nonsense; thanks to "w l" for pointing that out in comments. Instead, take the following configuration: 6,3,7 are negative, all others positive. There are then three independent changes we can make that leave all the given products unchanged: we can flip the signs of all three corners (1,2,7); we can flip the signs of all of 8,6,4,3; we can flip the signs of all of 5,8,3,9. (You might look at those last two and say "what about the third option: 5,4,6,9?" That one's good too, but it's not independent: it's the same as doing both of the last two.)
Sketch of solution process:
Let's begin by ignoring the +/- signs. First of all, it's easy to get the corners: we know the product of all the cells, and then pairs like A,B give us the product of "all but X" for each corner X. Now we can look at the three remaining cells on each long side, and pin down what numbers have to be there; e.g., the remaining cells on the NW side have a product of 160, which can be implemented only as 4x5x8. The rest is straightforward.
We then
have to figure out the signs. There are 9 cells and 6 constraints on the signs (which you can think of as linear relations over the field with 2 elements, if you're feeling fancy) and it's fairly clear that they're independent: so there must be 9-6=3 independent things you can do without changing the signs of the given products, and a little trial and error suffices to discover what they are. Then we just need to find one configuration of signs that gives the right results. Considering once again the products of all numbers and all-but-a-corner, we see that the SE corner has to differ from the other two; let's make it negative and the others positive. The given products have a symmetry about the obvious line through that corner, so let's look for patterns symmetrical about that line. Then it's just a little trial and error again.
$endgroup$
Completed grid without minus signs:
Signs:
One possibility is that 5 is negative and all others are positive. [EDITED to add:] No, wait, that's nonsense; thanks to "w l" for pointing that out in comments. Instead, take the following configuration: 6,3,7 are negative, all others positive. There are then three independent changes we can make that leave all the given products unchanged: we can flip the signs of all three corners (1,2,7); we can flip the signs of all of 8,6,4,3; we can flip the signs of all of 5,8,3,9. (You might look at those last two and say "what about the third option: 5,4,6,9?" That one's good too, but it's not independent: it's the same as doing both of the last two.)
Sketch of solution process:
Let's begin by ignoring the +/- signs. First of all, it's easy to get the corners: we know the product of all the cells, and then pairs like A,B give us the product of "all but X" for each corner X. Now we can look at the three remaining cells on each long side, and pin down what numbers have to be there; e.g., the remaining cells on the NW side have a product of 160, which can be implemented only as 4x5x8. The rest is straightforward.
We then
have to figure out the signs. There are 9 cells and 6 constraints on the signs (which you can think of as linear relations over the field with 2 elements, if you're feeling fancy) and it's fairly clear that they're independent: so there must be 9-6=3 independent things you can do without changing the signs of the given products, and a little trial and error suffices to discover what they are. Then we just need to find one configuration of signs that gives the right results. Considering once again the products of all numbers and all-but-a-corner, we see that the SE corner has to differ from the other two; let's make it negative and the others positive. The given products have a symmetry about the obvious line through that corner, so let's look for patterns symmetrical about that line. Then it's just a little trial and error again.
edited Mar 7 '18 at 10:31
answered Mar 7 '18 at 1:35
Gareth McCaughan♦Gareth McCaughan
63.5k3163248
63.5k3163248
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
add a comment |
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Having only the 5 negative does not work, because then A would be negative as well. It might also be nice to add the simplified constraints: same sign: 2 and 1 as well as 5 and 9; different sign: 8 and 3, 6 and 4 as well as 1 and 7 (plus any of the original constraint).
$endgroup$
– w l
Mar 7 '18 at 10:00
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Oops, you're right. Will fix the discussion of signs. ... Now done; thanks!
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:18
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Just wanted to add this remark on solving the numbers without the sign: 5 and 7 have only 1 multiple in the range of numbers we have to use, so looking at which products they divide (A, F and D for 5, and C and E for 7), you know where to put them.
$endgroup$
– Florian Bourse
Mar 7 '18 at 10:53
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
$begingroup$
Yup. (My answer was kinda sketchy on the details, but that was indeed part of the mental process.)
$endgroup$
– Gareth McCaughan♦
Mar 7 '18 at 10:57
add a comment |
$begingroup$
Here's verification that Gareth's solution is unique. I wrote a C program that just runs through every combination, with just about no smarts to speed it up since it just wasn't required. It found just the one given solution, runtime 5 milliseconds. The variables i0 through i8 correspond to triangle locations
7
012
65438
I modified it to output all possible sets of targets, and sorted them in order of "smallest total difference between all length 3 products and all length 5 products" (ie add up three differences between the three length 5 products and the three differences between the three length 3 products) and the smallest was a sum of 92, with length 6 targets (1120,1134,1152) and length three targets (40,45,54). I also checked how many sets of targets had multiple solutions. Of the 322560 sets of targets, 309888 were distinct, with 309840 being unique, 12433 having two solutions, and 48 having 6 solutions. Examples of target sets with 6 solutions are (6048, 12, 1080, 48, 840, 48) and (1680, 24, 2160, 24, 3024, 24)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int targets[6]={320,162,6048,60,756,240};
int maxval=9;
int minval=1;
unsigned long Total_secs; // time run so far
int Milli_secs; // plus millisecs
static long starttime;
// Gets the system time
void Time(int First)
{
static clock_t ticks, lticks;
ticks = clock();
if (First != 1)
{
double Tsecs;
Tsecs = ((double) ticks-lticks) / CLK_TCK;
Total_secs += (unsigned long) Tsecs;
Milli_secs += (int) (1000.0 * (Tsecs - (double) ((unsigned long) Tsecs)));
if (Milli_secs >= 1000)
{
Milli_secs -= 1000;
Total_secs++;
}
if (Milli_secs < 0)
{
Milli_secs += 1000;
Total_secs--;
}
}
else
{
Total_secs = 0;
Milli_secs = 0;
}
lticks = ticks;
}
void main(int argc, char **argv)
{
int i0,i1,i2,i3,i4,i5,i6,i7,i8,isols=0;
Time(1); // Initialise time registers
for (i0=minval;i0<=maxval;i0++)
{
for (i1=minval;i1<maxval;i1++)
{
if (i1==i0) continue;
for (i2=minval;i2<=maxval;i2++)
{
if (i2==i0 || i2==i1) continue;
if (i0*i1*i2 != targets[5]) continue;
for (i3=minval;i3<=maxval;i3++)
{
if (i3==i0 || i3==i1 || i3==i2) continue;
for (i4=minval;i4<=maxval;i4++)
{
if (i4==i0 || i4==i1 || i4==i2 || i4==i3) continue;
if (i2*i3*i4 != targets[1]) continue;
for (i5=minval;i5<=maxval;i5++)
{
if (i5==i0 || i5==i1 || i5==i2 || i5==i3 || i5==i4) continue;
if (i0*i4*i5 != targets[3]) continue;
for (i6=minval;i6<=maxval;i6++)
{
if (i6==i0 || i6==i1 || i6==i2 || i6==i3 || i6==i4 || i6==i5) continue;
for (i7=minval;i7<=maxval;i7++)
{
if (i7==i0 || i7==i1 || i7==i2 || i7==i3 || i7==i4 || i7==i5 || i7==i6) continue;
if (i6*i5*i0*i1*i7 != targets[0]) continue;
for (i8=minval;i8<=maxval;i8++)
{
if (i8==i0 || i8==i1 || i8==i2 || i8==i3 || i8==i4 || i8==i5 || i8==i6 || i8==i7) continue;
if (i7*i1*i2*i3*i8 != targets[2]) continue;
if (i8*i3*i4*i5*i6 != targets[4]) continue;
isols++;
printf("Sol %dn", isols);
printf(" %1d n",i7);
printf(" %1d%1d%1d n",i0,i1,i2);
printf("%1d%1d%1d%1d%1dn", i6,i5,i4,i3,i8);
}
}
}
}
}
}
}
}
}
printf("Found %d solsn",isols);
Time(2);
printf("Time taken: %d.%dn", Total_secs, Milli_secs);
}
$endgroup$
add a comment |
$begingroup$
Here's verification that Gareth's solution is unique. I wrote a C program that just runs through every combination, with just about no smarts to speed it up since it just wasn't required. It found just the one given solution, runtime 5 milliseconds. The variables i0 through i8 correspond to triangle locations
7
012
65438
I modified it to output all possible sets of targets, and sorted them in order of "smallest total difference between all length 3 products and all length 5 products" (ie add up three differences between the three length 5 products and the three differences between the three length 3 products) and the smallest was a sum of 92, with length 6 targets (1120,1134,1152) and length three targets (40,45,54). I also checked how many sets of targets had multiple solutions. Of the 322560 sets of targets, 309888 were distinct, with 309840 being unique, 12433 having two solutions, and 48 having 6 solutions. Examples of target sets with 6 solutions are (6048, 12, 1080, 48, 840, 48) and (1680, 24, 2160, 24, 3024, 24)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int targets[6]={320,162,6048,60,756,240};
int maxval=9;
int minval=1;
unsigned long Total_secs; // time run so far
int Milli_secs; // plus millisecs
static long starttime;
// Gets the system time
void Time(int First)
{
static clock_t ticks, lticks;
ticks = clock();
if (First != 1)
{
double Tsecs;
Tsecs = ((double) ticks-lticks) / CLK_TCK;
Total_secs += (unsigned long) Tsecs;
Milli_secs += (int) (1000.0 * (Tsecs - (double) ((unsigned long) Tsecs)));
if (Milli_secs >= 1000)
{
Milli_secs -= 1000;
Total_secs++;
}
if (Milli_secs < 0)
{
Milli_secs += 1000;
Total_secs--;
}
}
else
{
Total_secs = 0;
Milli_secs = 0;
}
lticks = ticks;
}
void main(int argc, char **argv)
{
int i0,i1,i2,i3,i4,i5,i6,i7,i8,isols=0;
Time(1); // Initialise time registers
for (i0=minval;i0<=maxval;i0++)
{
for (i1=minval;i1<maxval;i1++)
{
if (i1==i0) continue;
for (i2=minval;i2<=maxval;i2++)
{
if (i2==i0 || i2==i1) continue;
if (i0*i1*i2 != targets[5]) continue;
for (i3=minval;i3<=maxval;i3++)
{
if (i3==i0 || i3==i1 || i3==i2) continue;
for (i4=minval;i4<=maxval;i4++)
{
if (i4==i0 || i4==i1 || i4==i2 || i4==i3) continue;
if (i2*i3*i4 != targets[1]) continue;
for (i5=minval;i5<=maxval;i5++)
{
if (i5==i0 || i5==i1 || i5==i2 || i5==i3 || i5==i4) continue;
if (i0*i4*i5 != targets[3]) continue;
for (i6=minval;i6<=maxval;i6++)
{
if (i6==i0 || i6==i1 || i6==i2 || i6==i3 || i6==i4 || i6==i5) continue;
for (i7=minval;i7<=maxval;i7++)
{
if (i7==i0 || i7==i1 || i7==i2 || i7==i3 || i7==i4 || i7==i5 || i7==i6) continue;
if (i6*i5*i0*i1*i7 != targets[0]) continue;
for (i8=minval;i8<=maxval;i8++)
{
if (i8==i0 || i8==i1 || i8==i2 || i8==i3 || i8==i4 || i8==i5 || i8==i6 || i8==i7) continue;
if (i7*i1*i2*i3*i8 != targets[2]) continue;
if (i8*i3*i4*i5*i6 != targets[4]) continue;
isols++;
printf("Sol %dn", isols);
printf(" %1d n",i7);
printf(" %1d%1d%1d n",i0,i1,i2);
printf("%1d%1d%1d%1d%1dn", i6,i5,i4,i3,i8);
}
}
}
}
}
}
}
}
}
printf("Found %d solsn",isols);
Time(2);
printf("Time taken: %d.%dn", Total_secs, Milli_secs);
}
$endgroup$
add a comment |
$begingroup$
Here's verification that Gareth's solution is unique. I wrote a C program that just runs through every combination, with just about no smarts to speed it up since it just wasn't required. It found just the one given solution, runtime 5 milliseconds. The variables i0 through i8 correspond to triangle locations
7
012
65438
I modified it to output all possible sets of targets, and sorted them in order of "smallest total difference between all length 3 products and all length 5 products" (ie add up three differences between the three length 5 products and the three differences between the three length 3 products) and the smallest was a sum of 92, with length 6 targets (1120,1134,1152) and length three targets (40,45,54). I also checked how many sets of targets had multiple solutions. Of the 322560 sets of targets, 309888 were distinct, with 309840 being unique, 12433 having two solutions, and 48 having 6 solutions. Examples of target sets with 6 solutions are (6048, 12, 1080, 48, 840, 48) and (1680, 24, 2160, 24, 3024, 24)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int targets[6]={320,162,6048,60,756,240};
int maxval=9;
int minval=1;
unsigned long Total_secs; // time run so far
int Milli_secs; // plus millisecs
static long starttime;
// Gets the system time
void Time(int First)
{
static clock_t ticks, lticks;
ticks = clock();
if (First != 1)
{
double Tsecs;
Tsecs = ((double) ticks-lticks) / CLK_TCK;
Total_secs += (unsigned long) Tsecs;
Milli_secs += (int) (1000.0 * (Tsecs - (double) ((unsigned long) Tsecs)));
if (Milli_secs >= 1000)
{
Milli_secs -= 1000;
Total_secs++;
}
if (Milli_secs < 0)
{
Milli_secs += 1000;
Total_secs--;
}
}
else
{
Total_secs = 0;
Milli_secs = 0;
}
lticks = ticks;
}
void main(int argc, char **argv)
{
int i0,i1,i2,i3,i4,i5,i6,i7,i8,isols=0;
Time(1); // Initialise time registers
for (i0=minval;i0<=maxval;i0++)
{
for (i1=minval;i1<maxval;i1++)
{
if (i1==i0) continue;
for (i2=minval;i2<=maxval;i2++)
{
if (i2==i0 || i2==i1) continue;
if (i0*i1*i2 != targets[5]) continue;
for (i3=minval;i3<=maxval;i3++)
{
if (i3==i0 || i3==i1 || i3==i2) continue;
for (i4=minval;i4<=maxval;i4++)
{
if (i4==i0 || i4==i1 || i4==i2 || i4==i3) continue;
if (i2*i3*i4 != targets[1]) continue;
for (i5=minval;i5<=maxval;i5++)
{
if (i5==i0 || i5==i1 || i5==i2 || i5==i3 || i5==i4) continue;
if (i0*i4*i5 != targets[3]) continue;
for (i6=minval;i6<=maxval;i6++)
{
if (i6==i0 || i6==i1 || i6==i2 || i6==i3 || i6==i4 || i6==i5) continue;
for (i7=minval;i7<=maxval;i7++)
{
if (i7==i0 || i7==i1 || i7==i2 || i7==i3 || i7==i4 || i7==i5 || i7==i6) continue;
if (i6*i5*i0*i1*i7 != targets[0]) continue;
for (i8=minval;i8<=maxval;i8++)
{
if (i8==i0 || i8==i1 || i8==i2 || i8==i3 || i8==i4 || i8==i5 || i8==i6 || i8==i7) continue;
if (i7*i1*i2*i3*i8 != targets[2]) continue;
if (i8*i3*i4*i5*i6 != targets[4]) continue;
isols++;
printf("Sol %dn", isols);
printf(" %1d n",i7);
printf(" %1d%1d%1d n",i0,i1,i2);
printf("%1d%1d%1d%1d%1dn", i6,i5,i4,i3,i8);
}
}
}
}
}
}
}
}
}
printf("Found %d solsn",isols);
Time(2);
printf("Time taken: %d.%dn", Total_secs, Milli_secs);
}
$endgroup$
Here's verification that Gareth's solution is unique. I wrote a C program that just runs through every combination, with just about no smarts to speed it up since it just wasn't required. It found just the one given solution, runtime 5 milliseconds. The variables i0 through i8 correspond to triangle locations
7
012
65438
I modified it to output all possible sets of targets, and sorted them in order of "smallest total difference between all length 3 products and all length 5 products" (ie add up three differences between the three length 5 products and the three differences between the three length 3 products) and the smallest was a sum of 92, with length 6 targets (1120,1134,1152) and length three targets (40,45,54). I also checked how many sets of targets had multiple solutions. Of the 322560 sets of targets, 309888 were distinct, with 309840 being unique, 12433 having two solutions, and 48 having 6 solutions. Examples of target sets with 6 solutions are (6048, 12, 1080, 48, 840, 48) and (1680, 24, 2160, 24, 3024, 24)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int targets[6]={320,162,6048,60,756,240};
int maxval=9;
int minval=1;
unsigned long Total_secs; // time run so far
int Milli_secs; // plus millisecs
static long starttime;
// Gets the system time
void Time(int First)
{
static clock_t ticks, lticks;
ticks = clock();
if (First != 1)
{
double Tsecs;
Tsecs = ((double) ticks-lticks) / CLK_TCK;
Total_secs += (unsigned long) Tsecs;
Milli_secs += (int) (1000.0 * (Tsecs - (double) ((unsigned long) Tsecs)));
if (Milli_secs >= 1000)
{
Milli_secs -= 1000;
Total_secs++;
}
if (Milli_secs < 0)
{
Milli_secs += 1000;
Total_secs--;
}
}
else
{
Total_secs = 0;
Milli_secs = 0;
}
lticks = ticks;
}
void main(int argc, char **argv)
{
int i0,i1,i2,i3,i4,i5,i6,i7,i8,isols=0;
Time(1); // Initialise time registers
for (i0=minval;i0<=maxval;i0++)
{
for (i1=minval;i1<maxval;i1++)
{
if (i1==i0) continue;
for (i2=minval;i2<=maxval;i2++)
{
if (i2==i0 || i2==i1) continue;
if (i0*i1*i2 != targets[5]) continue;
for (i3=minval;i3<=maxval;i3++)
{
if (i3==i0 || i3==i1 || i3==i2) continue;
for (i4=minval;i4<=maxval;i4++)
{
if (i4==i0 || i4==i1 || i4==i2 || i4==i3) continue;
if (i2*i3*i4 != targets[1]) continue;
for (i5=minval;i5<=maxval;i5++)
{
if (i5==i0 || i5==i1 || i5==i2 || i5==i3 || i5==i4) continue;
if (i0*i4*i5 != targets[3]) continue;
for (i6=minval;i6<=maxval;i6++)
{
if (i6==i0 || i6==i1 || i6==i2 || i6==i3 || i6==i4 || i6==i5) continue;
for (i7=minval;i7<=maxval;i7++)
{
if (i7==i0 || i7==i1 || i7==i2 || i7==i3 || i7==i4 || i7==i5 || i7==i6) continue;
if (i6*i5*i0*i1*i7 != targets[0]) continue;
for (i8=minval;i8<=maxval;i8++)
{
if (i8==i0 || i8==i1 || i8==i2 || i8==i3 || i8==i4 || i8==i5 || i8==i6 || i8==i7) continue;
if (i7*i1*i2*i3*i8 != targets[2]) continue;
if (i8*i3*i4*i5*i6 != targets[4]) continue;
isols++;
printf("Sol %dn", isols);
printf(" %1d n",i7);
printf(" %1d%1d%1d n",i0,i1,i2);
printf("%1d%1d%1d%1d%1dn", i6,i5,i4,i3,i8);
}
}
}
}
}
}
}
}
}
printf("Found %d solsn",isols);
Time(2);
printf("Time taken: %d.%dn", Total_secs, Milli_secs);
}
edited Mar 7 '18 at 11:33
answered Mar 7 '18 at 6:19
theonetruepaththeonetruepath
1,6691316
1,6691316
add a comment |
add a comment |
Thanks for contributing an answer to Puzzling Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fpuzzling.stackexchange.com%2fquestions%2f61436%2fintegers-in-cells-puzzle-sudoko-like%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license for SE to distribute that content. By SE policy, any vandalism will be reverted. If you want to know more about deleting a post, consider taking a look at: How does deleting work?
$endgroup$
– iBot
1 hour ago