domino puzzle

Started by Noogy, February 07, 2012, 04:46:03 AM

Previous topic - Next topic

Noogy

i need help with a puzzle!

say you could arrange 8 dominoes in a 2x4 arrangement like this:


where each domino can be in either orientation, and you can use one of each domino once.
in the image above, the first column adds up to 9, while the first row adds up to 3.
how could you arrange it so that the columns, rows, and diagonals all add up to 6?

Shuey

Hey, it's good to see you back Noogy!  If I get time today, I'll look at this in more detail.  We have to use THESE pieces, correct?  And when you say the diagonals, can you maybe draw a line showing exactly what you mean?

PS: My perfect clear study got off to a good start, but appears to have had a quick death .

Noogy

#2
hello
no you can use any dominoes (0,0) (0,1) etc, as long as you use it once.
as for diagonals, there are only two going from corner to corner

as for pc's, i noticed something neat when trying to make some. it may seem intuitive to some, but i thought it was nifty

[fumen]110@9bYi1lgbKwibYi1lgb1lIwibZihb1lCcRpiblzhbTp?gbnzhbRpiblzFdA4G9boUNRgb6GiboUNRgbNR4GibpUhbNR?CcxNibdDhbzNgbfDhbxNibdDJcJ3hb/enb1llbRp1lmbRpu?bAAA/dJ3hbEY0lIwEYlbTpmbEYgbQpmbFYubAAA/dJ3ibxN?0llbzNlbwNNRcDmbNRubGhB/dJ3hbJw0lMRmbss0lMRmbFY?oUQplbssQpoUtbAAA[/fumen]
when making them, sometimes i try to group them into common shapes that usually allow for many piece combinations (frame 1)

you can tell which "chunks" will never work in a pc if they are at a height of 4 blocks anywhere along the chunk
just see if the area on both sides of the chunk are divisible by 4!

which is why frames 2 3 and 5 would never work in a pc while 4 would

this kinda explains why myndzis thing might be an impossible pc since there aren't that many things you could do with O's other than stack them on top of each other, and your options with S/Z are limited

myndzi

#3
You still don't define 'diagonals' well. Is it the bottom two on one side and the top two on the other?

Nevermind, duh. Each value on the dominos, so it's 4x4 values even though it's 4x2 pieces.

Shuey

#4
If we're stuck using ONLY these pieces (which I fully assume is correct, otherwise why would you post THESE specific pieces, right, lol?), this appears to be impossible.

In order to have a row add up to ONLY "6", using the piece [0/6], you'd be screwed when you put it in the same row with any of the pieces that have no 0 amount (ex: [2/2], [2/3], etc).

I have a feeling I am just misunderstanding your goal because of the way it was explained...

EDIT: I entered this reply before refreshing the page, so I didn't see your replies until after.  I'm still a little lost though .

caffeine

#5
Are these the only dominoes we may select from? Must it be in a 4x2 configuration? If so, then this is not possible (unless I've misunderstood the rules).

Just noticed Shuey already beat me to it.

myndzi

#6
Quote from: myndzi
You still don't define 'diagonals' well. Is it the bottom two on one side and the top two on the other?

Nevermind, duh. Each value on the dominos, so it's 4x4 values even though it's 4x2 pieces.

Proud to say I worked it out with logic rather than intuition.

[spoiler]
  • [1]
  • [5]
    [3] [3]


  • [2]
  • [3] [1]
    [1] [2] [3]

  • [/spoiler]

Shuey

Nice job myndzi.  Of course that's just ONE solution since any non-repeating set of 8 total dominoes can be used.  I still don't get how the diagonals work though...

Pikiwedia

#8
Quote from: Shuey
I still don't get how the diagonals work though...

I'm not sure what's hard to understand. There are two diagonals; Upper left to bottom right & lower left to upper right. Hence, corner to corner.

If you looked at Myndzi's solution, the diagonals would be 0,3,3,0 & 1,0,0,5.
[div align=\\\"center\\\"][/div]

Noogy

Quote from: myndzi
Proud to say I worked it out with logic rather than intuition.

[spoiler]
  • [1]
  • [5]
    [3] [3]


  • [2]
  • [3] [1]
    [1] [2] [3]

  • [/spoiler]
wow ty... for some reason i thought the solution would be nothing but dominoes with values of 0-3...well done!

Shuey

Quote from: Pikiwedia
I'm not sure what's hard to understand. There are two diagonals; Upper left to bottom right & lower left to upper right. Hence, corner to corner.

If you looked at Myndzi's solution, the diagonals would be 0,3,3,0 & 1,0,0,5.

It's not hard to understand when you know what diagonals he was specifically referring to, lol.  I totally see what you mean now that you clarified it.

myndzi

#11
It's not just "any". There are certain ways you can rearrange this one, but I'm reasonably certain that you need these numbers in these quantities.

Explanation:

[spoiler]
Numbers placed on the axes are involved in nine sums each; others are involved in two sums each.

Sixes cannot be used; if they are on the diagonals they invalidate too many other squares (9) to fill the rest with unique dominoes, since all squares aligning with a 6 must be 0.

If a 6 is on one of the sides, it only invalidates six squares, but it still invalidates an entire row and column. This means you'd use the 6-0, the 0-0, and 0-1, 0-2, 0-3. The remaining three spaces must be filled with three dominoes that add up to 3, 4, and 5 respectively, but can't be 0-1 0-2, or 0-3. 2-1 therefore, and 3-1 4-1 are possibilities, but you can't arrange them so that their horizontal sections add up to six. In fact, on the domino totalling to 5, the other two must be one, meaning that the final two must be 1-2 and 1-3. You can *almost* make this work, save the final diagonal.

The final diagonal cannot be six because no matter where you place a six on the sides, it creates two zeroes in a row and the remaining dominoes cannot be arranged in such a way that they satisfy all properties and have two threes on the remaining diagonal.

We go to fives, then. Fives give us more leeway: where you place one, it can support two zeroes and a one on axes that align with it. Using the same process of elimination as above, I placed the 5 in a corner to afford maximum flexibility (it affects three rows, but at the same time using three 1-X dominoes was desirable. There are also no extra or superfluous 1s which keeps the numerical balance.)

I realized that these ones could not be aligned with each other, and so I placed them sudoku-like so that they did not line up. This left me three axes to fill in with zeroes. I then had two lines with only two spaces left and the other two zeroes - these had to be 3s, 2/4, 1/5, or 0/6. Given the other values involved, 3 was the only choice that could combine with the 1s, so I placed three 3s in a non-intersecting arrangement, each paired with a 1. This gave me 4s on all axes that weren't 6. I expected to fill in the rest with 2 but saw immediately that this caused me to have a duplicate domino and was able to rearrange the symmetries to maintain all the properties I needed.

I found the answer at five, but before I took this approach I spent a deal of time working with numbers <=3 and was unable to avoid repeats. After thinking about it, I understood that there are not two sets of combinations of four dominoes that satisfy the horizontal sum; there are 3-3-0-0, 3-2-1-0, 3-1-1-1, 2-2-2-0, 2-2-1-1 = five combinations of these numbers that add to six, so each axis would have to be one of these combinations (in any order). Any combination of four of these cannot wind up with all values being <= 4 in total count except for 3-2-1-0 four times. Since requiring > 4 of one number is impossible: x-0, x-1, x-2, x-3, x-????, we only have one case left to examine...

It turns out there's one more solution:
  • [2] [3] [1]
    [3] [1]
  • [2]

    [1] [3] [2]

  • [2]
  • [1] [3]

    I arrived at this one by first arranging the diagonals with one of each value, which required that there be one of each on the inside square and one of each on the outside diagonals, then filling the rest in in similar fashion.
    [/spoiler]

    Edited^

    Wojtek: interesting, but that's kind of cheating... you might at least spoiler your answers for anyone who wants to try themselves.

Wojtek

#12
such problems can be easily solved with CLP.

here is my solution in swi-prolog (not very elegant):

:- [library(clpfd)].

% constrain [A,B] to be different domino than [C,D]
diff_dom([A,B],[C,D]):- (A #\= C #\/ B #\= D) #/\ (B #\= C #\/ A #\= D).

% M and N are numbers in 1..8 such M<N
d(M,N):- numlist(1,8,L), select(M,L,L1), select(N,L1,_), M < N.

% constrain Nth and Mth dominos from list L to be different
di(L,(M,N)):-
    nth1(N,L,A),
    nth1(M,L,B),
    diff_dom(A,B).

% show solution (it's rotated 90 degrees for simplicity of code)
write_dom(L):-
    L = [Q,W,E,R,T,Y,U,I],
    write(Q),write(W),nl,
    write(E),write(R),nl,
    write(T),write(Y),nl,
    write(U),write(I),nl,
    nl.

% solve dominos puzzle
noogy(Dominos):- Dominos = [[A1,B1],[C1,D1],
    [A2,B2],[C2,D2],
    [A3,B3],[C3,D3],
    [A4,B4],[C4,D4]],

    % numbers on dominos are in 0..6
    flatten(Dominos,Vars),
    Vars ins 0..6,

    % all columns sum to 6
    A1+B1+C1+D1 #= 6,
    A2+B2+C2+D2 #= 6,
    A3+B3+C3+D3 #= 6,
    A4+B4+C4+D4 #= 6,

    % all rows sum to 6
    A1+A2+A3+A4 #= 6,
    B1+B2+B3+B4 #= 6,
    C1+C2+C3+C4 #= 6,
    D1+D2+D3+D4 #= 6,

    % diagonals sum to 6
    A1+B2+C3+D4 #= 6,
    A4+B3+C2+D1 #= 6,

    % let Pairs to be list of pairs of different indexes of domino list
    findall((M,N),d(M,N), Pairs),
    
    % for every such pair constrain dominos of those indexes are different
    maplist(di(Dominos), Pairs),
    
    label(Vars),
    write_dom(Dominos).


output showing few example solution and number of diffrent solutions:
4 ?- noogy(X).
[0,0][1,5]
[1,4][0,1]
[4,0][2,0]
[1,2][3,0]

X = [[0, 0], [1, 5], [1, 4], [0, 1], [4, 0], [2, 0], [1, 2], [3|...]];
[0,0][1,5]
[2,3][1,0]
[4,0][2,0]
[0,3][2,1]

X = [[0, 0], [1, 5], [2, 3], [1, 0], [4, 0], [2, 0], [0, 3], [2|...]];
[0,0][2,4]
[0,5][0,1]
[4,0][1,1]
[2,1][3,0]

X = [[0, 0], [2, 4], [0, 5], [0, 1], [4, 0], [1, 1], [2, 1]

5 ?- findall(X,noogy(X),L),length(L,N).

....

L = [[[0, 0], [1, 5], [1, 4], [0, 1], [4, 0], [2, 0], [1|...], [...|...]], [[0, 0], [1, 5], [2, 3], [1, 0], [4, 0], [2|...], [...|...]|...], [[0, 0], [2, 4], [0, 5], [0, 1], [4|...], [...|...]|...], [[0, 0], [2, 4], [1, 3], [2|...], [...|...]|...], [[0, 0], [2, 4], [1|...], [...|...]|...], [[0, 0], [2|...], [...|...]|...], [[0|...], [...|...]|...], [[...|...]|...], [...|...]|...],
N = 392.
Recommended games:
NullpoMino
Tetris Online Poland

xlro

+1 Wojtek, for use of Prolog
[div align=\\\"center\\\"]NullpoMino[/div]