Shane75776's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
4 (0.01 per day)
Joined:
17-April 12
Profile Views:
47
Last Active:
User is offline Apr 18 2012 06:16 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   Shane75776 has not set their status

Posts I've Made

  1. In Topic: 3x3 Magic Square Recursive Backtracking

    Posted 17 Apr 2012

    Can anyone possibly help me to get started on this. I'm still very much lost. I have done a ton of googling and have not turned up anything helpful.

    Thanks.
  2. In Topic: 3x3 Magic Square Recursive Backtracking

    Posted 17 Apr 2012

    View PostGregBrannon, on 17 April 2012 - 01:36 PM, said:

    Do you know or can you use sets yet?


    We have not done anything with sets yet. All we were told was that this should be a fairly simple recursive method with the given pseudo-code. I'm just not seeing it or something. I feel kinda stupid because I have done more complicated things than this before. Yet I can't seem to wrap my head around it.
  3. In Topic: 3x3 Magic Square Recursive Backtracking

    Posted 17 Apr 2012

    View PostGregBrannon, on 17 April 2012 - 01:32 PM, said:

    We'll help you with your possibly overcomplicated approaches. Show what you've tried.

    If you haven't already, you could start by coding the above pseudo-code.


    This is what I have done thus far, and a few other attempts but I know its completely wrong and it seems like I am just not understanding the pseudo-code correctly.

    int[][] square = new int[3][3];
    	ArrayList<Integer> used_nums = new ArrayList<Integer>();
    	
    	
    	public MagicSquare()
    	{
    		rec_backtrack(0);
    		print_square();
    	}
    	public void rec_backtrack(int level)
    	{
    		int step = 0;
    		for(int i = 1; i < 10; i++)
    		{
    			if(!used_nums.contains(i))
    			{
    				square[step][level] = i;
    				used_nums.add(i);
    				step++;
    			}
    			if(step == 3) //we have inserted to all 3 spots now, check for solution
    			{
    				if((square[0][level] + square[1][level] + square[2][level]) == 15) //acceptable solution
    				{
    					rec_backtrack(level++);
    				}
    				else
    				{
    					step--;
    				}
    			}
    		}
    	}
    

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Shane75776 hasn't added any friends yet.

Comments

Shane75776 has no profile comments yet. Why not say hello?