All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Gardener's Woe (Posted on 2006-06-24) Difficulty: 4 of 5
An unlucky gardener planted a 10x10 square array of 100 old seeds out in the garden. Only 5 of these seeds have germinated including one at the southwest corner (0,0) where a slug is currently reducing it to ground level.

When it finishes it will head directly to the next closest doomed plant. After it eats that one it will again leave a slime trail to the closest remaining plant and so on until the garden is no more.

Where are the 4 remaining seedlings if the path crawled by the slug is the longest possible and it never has to choose between two equidistant snacks?

Note: Although the slug will never have to choose between two equidistant seedlings, this doesn't imply that no two are equidistant.

Next find the locations if 6 seedlings had germinated instead of 5.

See The Solution Submitted by Jer    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution re(2): Nicely done -- now through 7 seedlings | Comment 25 of 27 |
(In reply to re: Nicely done -- 2 thru 6 seedlings by Charlie)

Even a conversion to VB from QB didn't help that much. It took a couple of hours to find the solution for 7 seedlings, which I've added to the list below:

0  0     9  9     12.72792206135786
0  0     9  0     1  9     21.0415945787923
0  0     7  5     9  0     0  9     26.71541213553499
0  0     6  5     9  9     9  0     0  8     33.85184425469895
0  0     6  5     5  9     9  9     9  0     0  8     36.97494988031661
0  0     7  3     8  6     5  6     9  9     9  0     0  8   39.8196453448246

VERSION 5.00
Begin VB.Form Form1
   AutoRedraw      =   -1  'True
   Caption         =   "Form1"
   ClientHeight    =   6255
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   9405
   LinkTopic       =   "Form1"
   ScaleHeight     =   6255
   ScaleWidth      =   9405
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1
      Caption         =   "Command1"
      Height          =   855
      Left            =   7080
      TabIndex        =   0
      Top             =   240
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim n
Dim curX(12), curY(12), curDist(12), curTot(12)
Dim hldX(12), hldY(12), hldDist(12), hldTot
Sub place(lvl)
 DoEvents
 For r = 0 To 9
 stC = 0: If lvl = 2 Then stC = r
 For c = stC To 9
  For pLvl = 1 To lvl - 2
   dist = Sqr((r - curY(pLvl)) * (r - curY(pLvl)) + (c - curX(pLvl)) * (c - curX(pLvl)))
   If dist <= curDist(pLvl + 1) Then GoTo notThis
  Next pLvl
  dist = Sqr((r - curY(lvl - 1)) * (r - curY(lvl - 1)) + (c - curX(lvl - 1)) * (c - curX(lvl - 1)))
  If dist = 0 Then GoTo notThis
  curX(lvl) = c
  curY(lvl) = r
  curDist(lvl) = dist
  curTot(lvl) = curTot(lvl - 1) + dist
  If lvl = n Then
   If curTot(lvl) > hldTot Then
     Cls
     For i = 1 To n
      hldX(i) = curX(i): Print hldX(i);
      hldY(i) = curY(i): Print hldY(i); "   ";
      hldDist(i) = curDist(i)
     Next
     hldTot = curTot(lvl)
     Print hldTot
   End If
  Else
   place lvl + 1
  End If
notThis:
 Next c
 Next r
End Sub


Private Sub Command1_Click()
 Form1.MousePointer = vbHourglass
 curX(1) = 0
 curY(1) = 0
 curDist(1) = 0
 curTot(1) = 0
 n = 7

 place 2
 Print: Print "done"
 Form1.MousePointer = vbDefault
End Sub


  Posted by Charlie on 2006-06-26 13:47:48
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information