Can I install two Ubuntu versions on the same machine?

304

Solution 1

Yes you can.
For that you will have to use manual partition option.

  1. You can use the same swap for both the installs (this is simple, just select re-select same swap for second install).
  2. You can mount same /home for both installs. (a little advanced, if your experience with linux-admin is less.)

Solution 2

You may also want to consider a virtual machine to save time. With a virtual machine you wouldn't require a reboot of your computer. Virtualbox is easy to install and free. You can either get it from the software center in Ubuntu or you can download the non open source edition at... http://www.virtualbox.org/wiki/Downloads

Here's a walk through of how to install Ubuntu inside virtualbox.

http://helpdeskgeek.com/linux-tips/how-to-install-ubuntu-in-virtualbox/

The walk through is for Ubuntu 9.04, but the steps are the same. Easy to do and you don't need to reboot to switch to the 64 bit version or partition your drive any more than how it is.

Share:
304
Matthew Grima
Author by

Matthew Grima

Updated on September 17, 2022

Comments

  • Matthew Grima
    Matthew Grima over 1 year

    I'm trying to create a sudoku game, for those that do not know what it is. You have a 9x9 box that needs to be filled with numbers from 1-9, every number must be unique in its row and column, and also in the 3x3 box it is found. I ended up doing loads of looping within a 2 dimensional array.

    But at some point it just stops, with no exceptions whatsoever, just breaks out and nothing happens, and it's not always at the same position, but always goes past half way.

    I was expecting a stack overflow exception at least.

    Here's my code:

    public class Engine
    {
        public int[,] Create()
        {
            int[,] outer = new int[9, 9];
    
    
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                     outer[i, j] = GetRandom(GetUsed(outer, i, j));
                }
            }
    
            return outer;
    
        }
    
        List<int> GetUsed(int[,] arr, int x, int y)
        {
            List<int> usedNums = new List<int>();
            for (int i = 0; i < 9; i++)
            {
                if (arr[x, i] != 0 && i != y)
                {
                    if(!usedNums.Contains(arr[x, i]))
                        usedNums.Add(arr[x, i]);
                }
            }
    
            for (int i = 0; i < 9; i++)
            {
                if (arr[i, y] != 0 && i != x)
                {
                    if (!usedNums.Contains(arr[i, y]))
                        usedNums.Add(arr[i, y]);
                }
            }
    
            int x2 = 9 - (x + 1);
            int y2 = 9 - (y + 1);
    
            if (x2 <= 3)
                x2 = 2;
            else if (x2 > 3 && x2 <= 6)
                x2 = 5;
            else x2 = 8;
    
            if (y2 <= 3)
                y2 = 2;
            else if (y2 > 3 && y2 <= 6)
                y2 = 5;
            else y2 = 8;
    
            for (int i = x2 - 2; i < x2; i++)
            {
                for (int j = y2 - 2; j < y2; j++)
                {
                    if (arr[i, j] != 0 && i != x && j != y)
                    {
                        if (!usedNums.Contains(arr[i, j]))
                            usedNums.Add(arr[i, j]);
                    }
                }
            }
    
            return usedNums;
        }
    
        int GetRandom(List<int> numbers)
        {
            Random r;
            int newNum;
            do
            {
                r = new Random();
                newNum = r.Next(1, 10);
            } while (numbers.Contains(newNum));
    
            return newNum;
        }
    
    }
    
    • tzaman
      tzaman about 14 years
      Have you tried stepping through and seeing where it stops? Also, which function are we talking about? There's half a dozen loops in there..
    • Matthew Grima
      Matthew Grima about 14 years
      I'm stepping through the first loop in the first method "Create()" It's never the same, sometimes at 4,7 or at 5,3, always at a different position, it seems very random.
    • Phil
      Phil about 14 years
      Very...*random* you say? (I couldn't resist)
    • Eric Lippert
      Eric Lippert about 14 years
      You are on the wrong track; you will never get a successful Sudoku generator using this technique. Read this article: codeproject.com/KB/game/SudokuGen.aspx. As the author says "It's nearly impossible to produce a valid Sudoku by randomly plotting numbers and trying to make them fit. Likewise, backtracking with a random placement method is equally ineffective (trust me I've tried both)."
  • Phil
    Phil about 14 years
    +1 for mentioning that this way of creating the board will result in unsolvable/multiple solution boards.
  • Matthew Grima
    Matthew Grima about 14 years
    Well at first I am trying to fill it with the answers then I was going to use it and remove some of the values. How can it be unsolvable or with multiple solutions when numbers are unique within their row, column and 3x3 box?
  • Matthew Grima
    Matthew Grima about 14 years
    The maxValue shouldn't be included in the range while the minValue is. I tried already just in case and it filled my array with 0s. What I don't understand is how could it be going into an infinite loop. The way I see it, it is populating a list of numbers which are already used in the cell's row, column and box so the method does not return it, at the last iteration of the inner loop it should have one number out of 1-9 not used, or am I missing something? Please note that I am not trying to question your reasoning.
  • Matthew Grima
    Matthew Grima about 14 years
    Doesn't that mean that the problem is with the GetUsed function then or?
  • Phil
    Phil about 14 years
    Have you tried @tzaman's suggestion of putting the check at the top of GetRandom? Your code is not gathering a list of numbers for just 1 cell (which would always be exactly 1 number). It's gathering a list of numbers used in the row, column and 3x3 enclosing box. In the first row, there will be no issues. After that, all bets are off. The last element of the 2nd row can have an issue, since there are 8 cells before, 1 above, and 1 to the top left. That's all 10 numbers you are allowing in Random.Next.
  • Matthew Grima
    Matthew Grima about 14 years
    Undersoon, I get what you mean, I printed the numbers and got that problem you are mentioning. I started doing this as a challenge for myself really. So I can go on with your suggestion to try a solver first. Thanks a lot. one question, since you know that there are 9 occurrences of each number, once in every 3x3,row and col, would that help? As I did not even bother about the amount of times a number occurs.
  • Matthew Grima
    Matthew Grima about 14 years
    I printed the numbers that it managed to create and noticed the problem with that.
  • tzaman
    tzaman about 14 years
    While the global number of occurrences is a constraint, it's generally not a useful one - i.e. just knowing that 5 of 9 are on the board doesn't help you in locating where the others should go. Peter Norvig has a great essay on sudoku solvers, check it out: norvig.com/sudoku.html
  • Kangarooo
    Kangarooo over 12 years
    How swap will react if both system will use hibernation? And same /home will make both have same installations.. Better additional same files.. some settings synced and some file folder synced but not whole /home. i can try to find later in askubuntu where i found someone had problem with same /home with different ubuntu versions and programm versions merging.