Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7418385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:52:38+00:00 2026-05-29T07:52:38+00:00

I think I’ve come across an interesting question – how to scramble, then undo

  • 0

I think I’ve come across an interesting question – how to scramble, then undo the scramble on an array. Please keep in mind this needs to be done using .Net 2.0.

My thought process is shown below:

  1. Somehow, sign an index of some sort to each item in the array
  2. Randomize the array
  3. Use the indexes to re-sort the array

byte[] b = new byte[] {1=>33,2=>19,3=>41,n=>N}
b.Sort();

The array might now look like this:

byte[] b = new byte[] {3=>41,2=>19,1=>33,n=>NN ... etc.};

Please, someone tell me what I’d like to do here is a possibility, and if it indeed is possible, please point me in the correct direction.

Thanks,

Evan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:52:38+00:00Added an answer on May 29, 2026 at 7:52 am

    I would suggest shuffling and then unshuffling the array using the Fisher-Yates algorithm and a given integer key. The key can be fixed or random, but must be the same number for both operations in order to retrieve the original array.

    Unscramble is a little bit more complicated than Scramble because the sequence of swaps must be generated using a Random initialised with the same seed, and then applied in reverse order.

    void Scramble<T>(T[] array, int key)
    {
        var random = new Random(key);
        for (int i = array.Length; i > 1; i--)
        {
            Swap(array, random.Next(i), i - 1);
        }
    }
    
    void Unscramble<T>(T[] array, int key)
    {
        var random = new Random(key);
        var swaps = new List<int>(array.Length);
        for (int i = array.Length; i > 1; i--)
        {
           swaps.Add(random.Next(i));
        }
        swaps.Reverse();
        for (int i = 0 ; i < swaps.Count; ++i)
        {
            Swap(array, swaps[i], i + 1);
        }
    }
    
    void Swap<T>(T[] array, int i1, int i2)
    {
        T tmp = array[i2];
        array[i2] = array[i1];
        array[i1] = tmp;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

think about an array like this: ... key1 => some_call(val1, $params), key2 => some_call(val1,
Think: tiling my emacs window with eshells, a la xmonad. Is this possible? I
I think most people know how to do this via the GUI (right click
I think this is specific to IE 6.0 but... In JavaScript I add a
I think I know how to handle this case, but I just want to
Think of this: A view controller's view is added as subview to another view.
Think Windows Explorer's 'Details' view. I need to output my database to this view.
I think that asking this might be kind of silly but I'm still wondering
Think that I have many activities,and all I want is this: I have a
I think this has probably been asked, but after reading a lot, I'm not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.