Jump to content
BrainDen.com - Brain Teasers
  • 0

2000 shuffles


Go to solution Solved by bonanova,

Question

A shuffle of 2n cards puts the first n cards in the odd positions and the last n cards in the even positions.[For example shuffle (1,2,3,4,5,6) and you get (1,4,2,5,3,6).] Heather has 10 cards, 1-10, Briana has 12 cards, 1-12. Each shuffles her deck 2000 times. "Hey, my deck is back to its original state!"
Who said that, and which card does the other deck have in position #5?
Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Solution

Briana said it.

There is a 2 in the fifth place of Heather's deck.

s out-shuffles will restore deck a deck of n=2m cards,

where s=ordn-1(2).

For a 10-card deck, that's 6.

Since 2000(mod 6) = 2, 2000 out-shuffles of Heather's deck is equivalent to 2 out-shuffles.

For a 12-card deck, that's 10.

Since 2000(mod 10) = 0, 2000 out-shuffles restores Briana's deck.

Link to post
Share on other sites
  • 0

public class Class1 {
    public static void main(String[] args) {
        int[] arr1 = {1,2,3,4,5,6,7,8,9,10};
        int[] arr2 = {1,2,3,4,5,6,7,8,9,10,11,12};
        for(int i=0;i<2000;i++){
            doShuffle(arr1);
            doShuffle(arr2);
        }
        System.out.println("arr1 = "+java.util.Arrays.toString(arr1));
        System.out.println("arr2 = "+java.util.Arrays.toString(arr2));
    }
    private static void doShuffle(int[] arr){
        int[] temp = java.util.Arrays.copyOf(arr, arr.length);
        for(int i=0;i<arr.length;i++){
            arr[i] = temp[i/2 + (i%2)*(arr.length/2)];
        }
    }
}
Result:

arr1 = [1, 8, 6, 4, 2, 9, 7, 5, 3, 10]

arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Link to post
Share on other sites
  • 0

The one who has her cards in order is Briana.


The fifth card in the other deck is 2

By shuffling Heather's cards six times, it goes back to the original state.

So by the 2000th shuffle, it will have the same order as what the deck had after the second shuffle.

Edit: I just realized how tiresome my solution is.

Edited by DeathStone0000
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...