Interesting Programming Problem

I saw this in a careers section of a very nice website. Did you say "Why haven’t I just give the link?" Two reasons. They might just change it to a new one or totally remove it as they don’t have that position anymore. Second, I don’t want you to know where I’m looking for an opening 😉
 
Here we go… Serious one in a while…

Programming Problem

Given a deck of nCards unique cards, cut the deck iCut cards from top and perform a perfect shuffle. A perfect shuffle begins by putting down the bottom card from the top portion of the deck followed by the bottom card from the bottom portion of the deck followed by the next card from the top portion, etc., alternating cards until one portion is used up. The remaining cards go on top. The problem is to find the number of perfect shuffles required to return the deck to its original order. Your function should be declared as:

    static long shuffles(int nCards,int iCut);Please enter the result of shuffles(1002,101) along with your program down in the comments. 

Looking forward to the answers so that I can apply for the job… Hurry up…

Advertisements

Author: Ram

geek passionate about music and photos

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s