Thursday, October 15, 2009

Ace, King and Queen

Place a Ace (A), a Queen (Q) and a King (K) on three slots in a row like AQK (A on extreme left, K on extreme right). Reverse the position of the cards (ie, KQA) in the least possible number of moves. In a valid move, a card can be moved either left or right into an empty slot or placed onto a card of a higher rank. (eg, a Q can be placed on a K, but not vice-versa). Also, only the top card of the stack can be moved. Now, what is the least number of moves required if:
(a) there are only three slots?
(b) there is an empty slot to the left of the Ace?
(c) there is an empty slot to the right of the King?

Labels: ,

23 Comments:

Blogger Ragknot said...

It says...

"In a valid move, a card can be ...

....placed onto a card of a higher rank. (eg, a A can be placed on a K, but not vice-versa)."

A is not higher than a K is it?
This seems to contradict itself.

October 15, 2009 3:57 PM  
Blogger Ragknot said...

Only 3 slots? No!

It looks like it's describing 5 slots, if theres and empty one left of the A and another right of the K.

You only need 4 slots.
Put the king in the empty slot beside the ace, move the ace where the king was, then place the king where the ace was.

October 15, 2009 4:02 PM  
Anonymous Anonymous said...

This is a preliminary guess before I go to a group meeting, but the way I see it, regardless of slots to the left or right, I can do it in four moves:

Move K on top of Q.
Move A on top of K/Q.
Move A to right slot.
Move K to left slot.

But, I'm assuming since you asked the last two questions, one of the implied rules was that you cannot have all three cards stacked. Will work more later.

October 15, 2009 4:51 PM  
Anonymous Anonymous said...

Actually, I thought of another way:

Turn all the cards around, then walk to the other side of the table.

Zero moves! Or three, if you'd like. :P

October 15, 2009 4:58 PM  
Blogger Chris said...

Thhe following seems to be ridiculously long (6 moves) but:

-AQK-
--(A/Q)K-
--Q(A/K)-
--QKA
--(K/Q)-A
-KQ-A
-KQA-

I'm assuming you have to end up in the three middle slots.

October 15, 2009 5:37 PM  
Blogger Chris said...

I see that's what Ragknot said, except I inverted A and K.

Anonymous 4:51 seems to have a reasonable interpretation.

Is the 5 slots a red-herring?

October 15, 2009 5:50 PM  
Blogger Chris said...

aaarrgh. Not sure which way to read highest card rule - but that just corresponds to a mirror solution.

October 15, 2009 5:58 PM  
Anonymous Anonymous said...

Okay there are only three slots.

So, you would have to do:
AQK
-(A/Q)K
-Q(A/K)
Q-(A/K)
QAK
(A/Q)-K
(A/Q)K-
A(Q/K)-
AKQ
-(A/K)Q
-K(A/Q)
K-(A/Q)
KAQ
(A/K)-Q
(A/K)Q-
K(A/Q)-
KQA
16 moves.

Then if there is a space next to the Ace,
-AQK
A-QK
AQ-K
AQK-
-(A/Q)K-
-Q(A/K)-
-QKA
Q-KA
QK-A
-(Q/K)-A
-KQA
10 moves

Then, if there's a space next to the King,
AQK-
-(A/Q)K-
-Q(A/K)-
-QKA
Q-KA
QK-A
-(Q/K)-A
-KQA
7 moves

October 15, 2009 6:10 PM  
Blogger Ragknot said...

I assume there's an error.


And possibly it is way I understand ... or misunderstand the Trick.

October 15, 2009 6:42 PM  
Blogger Ragknot said...

The best answer I think... Is one move... walk your self around to the other side of the table.

That was cool.

October 15, 2009 6:44 PM  
Blogger Chris said...

Can improve Anonymous's scenario 2.

-AQK
A-QK
A-(K/Q)-
AKQ-
-(A/K)Q-
-K(A/Q)-
-KQA

that's only 6 moves rather than 10.

I'm beginning to believe that there aren't some more cunning solutions.

October 15, 2009 7:26 PM  
Blogger Chris said...

Also Scenario 3

AQK-
-(A/Q)K-
-Q(A/K)-
-QKA
-(K/Q)-A
KQ-A
KQA-

6 rather than 7 moves.

But for scenario 1, there seem to be no options (without simply going backwards).

October 15, 2009 7:33 PM  
Blogger Rajesh Lal said...

Ragknot your first comment is a valid point, my bad . I have changed that now to Q can be placed on K.

October 15, 2009 7:36 PM  
Blogger Chris said...

Hi Rajesh. We've already finished the problem, having recognised and overridden the conflict in the original rules, but with the reversed rule. We'd only be repeating ourselves, unless there really is something we've missed.

October 15, 2009 7:45 PM  
Blogger Kurt said...

I think it can be solved with 3 slots in 20 moves

AQK
.(QA)K
.Q(KA)
Q.(KA)
QAK
(QA).K
(QA)K.
Q(KA).
QKA
.(KQ)A
.(KQA).
A(KQ).
AKQ
.(KA)Q
.K(QA)
K.(QA)
KAQ
(KA).Q
(KA)Q.
K(QA).
KQA

October 16, 2009 12:26 AM  
Blogger ionutz said...

I.scenario 1:
(11 movements) from AQK:

A_[K/Q]
_A[K/Q]
_[A/Q]K
QAK
Q[A/K]_
_[A/K/Q]_
KAQ
K[A/Q]_
[K/Q]A_
[K/Q]_A
KQA

II.Scenario 2:
(8 movements) from _AQK:

_[A/Q]_K
QA_K
Q_AK
Q_[A/K]_
QKA_
QK_A
_[K/Q]_A
_KQA

III.Scenario 3:
(8 movements) from AQK_:

A_[K/Q]_
_A[K/Q]_
_AKQ
_[A/K]_Q
KA_Q
K_AQ
K_[A/Q]_
KQA_

October 16, 2009 1:19 AM  
Anonymous Euclid's Brother said...

ionuts.. your scenario 1 is actually 12 moves.. This is what I had come up with before looking at the comments..

You went from _[A/K/Q]_ to KAQ.. that's 2 moves. moving the Q right and the K left.

12 moves is correct when following the rule that a card can only be stacked onto a higher ranking card.

A_(Q/K)
_A(Q/K)
_(A/Q)K
QAK
Q(K/A)_
_(Q/K/A)_
_(K/A)Q
KAQ
K(Q/A)
(K/Q)A_
(K/Q)_A
KQA

(A/Q)_K
(A/Q)K_
Q(A/K)_
QKA

October 16, 2009 7:47 AM  
Anonymous Euclid's Brother said...

bah!.. those last 4 lines of my previous post is garbage i forgot to delete...

October 16, 2009 11:45 AM  
Blogger Chris said...

What you guys up to? You've got to beat 16, 6 and 6. Why show longer sets of moves? I'm assuming that you can't stack 3 cards together, else you've got to beat 4,4,4 moves.

October 16, 2009 4:46 PM  
Anonymous mo said...

Chris, the rules don't say you can't stack 3 cards, as long as they are "placed onto a card of a higher rank". Gratz to ionutz and EB, 12 is indeed the least possible number of moves,(as far as i can tell).

October 16, 2009 6:43 PM  
Blogger Chris said...

This post has been removed by the author.

October 16, 2009 7:21 PM  
Blogger Chris said...

Hi mo. I've already acknowledged the 3 stack move (it was given in the third post) in both my second and my last post. It only uses 4 moves in all three scenarios. I don't think that can be beaten.

October 16, 2009 8:37 PM  
Blogger Chris said...

Hi mo. The original question wasn't written correctly. Up to the point the Rajesh changed it to it's current form, we took it that a high card could be stacked on a low card and not the other way. That understanding was then reversed by Rajesh. I jumped to a false conclusion that reversing the priority didn't significantly change the problem. That was wrong.

Because with the original rule and allowing 3 cards to be stacked, all scenarios could be done using the same 4 moves, I'd considered that version of the problem to be almost trivial. Hence my assumption (not ruling) was that you couldn't stack 3.

I found ionutz's notation confusing. A-[K/Q] suggests King over Queen (as everyone else had done - except Kurt, who lost me). I think ionutz meant Q over King in the example. EB a typo on his 3rd and 10th move.

So AQK -> A-(Q/K) -> -A(Q/K) -> -(Q/A)K -> QAK -> Q(K/A)-
-> -(Q/K/A)- -> -(K/A)Q -> KAQ -> K(Q/A)- -> (Q/K)A- -> (Q/K)-A
-> KQA => 12 moves - credit to EB for that. I can't see a way to do scenario (a) without using a 3 card stack or in less moves.

I haven't re-examined the other scenarios.

October 17, 2009 3:44 AM  

Post a Comment

Links to this post:

Create a Link

<< Home