Stupid math riddle.

1. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Stupid math riddle.

I&#039;m not so much interested in knowing what the answer is - I&#039;m more interested in how you figure it out. I know how I did it, which was TOTALLY different than how a friend did it.<BR><BR>------------<BR><BR>Two farmers meet each at the fences that divide their properties. Farmer A says to Farmer B, "Give me one of your sheep so that I have double the number of sheep as you.". Farmer B laughs and says to Farmer A, "Give me one of your sheep so that we have the same number of sheep.".<BR><BR>How many sheep did each farmer have?

2. Senior Member
Join Date
Dec 1969
Posts
2,930

## RE: Stupid math riddle.

Farmer a - 7 sheep<BR>Farmer b - 5 sheep

3. Senior Member
Join Date
Dec 1969
Posts
440

## RE: Stupid math riddle.

well you could get smart and write a formula something like x+1=2y and y+1=x and solve from there, OR you could be like me and pick numbers almost at random and get that 7/5 thing.

4. Senior Member
Join Date
Dec 1969
Posts
1,274

## Good job, Einstein ;-)

But how did you figure it out?<BR><BR>We did this:<BR><BR>Private Sub Command1_Click()<BR> Dim a As Integer, b As Integer<BR> Dim tmpA As Integer, tmpB As Integer<BR> <BR> For a = 0 To 101<BR> For b = 0 To 101<BR> &#039; Scenario 1<BR> tmpA = a + 1<BR> tmpB = b - 1<BR> <BR> If tmpA = 2 * tmpB Then<BR> &#039; Check Scenario 2<BR> tmpA = a - 1<BR> tmpB = b + 1<BR> <BR> If tmpA = tmpB Then<BR> MsgBox "Found It: A=" + CStr(a) + " , B=" + CStr(b)<BR> End If<BR> End If<BR> Next b<BR> Next a<BR>End Sub<BR>

5. Member
Join Date
Dec 1969
Posts
52

## RE: Stupid math riddle.

Simultaneuos equations:<BR><BR>A+1 = 2(B-1) = A + 1 = 2B - 2 PLUG IT IN: A+1 = 2(5)-2<BR>A-1 = B+1 -A + 1 = -B - 1 A+1 = 10 -2<BR> ________________ A = 10 - 2 - 1<BR> 2 = B - 3 A = 7<BR> B = 5 <BR>THANK YOU VERY MUCH!!

6. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Holy ugly code, batman.

Here&#039;s what I did:<BR>&#060;%<BR>Dim bRet<BR>Dim iCnt<BR><BR>bRet = False<BR>iCnt = 0<BR>While iCnt &#060;= 25 And bRet = False<BR> iCnt = iCnt + 1<BR><BR> bRet = CBool(iCnt = (2 * (iCnt - 3)) - 1)<BR>Wend<BR><BR>Response.Write bRet & "&#060;br /&#062;" & vbCrLf & _<BR> "FarmerA = " & iCnt & "&#060;br /&#062;" & vbCrLf & _<BR> "FarmerB = " & (iCnt - 2)<BR>%&#062;<BR><BR>And, to figure out the equation:<BR>FarmerA + 1 = 2 * (FarmerB - 1)<BR>FarmerB + 1 = FarmerA - 1<BR><BR>FarmerA = (2 * (FarmerB - 1)) - 1<BR>FarmerB = FarmerA - 1 - 1 &#039;--- I know that they are different by 2<BR><BR>FarmerA = (2 * ((FarmerA - 1 - 1) - 1)) - 1<BR><BR>FarmerA = (2 * (FarmerA - 3)) - 1 &#039;--- Final equation<BR>FarmerB = FarmerA - 2 &#039;--- Final equation

7. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Impressive. Someone..

.. actually used simple Algebra to figure it out.<BR><BR>My friend&#039;s solution was pretty similar:<BR>A+1=2(b-1)<BR> b+1=A-1<BR> b+2=A<BR> b+2+1=2(b-1)<BR> b+3=2b-2<BR> b+5=2b<BR> b=5<BR> 5+2=7 which is A

8. Member
Join Date
Dec 1969
Posts
52

## RE: Impressive. Someone..

Did you want to see how many other programmers would use code to figure it out?

9. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## I dunno. Just curious how other..

.. people solved it.<BR><BR>I figured out via a little big of algebra and some code (as I posted).<BR><BR>I was just given another, and figured it out with just algebra (after seeing my friends answer).

10. Member
Join Date
Dec 1969
Posts
52

## RE: I dunno. Just curious how other..

OH OH!! Can I see the other one...I love logic! :)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•