Best way to start this problem guys?

  • Thread starter nomi
  • Start date
In summary: But more importantly we're both well under the 1 minute threshold anyway.In summary, the conversation discusses the problem of selecting 15 squares from a 12x12 array without any selected squares being in the same row or column. The participants suggest using the nearest neighbor algorithm or the Hungarian algorithm to solve the problem. A brute force approach is also mentioned, with one participant finding a minimum solution of 143 by picking specific numbers for each row. The conversation also briefly mentions the traveling salesman problem and the efficiency of brute force methods.
  • #1
nomi
19
0
http://img207.imageshack.us/img207/8952/neatoteeheesu5.jpg thx
 
Last edited by a moderator:
Mathematics news on Phys.org
  • #2
Do you have any thoughts?

And How can you pick 15 squares from a 12x12 array so that no two selected squares are in the same row or column?
 
  • #3
thats what i don't understand
 
  • #4
That needs to be clarified, if you assume that there was a typo and they meant to say 12, not 15, then the problem makes sense. If you assume they meant 15 then either the table array needs to be bigger, or the rules have to change.

Please clarify with your teacher/professor, and let us know.
 
  • #5
Well anyway, let's go ahead and assume that you have to just pick 12.

Have you ever heard of the traveling salesman problem? As wikipedia states
Given a number of cities and the costs of traveling from any city to any other city, what is the least-cost round-trip route that visits each city exactly once and then returns to the starting city?

One method of solving this problem (again according to wikipedia) is:

Constructive heuristics
The nearest neighbour (NN) algorithm (the so-called the greedy algorithm is similar, but slightly different) let's the salesman start from anyone city and choose the nearest city not visited yet to be his next visit. This algorithm quickly yields an effectively short route.

Do you see how you can apply this to your problem?
Hint: think of column one as a city, and all the rows in column one as different routes to the next column. Of course here you want to maximize, not minimize, but the general principal is the same.
 
  • #6
Since there are only 12! possible choices of numbers, the first thing I would do is brute force it. The simple program I made is probably the ugliest piece of C++ programming ever, but with less than 480 million trials, it took under 5 minutes. The minimum, seems to be 143 by picking 7, 18, 24, 5, 11, 9, 11, 14, 6, 5, 21, 12 in each row respectively. You should be able to find the maximum just as easily.

Then, you may want to look up what Diffy posted or consider better mathematical and algorithmic approaches to the problem.
 
  • #7
thanks guys
 
  • #8
Use the Hungarian Algorithm. (It's an algorithm designed specifically for that problem)
 
  • #9
Tedjn said:
The minimum, seems to be 143 by picking 7, 18, 24, 5, 11, 9, 11, 14, 6, 5, 21, 12 in each row respectively. You should be able to find the maximum just as easily.

Just wondering what CPU that was run on Tedjn?

BTW. I'm also a fan of brute force when you can get away with it, it must be the Engineer in me :). My exhaustive search ran in under 30 sec written/compiled in Borland Delphi 7 (pascal) and run on an Athlon64-3800+. I got the same answer as you when I set it to find a minimum. The actual problem here is to find a maximum however but of course that's a trivial program change. I won't post the solution since I think the OP is still working on it.
 
Last edited:
  • #10
I ran it on a Turion64 X2. It doesn't seem to account for maybe a 4 minute difference, so my program was probably very inefficient (I used a bunch of loops).
 
  • #11
No I just used 12 nested loops too. I know that looks ugly but it's actually a pretty efficient way to do it when the size of the problem (12 in this case) is a compile time constant. More likely the differences were in the way we each took care of the "index set" for enumerating all the combinations without choosing the same row or column twice.
 

Related to Best way to start this problem guys?

1. What are the steps to approach this problem?

The best way to start this problem is to first carefully read and understand the problem statement. Then, break down the problem into smaller, manageable parts. Next, brainstorm potential solutions and choose the most efficient and effective one. Finally, implement the chosen solution and test it to ensure it solves the problem.

2. How do I gather the necessary information to solve the problem?

To gather the necessary information, you can start by researching similar problems and solutions, consulting with colleagues or experts in the field, or conducting experiments or tests. It is important to gather all relevant and accurate information before proceeding with a solution.

3. What should I do if I get stuck while solving the problem?

If you get stuck while solving the problem, take a step back and approach the problem from a different perspective. You can also take a break and come back to it later with a fresh mind. If you are still stuck, don't be afraid to ask for help from others or consult additional resources.

4. Is there a specific order in which I should tackle the problem?

While there is no set order in which to tackle a problem, it is generally recommended to start with the most basic or fundamental aspects and work your way up to more complex components. This can help build a strong foundation for the solution and make it easier to identify and solve any potential issues.

5. How can I ensure my solution is the best one?

To ensure your solution is the best one, it is important to thoroughly test and evaluate it before implementing it. This can include conducting experiments, getting feedback from others, and comparing it to other potential solutions. It is also important to constantly review and improve your solution as needed.

Similar threads

  • General Math
Replies
2
Views
741
  • General Math
Replies
7
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
4
Views
2K
Replies
1
Views
3K
Replies
6
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
9K
  • Introductory Physics Homework Help
Replies
9
Views
4K
Replies
1
Views
703
Replies
76
Views
4K
Back
Top