Seven pumpkins are placed in a circle. The seven pairs formed by adjacent pairs of pumpkins are weighed, much like in prior
pumpkin puzzles. The weights recorded, sorted in ascending order, are 126, 149, 152, 160, 162, 182, and 191 pounds.
The same seven pumpkins (still in the same order) are weighted in pairs again, this time taking pairs separated by one pumpkin. (If A, B, and C are consecutive pumpkins in the circle then A+C is weighed.) The weights recorded, sorted in ascending order, are 125, 138, 163, 169, 170, 173, and 184 pounds.
From these two sets of weights determine the weights of the seven pumpkins and the order they were placed in the circle.
The program was written to find solutions which included (and started reporting with) a pumpkin weighing anywhere from 70 to 100 pounds:
DefDbl AZ
Dim crlf$, wt(7)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
c0$ = Chr$(126) + Chr$(149) + Chr$(152) + Chr$(160) + Chr$(162) + Chr$(182) + Chr$(191)
sk$ = Chr$(125) + Chr$(138) + Chr$(163) + Chr$(169) + Chr$(170) + Chr$(173) + Chr$(184)
For i = 1 To 7
tot = tot + Asc(Mid(c0, i, 1))
Next
tot = tot / 2
Text1.Text = Text1.Text & tot & crlf
tot = 0
For i = 1 To 7
tot = tot + Asc(Mid(sk, i, 1))
Next
tot = tot / 2
Text1.Text = Text1.Text & tot & crlf
cir$ = c0: h$ = cir
Do
For frst = 70 To 100
wt(1) = frst: t = frst
For i = 2 To 7
wt(i) = Asc(Mid(cir, i  1, 1))  wt(i  1)
t = t + wt(i)
Next
If t = tot Then
good = 1
For i = 1 To 7
j = i + 2: If j > 7 Then j = j  7
t = wt(i) + wt(j)
tround = Int(t + 0.5)
If Abs(t  tround) < 0.001 Then t = tround
If t < 1 Or t > 255 Or t <> Int(t) Then
good = 0: Exit For
End If
If InStr(sk, Chr$(t)) > 0 Then
xx = xx
End If
If InStr(sk, Chr$(t)) = 0 Then
good = 0: Exit For
End If
Next
If good Then
For i = 1 To 7
Text1.Text = Text1.Text & Str(wt(i))
Next
Text1.Text = Text1.Text & crlf
ctsol = ctsol + 1
End If
End If
Next
permute cir
Loop Until cir = h
Text1.Text = Text1.Text & crlf & ctsol & " done"
End Sub
While the solution is unique except for rotations and reflections, the program does not filter out the rotations and reflections, but still finds only 10 "solutions", as two of the weights fall outside the 70  100 pound range, so the four reports that would begin with those two weights are not found. The full output begins with the total weight of the pumpkins, based on the two sets of totals, to be sure they match:
561
561
91 69 93 56 70 82 100
93 69 91 100 82 70 56
82 100 91 69 93 56 70
100 82 70 56 93 69 91
100 91 69 93 56 70 82
91 100 82 70 56 93 69
82 70 56 93 69 91 100
70 82 100 91 69 93 56
93 56 70 82 100 91 69
70 56 93 69 91 100 82
10 done
The 561 is the total weight of the seven pumpkins.
As good a sequence as any is the first:
91 69 93 56 70 82 100
The rest are rotations and reflections. Again, the reason there aren't 14 is that two of the pumpkins' weights do not fall within the 70100 pound range sought for the first to report.

Posted by Charlie
on 20160205 15:41:05 