635 - Clock solitaire

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

635 - Clock solitaire

Post by Dominik Michniewski »

Does anyone know any trap in this problem ?
I try just to simulate this solitaire, but I got WA many times. Maybe I miss something in description ?
Maybe some IO ?

Edited:
Sorry, I made another silly mistake in my code. I wrong understood some sentences in description.

Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

don't get it..

Post by sohel »

I also use simulation, but can't get the sample right.

- what exactly is 52 cycle shifts..

Is it equivalent to placing the first card at the last place and then giving away the cards... and do this 52 times.

My output for the sample is 8 as opposed to 4, by following the above approach..

Some clarification might open up things for me.

Thanks.
minskcity
Experienced poster
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Post by minskcity »

You deal 4 card at a time to the same place.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Code: Select all

Got Accepted
Last edited by Jan on Tue Jun 27, 2006 12:11 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage
sluga
New poster
Posts: 20
Joined: Sun Jan 22, 2006 10:48 pm
Location: Croatia

Post by sluga »

I am trying to solve this problem, but I don't think I understand the description. I keep geting 0 as an answer to the sample input.
I do the following:
for every cycle ( if ABC were initial cards, then I suppose cycles were ABC, CAB and BCA ), I do the simulation:
In the simulation, I divide the cards into 13 queues and start from the 13. queue. I pick the lowest card and place it in the proper queue. I go through the cards until I pick some card I moved before. I count the number of turned cards. If this number is 52, this is winning configuration.
What am I doing wrong?
A sta da radim
kalinov
New poster
Posts: 27
Joined: Tue Mar 29, 2005 3:10 pm
Location: Croatia

Post by kalinov »

Check if you convert characters in the input to numbers correctly.
'A' is considered 11 o'clock, and 'J' is 1 o'clock, although I think it would be more logical otherwise.
Also there is no mention of character 'T' in the problem statement while there is 'T' in the sample input, not "10".
When you deal the cards, put four cards on one o'clock first, then next four cards on two o'clock... and finally the last four cards at the center.
I hope it helps :)
sluga
New poster
Posts: 20
Joined: Sun Jan 22, 2006 10:48 pm
Location: Croatia

Post by sluga »

Thanks! :)
A sta da radim
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 635 - Clock solitaire

Post by metaphysis »

The statement of problem is not so clear, I spent some time on Internet to figure out the rule of Clock game. The rule in this problem differs from regular rule. you should beware of two points below:
1. When you deal the cards, you should place four card at one clock, then four cards at two clock, and so on, for sample input, the cards at one clock is: 7 J 9 3, the order is from bottom to top, 7 is the bottommost card, 3 is the topmost card.
2. "cyclic shifts" means move the first card to last place of sequence, deal cards and play again to check successful or not untill sequence return to original state.
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 635 - Clock solitaire

Post by metaphysis »

The test data generator.

Code: Select all

#include <iostream>
#include <algorithm>
#include <ctime>
#include <random>

using namespace std;

int main(int argc, char *argv[])
{
    string cards = "7J93JQKA23456789T8QKA23456789TJQKA23456789TJQKA2T456";

    for (int i = 1; i <= 100; i++)
    {
        shuffle (cards.begin(), cards.end(), default_random_engine(time(NULL)));
        for (int j = 0; j < cards.length(); j++)
        {
            if (j > 0)
                cout << ' ';
            cout << cards[j];
        }
        cout << '\n';
    }
    cout << "0\n";
    
    return 0;
}
Post Reply

Return to “Volume 6 (600-699)”