Skip to Main Content Skip to Search
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com
 
Latest News Oct 12 1:20PM 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.

Snake

A "snake" is defined as a sequence of adjacent consecutively increasing integers (incrementing by one) embedded in and twisting through a larger matrix. The sequence can turn north, south, east, or west, but not diagonally. A snake sequence may also be straight.

Given the matrix a, return the longest snake sequence in the variable b. a is an array containing positive integers. b is a column vector containing the linear index of this sequence, beginning with the smallest number in the snake sequence. For example, when

a = [ 14    16    13
      15    15    14
      16    10     9]

create

b = [ 7
      8
      5
      4 ]

Another example is

a = [  1     2     3
       4     7     4
       5     6     5]
b = [ 1
      4
      7
      8
      9
      6
      5 ]

Each matrix will have exactly one snake sequence longer than all others. In addition, a will never be a vector. That is, the smallest dimension of a will always be greater than one.

Note: Linear (or absolute) indexing is a way to index into a 2-D matrix with one number. Linear indexing is column-oriented, so if

a = [ 14    16    13
      15    15    14
      16    10     9]
then a(1) is 14, a(4) is 16 and a(8) is 14. To learn more about linear indexing, read this MATLAB Digest article.

Leaders

Place Submitted Entry Author Length
1 17:58:34 Revolution IV Nicke 139
2 17:53:08 h13 John Arthur 172
3 17:35:44 h11 John Arthur 174
4 17:27:34 h10 John Arthur 175
5 17:05:56 h8 John Arthur 179
6 16:42:49 x3 PU 231
7 16:39:29 x2 PU 238
8 16:34:48 transpose5.1 Guy shechter 247
9 16:24:16 transpose 5 Martijn 248
10 16:23:48 Serpent2.3 Francois Glineur 252
11 16:21:39 transpose 4 Martijn 254
12 16:16:47 transpose 3 Martijn 255
13 16:11:57 Wobbbling Woburn Colin Ross 262
14 16:07:41 cyclist_13 cyclist 273
15 15:39:47 cyclist_4 cyclist 274
16 15:39:29 transpose1 anitha 276
17 15:38:20 transpose Martijn 277


 golf_1_snake
 
Home

Rules

This hole (closed)

     The challenge

     Show all entries

     Search for an entry

Message board

Hall of fame

Send us feedback