Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com
 
Latest News Jul 9 4:01AM EST 

The winners page is now online. Find out more about our winners and read their contest stories! We've also posted some statistics and commentary about the evolution of the contest and an analysis of some of the code

Per Rutquist is our overall MATLAB Golf Champion. He came away with two first place finishes and two second place finishes. We'll send him a MATLAB Jacket.

Congratulations to all of our first-place finishers: Guy Shechter, Imre Polik, Stijn Helsen, Per Rutquist, Claus Still, François Glineur, and Nicke. You will each receive a MATLAB toolkit.

You can now download the full testsuites used in the contest from the File Exchange.

If you'd like to hear about the next contest, sign up for our Contest Announcement mailing list. To subscribe send e-mail to lists@mathworks.com with subscribe contest-announce in the body.

All holes: frequencies, palindrome, encryption, infection, heaviest, pathfinder, and snake.

Pathfinder

Suppose you have a network of connected points on a plane. It may not be fully connected, but it is possible to get from one point to any other point. If you found the shortest route from a starting point to every other point, which of these routes is the longest?

More formally, given the adjacency matrix a and the coordinates matrix b, find the path from the first point in b (given by the first row in b) to the most distant point from b as traveled through the minimal network distance.

Coordinates in b are provided in the form [x1 y1; x2 y2; ...]. Travel is permitted only between connected points as indicated by ones in the adjacency matrix a. Return your answer c in the form of a vector of indices that represent the waypoints from start to finish. c(1) will always be one.

So when

 a = [ 1     1     0
       1     1     1
       0     1     1 ]

and

 b = [ 0     0
       1     0
       1     1 ]

the most distant point from point 1 (x1,y1) is point 3 (x3,y3), a total distance of 2 away. Since point 1 is not directly connected to point 3, the trip must include point 2. Return

c  = [ 1 2 3 ]

If a had been the fully connected matrix ones(3), then the answer would have been

c = [ 1 3 ]

Since there would no longer be a need to detour through point 2.

A slightly more complex problem appears below.

a = [ 1     0     1     0     0     0
      0     1     1     1     0     0
      1     1     1     1     0     0
      0     1     1     1     1     1
      0     0     0     1     1     0
      0     0     0     1     0     1 ]
b = [ 0     0
      1     2
      1     1
      2     2
      3     0
      3     3 ]

Even if you take the shortest path from point 1 to point 5, it ends up being harder to reach than any other point in the network. What is the shortest path to point 5?

c = [ 1 3 4 5 ]

Leaders

Place Submitted Entry Author Length
1 12:52:19 PPath IV Per Rutquist 128
2 12:41:03 PPath III Per Rutquist 130
3 12:23:25 also ran 3 wak 152
4 12:21:43 also ran2 wak 160
5 12:07:00 zero1 Imre Polik 183
6 12:04:36 also ran wak 185
7 11:54:03 probably not the shortest - tweak aga... Christopher Cheng 191
8 11:46:50 probably not the shortest - tweak 2 Christopher Cheng 192
9 11:35:39 probably not the shortest - tweak Christopher Cheng 193
10 11:19:18 probably not the shortest Christopher Cheng 194
11 11:15:41 Tweak Peter J. Acklam 243
12 11:11:24 Finally? Peter J. Acklam 250


 golf_1_pathfinder
 
Home

Rules

This hole (closed)

     The challenge

     Show all entries

     Search for an entry

Message board

Hall of fame

Send us feedback